• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Mix_HookMusicFinished函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: stopTrack

void Audio::startTrack(const std::string &trackName)
{
    //std::cout << "startTrack()" << std::endl;
	stopTrack();	//stop any existing music

	if (_opt._bMusic && trackName.length() > 0)
	{
		printf("Play: %s\n", trackName.c_str());
		std::string newTrack = _baseTrackDir + "/" + trackName;
        Mix_FreeMusic(_musicTrack);
		_musicTrack = Mix_LoadMUS(newTrack.c_str());
		if(_musicTrack)
		{
			Mix_PlayMusic(_musicTrack, 1);
			_bPlayingTrack = isActuallyPlayingMusic();	//actualy playing?
		}
		else
			printf("Failed to start track %s (%s)\n", newTrack.c_str(), Mix_GetError());

		Mix_HookMusicFinished(AudioTrackDone);	//reiterate callback
	}
	if (!_bPlayingTrack)
	{
		//TODO: play fail sound
	}
}
开发者ID:PurplePup,项目名称:Reword,代码行数:26,代码来源:audio.cpp


示例17: LOG

void SDLSound::playMusic(const char* directory)
{
    // Part1: scan directory for music files
    char **list = FileSystem::enumerateFiles(directory);

    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) {
        LOG (("Not found any music in '%s'", directory));
        return;
    }

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


示例18: Mix_HookMusicFinished

void SDLSound::stopMusic()
{
    // nicely fade the music out for 1 second
    if(Mix_PlayingMusic()) {
        Mix_HookMusicFinished(0);
        Mix_FadeOutMusic(500);
    }
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:8,代码来源:SDLSound.cpp


示例19: operator

	void operator ()()
	{
	

		while (Flc::flc.FrameCount >= introSoundTrack[trackPosition].frameNumber)
		{
			int command = introSoundTrack[trackPosition].sound;

			if (command & 0x200)
			{
#ifndef __NO_MUSIC
				switch(command)
				{
				case 0x200:
					Log(LOG_DEBUG) << "Playing gmintro1";
					m = rp->getMusic("GMINTRO1");
					m->play(1);
					break;
				case 0x201:
					Log(LOG_DEBUG) << "Playing gmintro2";
					m = rp->getMusic("GMINTRO2");
					m->play(1);
					break;
				case 0x202:
					Log(LOG_DEBUG) << "Playing gmintro3";
					m = rp->getMusic("GMINTRO3");
					m->play(1);
					Mix_HookMusicFinished(musicDone);
					break;
				}
#endif		
			}
			else if (command & 0x400)
			{
				Flc::flc.HeaderSpeed = (1000.0/70.0) * (command & 0xff);
				Log(LOG_DEBUG) << "Frame delay now: " << Flc::flc.HeaderSpeed;
			}
			else if (command <= 0x19)
			{
				for (soundInFile **sounds = introSounds; *sounds; ++sounds) // try hybrid sound set, then intro.cat or sample3.cat alone
				{
					soundInFile *sf = (*sounds) + command;
					int channel = trackPosition % 4; // use at most four channels to play sound effects
					Log(LOG_DEBUG) << "playing: " << sf->catFile << ":" << sf->sound << " for index " << command; 
					s = rp->getSound(sf->catFile, sf->sound);
					if (s)
					{
						s->play(channel);
						Mix_Volume(channel, sf->volume);
						break;
					}
					else Log(LOG_DEBUG) << "Couldn't play " << sf->catFile << ":" << sf->sound;
				}
			}
			++trackPosition;
		}

	}
开发者ID:Juju-Dredd,项目名称:OpenXcom,代码行数:58,代码来源:StartState.cpp


示例20: Mix_HookMusicFinished

void SoundManager::shutdown()
{
    config.removeListeners(this);

    // Unlink the callback function.
    Mix_HookMusicFinished(nullptr);

    CHECKLISTENERS
}
开发者ID:LogicTribe,项目名称:ManaPlus,代码行数:9,代码来源:soundmanager.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Mix_OpenAudio函数代码示例发布时间:2022-05-30
下一篇:
C++ Mix_HaltMusic函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap