2011-01-12 11:49:54 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "SimpleAudioEngine.h"
|
2011-01-19 16:00:19 +08:00
|
|
|
#include "jni/SimpleAudioEngineJni.h"
|
2011-01-12 11:49:54 +08:00
|
|
|
|
|
|
|
namespace CocosDenshion
|
|
|
|
{
|
2012-03-04 11:25:01 +08:00
|
|
|
static SimpleAudioEngine *s_pEngine = 0;
|
2011-01-12 11:49:54 +08:00
|
|
|
|
|
|
|
SimpleAudioEngine::SimpleAudioEngine()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleAudioEngine::~SimpleAudioEngine()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleAudioEngine* SimpleAudioEngine::sharedEngine()
|
|
|
|
{
|
|
|
|
if (! s_pEngine)
|
|
|
|
{
|
|
|
|
s_pEngine = new SimpleAudioEngine();
|
|
|
|
}
|
|
|
|
|
|
|
|
return s_pEngine;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::end()
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
endJNI();
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
2011-05-06 10:13:12 +08:00
|
|
|
void SimpleAudioEngine::setResource(const char* pszZipFileName)
|
2011-01-12 11:49:54 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-01-14 17:42:37 +08:00
|
|
|
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
|
2011-01-12 11:49:54 +08:00
|
|
|
{
|
2011-08-28 10:24:52 +08:00
|
|
|
preloadBackgroundMusicJNI(pszFilePath);
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
|
|
|
|
{
|
2011-01-19 16:00:19 +08:00
|
|
|
playBackgroundMusicJNI(pszFilePath, bLoop);
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData)
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
stopBackgroundMusicJNI();
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::pauseBackgroundMusic()
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
pauseBackgroundMusicJNI();
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::resumeBackgroundMusic()
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
resumeBackgroundMusicJNI();
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::rewindBackgroundMusic()
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
rewindBackgroundMusicJNI();
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SimpleAudioEngine::willPlayBackgroundMusic()
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
return true;
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SimpleAudioEngine::isBackgroundMusicPlaying()
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
return isBackgroundMusicPlayingJNI();
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
2011-01-21 15:14:07 +08:00
|
|
|
float SimpleAudioEngine::getBackgroundMusicVolume()
|
2011-01-12 11:49:54 +08:00
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
return getBackgroundMusicVolumeJNI();
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
2011-01-21 15:14:07 +08:00
|
|
|
void SimpleAudioEngine::setBackgroundMusicVolume(float volume)
|
2011-01-12 11:49:54 +08:00
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
setBackgroundMusicVolumeJNI(volume);
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
2011-01-21 15:14:07 +08:00
|
|
|
float SimpleAudioEngine::getEffectsVolume()
|
2011-01-12 11:49:54 +08:00
|
|
|
{
|
2012-03-04 11:25:01 +08:00
|
|
|
return getEffectsVolumeJNI();
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
2011-01-21 15:14:07 +08:00
|
|
|
void SimpleAudioEngine::setEffectsVolume(float volume)
|
2011-01-12 11:49:54 +08:00
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
setEffectsVolumeJNI(volume);
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
2011-07-26 15:52:41 +08:00
|
|
|
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop)
|
2011-01-12 11:49:54 +08:00
|
|
|
{
|
2011-07-26 15:52:41 +08:00
|
|
|
return playEffectJNI(pszFilePath, bLoop);
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::stopEffect(unsigned int nSoundId)
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
stopEffectJNI(nSoundId);
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
preloadEffectJNI(pszFilePath);
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::unloadEffect(const char* pszFilePath)
|
|
|
|
{
|
2011-01-21 15:14:07 +08:00
|
|
|
unloadEffectJNI(pszFilePath);
|
2011-01-12 11:49:54 +08:00
|
|
|
}
|
2011-11-25 09:56:06 +08:00
|
|
|
|
|
|
|
void SimpleAudioEngine::pauseEffect(unsigned int nSoundId)
|
|
|
|
{
|
|
|
|
pauseEffectJNI(nSoundId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::pauseAllEffects()
|
|
|
|
{
|
|
|
|
pauseAllEffectsJNI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::resumeEffect(unsigned int nSoundId)
|
|
|
|
{
|
|
|
|
resumeEffectJNI(nSoundId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::resumeAllEffects()
|
|
|
|
{
|
|
|
|
resumeAllEffectsJNI();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimpleAudioEngine::stopAllEffects()
|
|
|
|
{
|
|
|
|
stopAllEffectsJNI();
|
|
|
|
}
|
2012-03-04 11:25:01 +08:00
|
|
|
}
|