当前位置: 首页>>代码示例>>C++>>正文


C++ Mix_HookMusicFinished函数代码示例

本文整理汇总了C++中Mix_HookMusicFinished函数的典型用法代码示例。如果您正苦于以下问题:C++ Mix_HookMusicFinished函数的具体用法?C++ Mix_HookMusicFinished怎么用?C++ Mix_HookMusicFinished使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Mix_HookMusicFinished函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BOOST_ASSERT

void SoundProcessor::playMusic(boost::shared_ptr<const Music> play_music, const bool loop)
{

#ifdef _FMOD_SOUND
	BOOST_ASSERT(soundEngine);

	if(musicChannel) {
		musicChannel->stop();
	}
	soundEngine->playSound(FMOD_CHANNEL_FREE, play_music->getData(), 0, &musicChannel);

#elif _SDL_MIXER_SOUND

	bool success = false;

	// music currently playing?
	if(currentMusic != NULL)
	{
		// new music?
		if(play_music != NULL) {
			if(loop) {
				nextMusic = currentMusic;
			} else {
				nextMusic = NULL;
			}
			// transition between both music plays
			Mix_HookMusicFinished(::transitionMusic);
			success = (Mix_FadeOutMusic(MUSIC_TRANSITION_DURATION/2) == 1);
		} else 
			// empty music => Stop music, just fade out
		{
			success = (Mix_FadeOutMusic(MUSIC_TRANSITION_DURATION) == 1);
		}
	} else 
		// no music was playing
	{
		if(play_music != NULL)
		{
			currentMusic = play_music->getData();
			if(loop) {
				nextMusic = currentMusic;
			} else {
				nextMusic = NULL;
			}

			Mix_HookMusicFinished(::transitionMusic);
			success = (Mix_FadeInMusic(currentMusic, -1, MUSIC_TRANSITION_DURATION) == 0);
		} else {
			// no music played, no music to play
			success = true;
		}
	}

	if(!success) {
		std::ostringstream os;
		os << "ERROR (SoundProcessor::playMusic()): " << Mix_GetError() << "[" << play_music->getFileName() << "]";
		toErrorLog(os.str());
	}
#endif
}
开发者ID:LodePublishing,项目名称:GUI,代码行数:60,代码来源:soundprocessor.cpp

示例2: snd_play_mus

int snd_play_mus(char *fname, int ms, int loop)
{
	if (!sound_on)
		return 0;
	if (snd_playing_mus()) {
		if (next_mus) {
			free(next_mus);
		}
		next_mus = strdup(fname);
		next_fadein = ms;
		next_loop = loop;
		if (!timer_id)
			timer_id = SDL_AddTimer(200, callback, NULL);
		return 1;
	}
	if (mus)
		snd_free_mus(mus);

	mus = snd_load_mus(fname);
	if (!mus)
		return -1;
	if (loop >= 0)
		Mix_HookMusicFinished(game_music_finished);
	else
		Mix_HookMusicFinished(NULL);
	if (ms)
		Mix_FadeInMusic(mus->mus, loop, ms);
	else
		Mix_PlayMusic(mus->mus, loop);
	snd_volume_mus(snd_volume_mus(-1)); /* SDL hack? */
	return 0;
}
开发者ID:wimh,项目名称:instead,代码行数:32,代码来源:sound.c

示例3: Mix_HookMusicFinished

void CMusicHandler::init()
{
	CAudioBase::init();

	if (initialized)
		Mix_HookMusicFinished(musicFinishedCallbackC);
}
开发者ID:COJIDAT,项目名称:vcmi-ios,代码行数:7,代码来源:CMusicHandler.cpp

示例4: Mix_HookMusicFinished

Sound::~Sound()
{
    config.removeListeners(this);

    // Unlink the callback function.
    Mix_HookMusicFinished(nullptr);
}
开发者ID:Evonline,项目名称:ManaPlus,代码行数:7,代码来源:sound.cpp

示例5: stopMusic

/**
 * Play music.
 * @param file path to music file (i.e. *.ogg)
 * @param finished send this message when music is finished.
 * If finished is NULL, play music forever.
 */
