Example #1
0
bool Sound::Init()
{
	int32 strLength = (int32)fileName.length();
    if(strLength < 5)
        return false;
    
	String ext = fileName.substr(strLength-4, strLength);
	if(".wav" == ext)
	{
		provider = new SoundWVProvider(fileName);
	}
#if defined(__DAVAENGINE_WIN32__) || defined(__DAVAENGINE_MACOS__)
	else if(".ogg" == ext)
	{
		provider = new SoundOVProvider(fileName);
	}
#endif //#if defined(__DAVAENGINE_WIN32__) || defined(__DAVAENGINE_MACOS__)

#ifdef __DAVAENGINE_ANDROID__    
    if(TYPE_STATIC == type)
#endif //#ifdef __DAVAENGINE_ANDROID__ 
        if(!provider)
            return false;

    if(TYPE_STATIC == type)
	{
		if(!PrepareStaticBuffer())
            return false;
#ifdef __DAVAENGINE_ANDROID__
        InitBufferQueueAudioPlayer();
#endif //#ifdef __DAVAENGINE_ANDROID__
        
    }
    else if (TYPE_STREAMED == type)
    {
#ifndef __DAVAENGINE_ANDROID__
		if(!provider->Init())
        {
            return false;
        }
        provider->Rewind();
#else
        if(!InitAssetAudioPlayer())
            return false;
#endif //#ifndef __DAVAENGINE_ANDROID__        
    }

#ifdef __DAVAENGINE_ANDROID__
    minVolumeLevel = SL_MILLIBEL_MIN;
    (*playerVolume)->GetMaxVolumeLevel(playerVolume, &maxVolumeLevel);
#endif //#ifdef __DAVAENGINE_ANDROID__  
    return true;
}
Example #2
0
void Sound::Init()
{
	int32 strLength = (int32)fileName.length();
	String ext = fileName.substr(strLength-4, strLength);
	if(".wav" == ext)
	{
		provider = new SoundWVProvider(fileName);
	}
#if defined(__DAVAENGINE_WIN32__) || defined(__DAVAENGINE_MACOS__)
	else if(".ogg" == ext)
	{
		provider = new SoundOVProvider(fileName);
	}
#endif

	if(TYPE_STATIC == type)
	{
		PrepareStaticBuffer();
	}
}