/* function: Mix_ResumeMusic */ static int toluaI_sound_sound_resume_music00(lua_State* tolua_S) { if ( !tolua_isnoobj(tolua_S,1) ) goto tolua_lerror; else { { Mix_ResumeMusic(); } } return 0; tolua_lerror: tolua_error(tolua_S,"#ferror in function 'resume_music'."); return 0; }
void jhi_replay_music(JHI_Music *music, int loop) { if (Mix_PausedMusic() == 1) { Mix_ResumeMusic(); } if (Mix_PlayingMusic() != 0) { jhi_stop_music(); } jhi_free_music(music); jhi_load_music(music, music->filename); jhi_play_music(music, loop); }
void handleKey(SDL_KeyboardEvent key) { switch(key.keysym.sym) { case SDLK_p: shoot(phaser, NULL, key.type); break; case SDLK_1: shoot(one, oneEnd, key.type); break; case SDLK_2: shoot(two, twoEnd, key.type); break; case SDLK_3: shoot(three, threeEnd, key.type); break; case SDLK_4: shoot(four, fourEnd, key.type); break; case SDLK_5: shoot(five, fiveEnd, key.type); break; case SDLK_6: shoot(six, sixEnd, key.type); break; case SDLK_m: if(key.state == SDL_PRESSED) { if(music == NULL) { music = Mix_LoadMUS("music.ogg"); Mix_PlayMusic(music, 0); Mix_HookMusicFinished(musicDone); } if (!musicPlaying) { printf("Play\n"); musicPlaying = 1; Mix_ResumeMusic(); } else { printf("Pause\n"); musicPlaying = 0; Mix_PauseMusic(); //Mix_HaltMusic(); //Mix_FreeMusic(music); //music = NULL; } } break; } }
//---------------------------------------------------------------------------------------------------------------------- void Game::update() { // only update if game is acutally playing if(m_playing) { // if the music is paused when changing levels if(Mix_PausedMusic()==1) { // play the music Mix_ResumeMusic(); } // update all the game's systems m_controlSys.update(m_rotX, m_rotY); m_sensorSys.update(); m_autoSys.update(); // get rid of dead boids cleanup(); m_flightSys.update(); m_combatSys.update(); // check if vulnerable boid lists are empty if(m_world->m_stdBoids.empty() && m_world->m_ldrBoids.empty()) { // increment the level ++m_level; // if level is still within max levels if(m_level<m_maxLevels) { // congratulations for beating level, loading new level Mix_PauseMusic(); // load next level after reset m_world->resetWorld(); loadLevel(m_levelList[m_level]); } else { // finished the game, return to menu gameover(); } } if(m_world->m_player->m_auto.m_dead) { // gameover, return to menu gameover(); } } }
void CSound::SetPause (bool Pause) { // If the sound works if (m_SoundOK) { if (Pause) { Mix_PauseMusic(); } else { Mix_ResumeMusic(); } m_GlobalPause = Pause; } }
void music_muter::handle_window_event(const SDL_Event& event) { if (preferences::stop_music_in_background() && preferences::music_on()) { if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { Mix_ResumeMusic(); } else if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) { if (Mix_PlayingMusic()) { Mix_PauseMusic(); } } } }
void cMusicSDL2::Play(int _repeat, int fade){ if(music != NULL){ if(Mix_PlayingMusic() > 0){ //Music is already playing if(isPaused){ Mix_ResumeMusic(); isPaused = false; return; }else if(Mix_FadingMusic() == MIX_FADING_OUT){ Mix_HaltMusic(); }else{ return; } } if(Mix_FadeInMusic(music, _repeat, fade) < 0){ StormPrintLog(STORM_LOG_ERROR, "cMusicSDL2", "Error %s", Mix_GetError()); } } }
void Player::Play() { if (MusicPaused) { Mix_ResumeMusic(); MusicPaused = false; } else { //Get first song to play //TEMP: just grab test song current = Mix_LoadMUS("song.flac"); next = Mix_LoadMUS("next.flac"); if (!current) { fprintf(stderr, "Error opening music file: %s\n", SDL_GetError()); exit(1); } playCurrent(); } }
void one_iter() { static int frames = 0; frames++; switch( frames ) { case 1: soundChannel = Mix_PlayChannel(-1, sound, 0); printf("channel = %d", soundChannel); assert(soundChannel != -1 && soundChannel != 0); break; case 2: printf("channel %d is playing = %d", soundChannel, Mix_Playing(soundChannel)); assert(Mix_Playing(soundChannel)); break; case 30: Mix_Pause(soundChannel); Mix_PlayMusic(music, 1); break; case 31: assert(Mix_Paused(soundChannel)); assert(Mix_PlayingMusic()); break; case 60: Mix_Resume(soundChannel); Mix_PauseMusic(); break; case 61: assert(Mix_Playing(soundChannel)); assert(Mix_PausedMusic()); break; case 90: Mix_ResumeMusic(); break; case 91: assert(Mix_PlayingMusic()); break; case 120: Mix_HaltChannel(soundChannel); Mix_HaltMusic(); int result = 1; REPORT_RESULT(); break; }; }
bool Tela::showConfScreen() { bool quit = false, execute = true; if(audio) { applySurface( 0, 0, telaConfigSound_ON, screen ); SDL_Flip( screen ); } else { applySurface( 0, 0, telaConfigSound_OFF, screen ); SDL_Flip( screen ); } while( execute ) { if( SDL_PollEvent( &event ) ) { Ponto tmp; if( event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_LEFT) { tmp.x = event.button.x; tmp.y = event.button.y; if((tmp.x >= 590 && tmp.x <= 645) && (tmp.y >= 100 && tmp.y <= 160)) { execute = false; } else if((tmp.x >= 140 && tmp.x <= 660) && (tmp.y >= 60 && tmp.y <= 580)) { if(audio) { applySurface( 0, 0, telaConfigSound_OFF, screen ); SDL_Flip( screen ); audio = false; Mix_PauseMusic(); } else { applySurface( 0, 0, telaConfigSound_ON, screen ); SDL_Flip( screen ); audio = true; Mix_ResumeMusic(); } } } else if( (event.type == SDL_QUIT) || (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) { //Encerra programa quit = true; return quit; } } } return execute; }
//Checks if music is on void Application::checkMusic() { if (isMusicOn) { isMusicOn = false; Mix_PauseMusic(); } else { isMusicOn = true; if (Mix_PausedMusic() == 1) { Mix_ResumeMusic(); } else { Mix_PlayMusic(menuBackgroundSound, 10); } } }
void GameThroneMode::GameOver() { const int fontSize = 60; int middleX=(int) RESX/2; int middleY=(int) RESY/2; if(snake1->GetDead()) { player2Score++; DrawText(middleX-250,middleY-10,"Player WASD WIN",fontSize,250,152,5); } if(snake2->GetDead()) { player1Score++; DrawText(middleX-250,middleY-10,"Player ULDR WIN",fontSize,250,152,5); } SDL_Flip(screen); Mix_PauseMusic(); Mix_PlayChannel(-1,sounds[4],0); SDL_Delay(4500); Mix_ResumeMusic(); for(int i=0;i<65;i++) { for(int j=0;j<35;j++) { Converter.CreateConvert<CellEmpty>(i,j); } } Converter.Convert(); delete snake1; delete snake2; snake1=new Snake(Left,"Snake1",CellStruct(61,17),CellStruct(62,17),CellStruct(63,17)); snake2=new Snake(Right,"Snake2",CellStruct(3,18),CellStruct(2,18),CellStruct(1,18),1); SDL_PumpEvents(); SDL_Event event[30]; SDL_PeepEvents(event,30,SDL_GETEVENT,SDL_KEYDOWNMASK); }
void SDLH_Play(void) { musicMutex = !songs.empty(); while (musicMutex) { HIDUSER_GetSoundVolume(¤tVolume); if (!Mix_PlayingMusic() || (currentVolume == 0 && songs.size() > 1)) { if (song) { Mix_FreeMusic(song); song = nullptr; } if (Configuration::getInstance().randomMusic()) { currentSong = randomNumbers() % songs.size(); } else { currentSong = (currentSong + 1) % songs.size(); } song = Mix_LoadMUS(songs[currentSong].c_str()); Mix_PlayMusic(song, 1); } if (currentVolume == 0) { Mix_PauseMusic(); } while (currentVolume == 0 && musicMutex) { HIDUSER_GetSoundVolume(¤tVolume); svcSleepThread(250000000); } if (Mix_PausedMusic() && musicMutex) { Mix_ResumeMusic(); } svcSleepThread(250000000); } donePlaying = true; }
void startStopSound() { if( Mix_PlayingMusic() == 0 ) { Mix_PlayMusic( gMusic, -1 ); chunk = true; } else { if( Mix_PausedMusic() == 1 ) { Mix_ResumeMusic(); chunk = true; } else { Mix_PauseMusic(); chunk = false; } } }
void audio_set_music_on_off (int on) { #ifdef USE_AUDIO if (!sound_supported) return; if (on) { if (Mix_PausedMusic()) Mix_ResumeMusic(); else { while (Mix_FadingMusic() == MIX_FADING_OUT) SDL_Delay(100); } if (music[currentMus]) Mix_FadeInMusic (music[currentMus], -1, 1000); } else { while (Mix_FadingMusic() == MIX_FADING_IN) SDL_Delay(100); Mix_FadeOutMusic (1000); } music_on = on; #endif }
void Menu(void) { char buf[10]; printf("Available commands: (p)ause (r)esume (h)alt > "); fflush(stdin); scanf("%s",buf); switch(buf[0]){ case 'p': case 'P': Mix_PauseMusic(); break; case 'r': case 'R': Mix_ResumeMusic(); break; case 'h': case 'H': Mix_HaltMusic(); break; } printf("Music playing: %s Paused: %s\n", Mix_PlayingMusic() ? "yes" : "no", Mix_PausedMusic() ? "yes" : "no"); }
int BEE::Sound::resume() { if (!is_loaded) { if (!has_play_failed) { game->messenger_send({"engine", "sound"}, BEE_MESSAGE_WARNING, "Failed to resume sound \"" + name + "\" because it is not loaded"); has_play_failed = true; } return 1; } if (is_music) { Mix_ResumeMusic(); } else { for (auto i=current_channels.begin(); i != current_channels.end(); ++i) { Mix_Resume(*i); } } is_playing = true; return 0; }
void Sound::playMusic(Mix_Music *song) { //If no Music is playing if (Mix_PlayingMusic() == 0) { //Play the music Mix_PlayMusic(goneFishing, -1); } else { //If music is paused if (Mix_PausedMusic() == 1) { //Resume the music Mix_ResumeMusic(); } } }
void MusicSound::Play(int loopCount) { if(Mix_PausedMusic()) { Mix_ResumeMusic(); } else { if(Mix_PlayMusic(MusicAudio, loopCount)==-1) { #ifdef DEBUG_MODE printf("Mix_LoadPlay Error: %s\n", Mix_GetError()); #endif } if(loopCount == -1) { looping = true; } } }
void Music::pauseResume() { if(tipo == SOM) { if(Mix_Paused(0)) { Mix_Resume(0); } else if(Mix_Playing(0)) { Mix_Pause(0); } if(Mix_Paused(1)) { Mix_Resume(1); } else if(Mix_Playing(1)) { Mix_Pause(1); } } else { if(Mix_PausedMusic()) { Mix_ResumeMusic(); } else { Mix_PauseMusic(); } } }
//Pauses music //Returns the playing state after the function runs int musicTogglePause() { //If music is playing (it may be paused, but not stopped) if (Mix_PlayingMusic() == 1) { //If music is paused if (Mix_PausedMusic() == 1) { //Resume music Mix_ResumeMusic(); return LC_MUSIC_PLAYING; } //If music isn't paused else { //Pause music Mix_PauseMusic(); return LC_MUSIC_PAUSED; } } return LC_MUSIC_STOPPED; } //void musicTogglePause()
/* Check for the quit event, return true if detected*/ char getEvent(display *d, Button *buttons[NUM_BUTTONS], Button *HomeButtons[HOME_BUTTON_NUM], Button *OptionButtons[O_B_TOTAL]) { char what = NONE; int sym; //avoid repeating inputs --------------------- while (SDL_PollEvent(d->event) != 0) { int x, y; SDL_GetMouseState(&x, &y); switch (d->event->type) { case SDL_QUIT: what = QUIT; break; case SDL_TEXTINPUT: if ((what != CLICK1) && (what != HINT)) { what = d->event->text.text[0]; printf("ordinary character form keyboard %c\n", what); fflush(stdout); break; } case SDL_KEYDOWN: sym = d->event->key.keysym.sym; if (sym == ENTER) { what = (char)sym; } else if ((sym == SDLK_LCTRL) || (sym == SDLK_RCTRL)) { ctrl_pressed = true; //ctrl part-------------- } else if (ctrl_pressed) { if (sym == MUTE) { if (Mix_PausedMusic() == true) { Mix_ResumeMusic(); m_state = MUSIC_ON; } else { Mix_PauseMusic(); m_state = MUSIC_OFF; } } if (sym == SDLK_q) { what = QUIT; } //----------next song if (sym == SDLK_n) { NextSong(); m_state = MUSIC_ON; } ctrl_pressed = false; } else if (sym == BS || sym == TAB || sym == ENTER || sym == DEL) { what = (char)sym; } else if (sym == SDLK_UP) { what = (char)UP; } else if (sym == SDLK_DOWN) { what = (char)DOWN; } else if (sym == SDLK_LEFT) { what = (char)LEFT; } else if (sym == SDLK_RIGHT) { what = (char)RIGHT; } break; case SDL_MOUSEBUTTONDOWN: printf("in mouse %d %d\n", d->event->button.x, d->event->button.y); fflush(stdout); //------------------------------------- if (gScene == HOME_SCREEN) { if (is_point_in_rect(d->event->button.x, d->event->button.y, &HomeButtons[0]->rectangle)) { what = ENTER_GAME; } if (is_point_in_rect(d->event->button.x, d->event->button.y, &HomeButtons[1]->rectangle)) { what = ENTER_OPTION; } if (is_point_in_rect(d->event->button.x, d->event->button.y, &HomeButtons[2]->rectangle)) { what = ENTER_ABOUT; } } else if (gScene == GAME_SCREEN) { if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[0]->rectangle)) { what = CLICK1; } else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[1]->rectangle)) { what = HINT; } else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[2]->rectangle)) { what = NEWGAME; } else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[3]->rectangle)) { what = STOOL; } else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[4]->rectangle)) { what = BOOTH; } else if (is_point_in_rect(d->event->button.x, d->event->button.y, &buttons[5]->rectangle)) { what = GREEN; } } break; case SDL_MOUSEMOTION: if (gScene == HOME_SCREEN) { if (is_point_in_rect(x, y, &HomeButtons[0]->rectangle)) { what = HOVER_GAME; } else if (is_point_in_rect(x, y, &HomeButtons[1]->rectangle)) { what = HOVER_OPTION; } else if (is_point_in_rect(x, y, &HomeButtons[2]->rectangle)) { what = HOVER_ABOUT; } else { what = OUT_BUTTON; } } else if (gScene == OPTION_SCREEN) { if (is_point_in_rect(x, y, &OptionButtons[BACK]->rectangle)) { what = BACK_HOVER; } else { what = OUT_BACK; } } break; case SDL_MOUSEBUTTONUP: if (gScene == OPTION_SCREEN) { if (is_point_in_rect(x, y, &OptionButtons[BACK]->rectangle)) { what = BACK_HOME; } } break; default: break; } } return what; }
void Music::resume() { Mix_ResumeMusic(); }
void AudioController::unpause_music() { Mix_ResumeMusic(); }
void SoundManager::play(int i) { //If there is no music playing switch (i) { case GUN_PICKUP: Mix_PlayChannel(GUN_PICKUP, gunPickup, 0); break; case SCORE_PICKUP: Mix_PlayChannel(SCORE_PICKUP, scorePickup, 0); break; case GUNSHOT: Mix_PlayChannel(GUNSHOT, gunshot, 0); break; case HEALTH: Mix_PlayChannel(HEALTH, health, 0); break; case MINE: Mix_PlayChannel(MINE, mine, 0); break; case ELECTROCUTED: Mix_PlayChannel(ELECTROCUTED, electrocuted, 0); break; case SWITCH: Mix_PlayChannel(SWITCH, switchSound, 0); break; case MENU_MUSIC: // If there is no music playing if (Mix_PlayingMusic() == 0) { //Play the music Mix_PlayMusic(menuMusic, -1);// -1 means we want it to loop until it is stopped } // If the music is being played else { //If the music is paused if (Mix_PausedMusic() == 1 && SoundOn()) { //Resume the music Mix_ResumeMusic(); } //If the music is playing else { if (!SoundOn()) { //Pause the music Mix_PauseMusic(); } } } break; case LEVEL_ONE_MUSIC: if (Mix_PlayingMusic() == 0) { //Play the music Mix_PlayMusic(levelOneMusic, -1); } else { //If the music is paused if (Mix_PausedMusic() == 1 && SoundOn()) { //Resume the music Mix_ResumeMusic(); } //If the music is playing else { if (!SoundOn()) { //Pause the music Mix_PauseMusic(); } } } break; case LEVEL_TWO_MUSIC: if (Mix_PlayingMusic() == 0) { //Play the music Mix_PlayMusic(levelTwoMusic, -1); } else { //If the music is paused if (Mix_PausedMusic() == 1 && SoundOn()) { //Resume the music Mix_ResumeMusic(); } //If the music is playing else { if (!SoundOn()) { //Pause the music Mix_PauseMusic(); } } } break; case LEVEL_THREE_MUSIC: if (Mix_PlayingMusic() == 0) { //Play the music Mix_PlayMusic(levelThreeMusic, -1); } else { //If the music is paused if (Mix_PausedMusic() == 1 && SoundOn()) { //Resume the music Mix_ResumeMusic(); } //If the music is playing else { if (!SoundOn()) { //Pause the music Mix_PauseMusic(); } } } break; case LEVEL_FOUR_MUSIC: if (Mix_PlayingMusic() == 0) { //Play the music Mix_PlayMusic(levelFourMusic, -1); } else { //If the music is paused if (Mix_PausedMusic() == 1 && SoundOn()) { //Resume the music Mix_ResumeMusic(); } //If the music is playing else { if (!SoundOn()) { //Pause the music Mix_PauseMusic(); } } } break; case VICTORY: if (Mix_PlayingMusic() == 0) { //Play the music Mix_PlayMusic(victory, -1); } else { //If the music is paused if (Mix_PausedMusic() == 1 && SoundOn()) { //Resume the music Mix_ResumeMusic(); } //If the music is playing else { if (!SoundOn()) { //Pause the music Mix_PauseMusic(); } } } break; } }
int Musica::reanudarSonMus() { Mix_ResumeMusic(); }
extern "C" int SDL_main(int, char **) // 2-arg form is required by SDL { if (!sdlInit(250, 140, "../img/icon.png", "Music Test")) { return EXIT_FAILURE; } SdlSurface play = sdlLoadImage("../img/button-play.png"); SdlSurface pause = sdlLoadImage("../img/button-pause.png"); SdlSurface next = sdlLoadImage("../img/button-next.png"); SdlSurface prev = sdlLoadImage("../img/button-prev.png"); // Define the control buttons. GuiButton playButton{105, 90, play}; GuiButton nextTrack{155, 90, next}; GuiButton prevTrack{55, 90, prev}; std::vector<GuiButton *> buttons = {&playButton, &nextTrack, &prevTrack}; auto font = sdlLoadFont("../DejaVuSans.ttf", 14); auto white = SDL_Color{255, 255, 255, 0}; sdlDrawText(font, "Now playing:", SDL_Rect{10, 10, 230, 20}, white); auto trackTitle = SDL_Rect{10, 30, 230, 50}; sdlDrawText(font, "Nothing", trackTitle, white); SDL_UpdateRect(screen, 0, 0, 0, 0); auto musicFiles = getMusicFiles("../music"); assert(!musicFiles.empty()); int trackNum = 0; playButton.onClick([&] { if (!Mix_PlayingMusic()) { // have we started playing music at all auto &track = musicFiles[trackNum]; sdlPlayMusic(track.music); playButton.setImage(pause); sdlDrawText(font, track.path, trackTitle, white); } else { if (Mix_PausedMusic()) { playButton.setImage(pause); Mix_ResumeMusic(); } else { playButton.setImage(play); Mix_PauseMusic(); } } }); nextTrack.onClick([&] { if (!Mix_PlayingMusic()) return; trackNum = (trackNum + 1) % musicFiles.size(); auto &track = musicFiles[trackNum]; sdlDrawText(font, track.path, trackTitle, white); if (Mix_PausedMusic()) { sdlPlayMusic(track.music); Mix_PauseMusic(); } else { sdlPlayMusic(track.music); } }); prevTrack.onClick([&] { if (!Mix_PlayingMusic()) return; trackNum = (trackNum - 1) % musicFiles.size(); auto &track = musicFiles[trackNum]; sdlDrawText(font, track.path, trackTitle, white); if (Mix_PausedMusic()) { sdlPlayMusic(track.music); Mix_PauseMusic(); } else { sdlPlayMusic(track.music); } }); bool isDone = false; SDL_Event event; while (!isDone) { while (SDL_PollEvent(&event)) { if (event.type == SDL_MOUSEBUTTONUP) { handleMouseUp(event.button, buttons); } else if (event.type == SDL_QUIT) { Mix_HaltMusic(); isDone = true; } } SDL_UpdateRect(screen, 0, 0, 0, 0); SDL_Delay(1); } return EXIT_SUCCESS; }
void SDLManager::resumeMusic() { if (SDLManager::musicPaused()) Mix_ResumeMusic(); }
void Sound_unpause_music(void) { Mix_ResumeMusic(); } /* Sound_unpause_music */
void AudioPlayer::resumeMusic() { Mix_ResumeMusic(); }