void
SDLSoundAgent::playMusic(const Path &file,
        BaseMsg *finished)
{
    // The same music is not restarted when it is not needed.
    if (m_playingPath == file.getPosixName()
            && ms_finished == NULL && finished == NULL) {
        return;
    }

    stopMusic();
    m_playingPath = file.getPosixName();

    if (finished) {
        ms_finished = finished;
        m_music = Mix_LoadMUS(file.getNative().c_str());
        if (m_music && (0 == Mix_PlayMusic(m_music, 1))) {
            Mix_HookMusicFinished(musicFinished);
        }
        else {
            LOG_WARNING(ExInfo("cannot play music")
                    .addInfo("music", file.getNative())
                    .addInfo("Mix", Mix_GetError()));
        }
    }
    else {
        m_looper = new SDLMusicLooper(file);
        m_looper->setVolume(m_musicVolume);
        m_looper->start();
    }
}
开发者ID:Toast442,项目名称:FilletsNG,代码行数:37,代码来源:SDLSoundAgent.cpp

示例6: Mix_HookMusicFinished

void SoundHandler::stopMusic()
{
	m_musicPosition = 0;

	Mix_HookMusicFinished(nullptr);
	Mix_FadeOutMusic(1000);
}
开发者ID:MemoryLeek,项目名称:ld30,代码行数:7,代码来源:SoundHandler.cpp

示例7: handleKey

void handleKey(SDL_KeyboardEvent key) {
	switch(key.keysym.sym) {
  case SDLK_p:

	  if(key.type == SDL_KEYDOWN) {

		  if(phaserChannel < 0) {
			  phaserChannel = Mix_PlayChannel(-1, phaser, -1);
		  }
	  } else {
		  Mix_HaltChannel(phaserChannel);

		  phaserChannel = -1;
	  }
	  break;

  case SDLK_m:
	  if(key.state == SDL_PRESSED) {

		  if(music == NULL) {

			  music = Mix_LoadMUS("music.ogg");
			  Mix_PlayMusic(music, 0);
			  Mix_HookMusicFinished(handleKey);

		  } else {
			  Mix_HaltMusic();
			  Mix_FreeMusic(music);
			  music = NULL;
		  }
	  }
	  break;
	}
}
开发者ID:yzy6806555,项目名称:job,代码行数:34,代码来源:test3.cpp

示例8: Mix_HaltMusic

///////////////////////////////////////////////////////////
// BGM stop
///////////////////////////////////////////////////////////
void Audio::BGM_Stop() {
	if (bgm_playing) {
		Mix_HaltMusic();
		bgm_playing = false;
	}
	Mix_HookMusicFinished(NULL);
}
开发者ID:cstrahan,项目名称:argss,代码行数:10,代码来源:audio_sdl.cpp

示例9: Init

static bool Init()
{
   if (!gSDLIsInit)
   {
      ELOG("Please init Stage before creating sound.");
      return false;
   }

   if (!sChannelsInit)
   {
      sChannelsInit = true;
      for(int i=0;i<sMaxChannels;i++)
      {
         sUsedChannel[i] = false;
         sDoneChannel[i] = false;
      }
      Mix_ChannelFinished(onChannelDone);
      Mix_HookMusicFinished(onMusicDone);
      #ifndef EMSCRIPTEN
      Mix_SetPostMix(onPostMix,0);
      #endif
   }

   return sChannelsInit;
}
开发者ID:DanielUranga,项目名称:NME,代码行数:25,代码来源:SDLSound.cpp

示例10: Mix_VolumeMusic

///////////////////////////////////////////////////////////
// ME finish callback
///////////////////////////////////////////////////////////
void Audio::ME_finish() {
	Mix_VolumeMusic(Audio::bgm_volume);
	Mix_FadeInMusic(Audio::bgm, -1, 1000);
	Audio::bgm_playing = true;
	Audio::me_playing = false;
	Mix_HookMusicFinished(NULL);
}
开发者ID:cstrahan,项目名称:argss,代码行数:10,代码来源:audio_sdl.cpp

示例11: Mix_FadeOutMusic

