示例#1
0
文件: omusic.cpp 项目: mecirt/7k2
// -------- begin of function Music::play ---------//
// <int> songId
// <int> playType   0 = non-looped, 1 = looped
int Music::play(int songId, int playType)
{
	if( !init_flag )
		return 0;

	stop();
		if( audio.wav_init_flag )
		{
			String waveFileStr(DIR_MUSIC);
			waveFileStr += music_file[songId-1];
			if( !DIR_MUSIC[0] || !m.is_file_exist(waveFileStr) || !audio.wav_init_flag )
				return 0;
			if( playType & MUSIC_PLAY_LOOPED )
                        {
                                AbsVolume absv(config.wav_music_volume,0);
                                music_channel = audio.play_loop_wav(waveFileStr, absv );
                        }
			else
                        {
                                AbsVolume absv(config.wav_music_volume,0);
                                music_channel = audio.play_long_wav(waveFileStr, absv );
                        }
			play_type = playType;
			song_id = songId;
			return music_channel >= 0;
		}
		return 0;
}
示例#2
0
文件: OMUSIC.cpp 项目: AMDmi3/7kaa
// -------- begin of function Music::play ---------//
// <int> songId
// <int> playType   0 = non-looped, 1 = looped
int Music::play(int songId, int playType)
{
	if( !init_flag )
		return 0;

	stop();

#ifdef BUNDLE
	// disable CD music
	playType &= ~MUSIC_CD_THEN_WAV & ~MUSIC_PLAY_CD;
#endif

	if( playType & MUSIC_CD_THEN_WAV )
	{
		return play(songId, playType & ~MUSIC_CD_THEN_WAV | MUSIC_PLAY_CD) 
			|| play(songId, playType & ~MUSIC_CD_THEN_WAV & ~MUSIC_PLAY_CD);
	}
	else if( playType & MUSIC_PLAY_CD )
	{
		if( audio.cd_init_flag && audio.play_cd(songId +1, config.cd_music_volume) ) // skip the first data track
		{
			play_type = playType;
			song_id = songId;
			music_channel = 1;
			return 1;
		}
		return 0;
	}
	else 
	{
		if( audio.wav_init_flag )
		{
			String waveFileStr(DIR_MUSIC);
			waveFileStr += music_file[songId-1];
			if( !DIR_MUSIC[0] || !misc.is_file_exist(waveFileStr) || !audio.wav_init_flag )
				return 0;
			if( playType & MUSIC_PLAY_LOOPED )
			{
				AbsVolume absv(config.wav_music_volume,0);
				music_channel = audio.play_loop_wav(waveFileStr, 0, absv );
			}
			else
			{
				AbsVolume absv(config.wav_music_volume,0);
				music_channel = audio.play_long_wav(waveFileStr, absv );
			}
			play_type = playType;
			song_id = songId;
			return music_channel != 0;
		}
		return 0;
	}
}