///////////////////////////////////////////////////////////
// BGM fade
///////////////////////////////////////////////////////////
void Audio::BGM_Fade(int fade) {
	if (bgm_playing) {
		Mix_FadeOutMusic(fade);
		bgm_playing = false;
	}
	Mix_HookMusicFinished(NULL);
}
开发者ID:cstrahan,项目名称:argss,代码行数:10,代码来源:audio_sdl.cpp

示例12: fprintf

/**
 *  Treiberinitialisierungsfunktion.
 *
 *  @return @p true bei Erfolg, @p false bei Fehler
 *
 *  @author FloSoft
 */
bool AudioSDL::Initialize(void)
{
	if( SDL_InitSubSystem( SDL_INIT_AUDIO ) < 0 )
	{
		fprintf(stderr, "%s\n", SDL_GetError());
		initialized = false;
		return false;
	}

	// open 44.1KHz, signed 16bit, system byte order,
	// stereo audio, using 1024 byte chunks
	if(Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 4096) < 0)
	{
		fprintf(stderr, "%s\n", Mix_GetError());
		initialized = false;
		return false;
	}

	Mix_AllocateChannels(CHANNEL_COUNT);
	Mix_SetMusicCMD(NULL);
	Mix_HookMusicFinished(AudioSDL::MusicFinished);

	initialized = true;

	return initialized;
}
开发者ID:MiyaxinPittahai,项目名称:s25rttr,代码行数:33,代码来源:SDL.cpp

示例13: choose_track

void music_thinker::process(events::pump_info &info) {
	if(preferences::music_on()) {
		if(!music_start_time && !current_track_list.empty() && !Mix_PlayingMusic()) {
			// Pick next track, add ending time to its start time.
			current_track = choose_track();
			music_start_time = info.ticks();
			no_fading=true;
			fadingout_time=0;
		}

		if(music_start_time && info.ticks(&music_refresh, music_refresh_rate) >= music_start_time - fadingout_time) {
			want_new_music=true;
		}

		if(want_new_music) {
			if(Mix_PlayingMusic()) {
				Mix_FadeOutMusic(fadingout_time);
			}

			unload_music = false;
			play_new_music();
		}
	}

	if (unload_music) {
		for (auto track : music_cache) {
			Mix_FreeMusic(track.second);
		}
		music_cache.clear();

		Mix_HookMusicFinished(nullptr);

		unload_music = false;
	}
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:35,代码来源:sound.cpp

示例14: setMusicVolume

void SDLSound::playMusic(const char* directory)
{
    // Part1: scan directory for music files
    char **list = filesystem::enumerateFiles(directory);
    setMusicVolume(gameconfig->sound.getMusicVol());

    musicfiles.clear();
    for (char **i = list; *i != NULL; i++) {
        std::string filename = directory;
        filename.append(*i);
        if (!filesystem::isDirectory(filename.c_str())) {
            musicfiles.push_back(filename);
        }
    }
    filesystem::freeList(list);

    if(musicfiles.size() == 0) {
        LOGGER.info("Couldn't find any music in '%s'", directory);
        return;
    }

    // Part2: play music :)
    currentsong = musicfiles.end();
    nextSong();
    Mix_HookMusicFinished(nextSong);
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:26,代码来源:SDLSound.cpp

示例15: init_music_subsystem

void init_music_subsystem(void)
{
	// set this to any of 512,1024,2048,4096 the higher it is, the more FPS shown and CPU needed
	s32b audio_buffers = 512;

	/* Should we do sounds ? */
	esettings_get_int("audio.music.enable", 1);
	esettings_get_int("audio.effects.enable", 1);
	if (!esettings_get_int("audio.enable", 1))
	{
		sound_not_available = TRUE;
		return;
	}

	// initialize SDL_net
	if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, audio_buffers) == -1)
	{
		sound_not_available = TRUE;
		return;
	}

	Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
	Mix_Volume(-1, SDL_MIX_MAXVOLUME);

#ifdef USE_SDL
	if (!strcmp(ANGBAND_SYS, "sdl"))
	{
		Mix_HookMusicFinished(music_finished);
		Mix_ChannelFinished(channel_finished);
	}
#endif

	sound_not_available = FALSE;
}
开发者ID:jcubic,项目名称:ToME,代码行数:34,代码来源:music.c


注:本文中的Mix_HookMusicFinished函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。