2014-01-07 11:47:11 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2015-05-29 14:52:25 +08:00
|
|
|
Copyright (c) 2013-2015 Chukong Technologies Inc.
|
2014-01-07 11:47:11 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-07-23 07:12:18 +08:00
|
|
|
#include "cddandroidAndroidJavaEngine.h"
|
2015-05-29 14:52:25 +08:00
|
|
|
#include <stdlib.h>
|
2013-07-18 05:49:07 +08:00
|
|
|
#include <android/log.h>
|
|
|
|
#include <jni.h>
|
2015-05-29 14:52:25 +08:00
|
|
|
#include <sys/system_properties.h>
|
|
|
|
#include "platform/android/jni/JniHelper.h"
|
|
|
|
#include "ccdandroidUtils.h"
|
|
|
|
#include "audio/include/AudioEngine.h"
|
2013-07-18 05:49:07 +08:00
|
|
|
|
|
|
|
// logging
|
|
|
|
#define LOG_TAG "cocosdenshion::android::AndroidJavaEngine"
|
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
|
|
|
|
|
|
|
// Java class
|
|
|
|
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxHelper"
|
2013-07-23 07:12:18 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
using namespace cocos2d::experimental;
|
|
|
|
using namespace CocosDenshion::android;
|
|
|
|
|
|
|
|
static inline bool getJNIStaticMethodInfo(cocos2d::JniMethodInfo &methodinfo,
|
|
|
|
const char *methodName,
|
|
|
|
const char *paramCode) {
|
|
|
|
return cocos2d::JniHelper::getStaticMethodInfo(methodinfo,
|
|
|
|
CLASS_NAME,
|
|
|
|
methodName,
|
|
|
|
paramCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
AndroidJavaEngine::AndroidJavaEngine()
|
|
|
|
: _implementBaseOnAudioEngine(false)
|
|
|
|
, _effectVolume(1.f)
|
|
|
|
{
|
|
|
|
char sdk_ver_str[PROP_VALUE_MAX] = "0";
|
|
|
|
auto len = __system_property_get("ro.build.version.sdk", sdk_ver_str);
|
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
auto sdk_ver = atoi(sdk_ver_str);
|
|
|
|
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d", "android build version:%d", sdk_ver);
|
|
|
|
if (sdk_ver == 21)
|
|
|
|
{
|
|
|
|
_implementBaseOnAudioEngine = true;
|
2013-07-18 05:49:07 +08:00
|
|
|
}
|
2015-05-29 14:52:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d", "%s", "Fail to get android build version.");
|
|
|
|
}
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
AndroidJavaEngine::~AndroidJavaEngine() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "end", "()V")) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
void AndroidJavaEngine::preloadBackgroundMusic(const char* filePath) {
|
|
|
|
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(filePath);
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
// void playBackgroundMusic(String,boolean)
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "preloadBackgroundMusic", "(Ljava/lang/String;)V")) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
|
|
|
|
methodInfo.env->DeleteLocalRef(stringArg);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
void AndroidJavaEngine::playBackgroundMusic(const char* filePath, bool loop) {
|
|
|
|
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(filePath);
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "playBackgroundMusic", "(Ljava/lang/String;Z)V")) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg, loop);
|
|
|
|
methodInfo.env->DeleteLocalRef(stringArg);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
void AndroidJavaEngine::stopBackgroundMusic(bool releaseData) {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "stopBackgroundMusic", "()V")) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
void AndroidJavaEngine::pauseBackgroundMusic() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "pauseBackgroundMusic", "()V")) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
void AndroidJavaEngine::resumeBackgroundMusic() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "resumeBackgroundMusic", "()V")) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
void AndroidJavaEngine::rewindBackgroundMusic() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "rewindBackgroundMusic", "()V")) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-18 05:49:07 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AndroidJavaEngine::willPlayBackgroundMusic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AndroidJavaEngine::isBackgroundMusicPlaying() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
jboolean ret = false;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "isBackgroundMusicPlaying", "()Z")) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = methodInfo.env->CallStaticBooleanMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
float AndroidJavaEngine::getBackgroundMusicVolume() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
jfloat ret = -1.0;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "getBackgroundMusicVolume", "()F")) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AndroidJavaEngine::setBackgroundMusicVolume(float volume) {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "setBackgroundMusicVolume", "(F)V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static float _jni_getEffectsVolume() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
jfloat ret = -1.0;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "getEffectsVolume", "()F")) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = methodInfo.env->CallStaticFloatMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_setEffectsVolume(float volume) {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "setEffectsVolume", "(F)V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, volume);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int _jni_playEffect(const char* filePath, bool loop, float pitch, float pan, float gain)
|
|
|
|
{
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
int ret = 0;
|
|
|
|
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(filePath);
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "playEffect", "(Ljava/lang/String;ZFFF)I")) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
|
|
|
|
ret = methodInfo.env->CallStaticIntMethod(methodInfo.classID,
|
|
|
|
methodInfo.methodID,
|
|
|
|
stringArg,
|
|
|
|
loop,
|
|
|
|
pitch, pan, gain);
|
|
|
|
methodInfo.env->DeleteLocalRef(stringArg);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
|
|
|
|
return (unsigned int)ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_pauseEffect(unsigned int soundId) {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "pauseEffect", "(I)V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)soundId);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_pauseAllEffects() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "pauseAllEffects", "()V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_resumeEffect(unsigned int soundId) {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "resumeEffect", "(I)V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)soundId);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_resumeAllEffects() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "resumeAllEffects", "()V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_stopEffect(unsigned int soundId) {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "stopEffect", "(I)V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, (int)soundId);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_stopAllEffects() {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
|
|
|
|
if (!getJNIStaticMethodInfo(methodInfo, "stopAllEffects", "()V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void loadEffect(const char* filePath, char* loadEffectName) {
|
|
|
|
cocos2d::JniMethodInfo methodInfo;
|
|
|
|
std::string fullPath = CocosDenshion::android::getFullPathWithoutAssetsPrefix(filePath);
|
|
|
|
|
|
|
|
if (!cocos2d::JniHelper::getStaticMethodInfo(methodInfo, CLASS_NAME, loadEffectName, "(Ljava/lang/String;)V")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
jstring stringArg = methodInfo.env->NewStringUTF(fullPath.c_str());
|
|
|
|
methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, stringArg);
|
|
|
|
methodInfo.env->DeleteLocalRef(stringArg);
|
|
|
|
methodInfo.env->DeleteLocalRef(methodInfo.classID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_preloadEffect(const char* filePath) {
|
|
|
|
loadEffect(filePath, "preloadEffect");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _jni_unloadEffect(const char* filePath) {
|
|
|
|
loadEffect(filePath, "unloadEffect");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float AndroidJavaEngine::getEffectsVolume()
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
return _effectVolume;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return _jni_getEffectsVolume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AndroidJavaEngine::setEffectsVolume(float volume)
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
if (volume > 1.f)
|
|
|
|
{
|
|
|
|
volume = 1.f;
|
|
|
|
}
|
|
|
|
else if (volume < 0.f)
|
|
|
|
{
|
|
|
|
volume = 0.f;
|
2013-07-18 05:49:07 +08:00
|
|
|
}
|
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
if (_effectVolume != volume)
|
|
|
|
{
|
|
|
|
_effectVolume = volume;
|
|
|
|
for (auto& it : _soundIDs)
|
|
|
|
{
|
|
|
|
AudioEngine::setVolume(it.first, volume);
|
2013-07-18 05:49:07 +08:00
|
|
|
}
|
2015-05-29 14:52:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_jni_setEffectsVolume(volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int AndroidJavaEngine::playEffect(const char* filePath, bool loop,
|
|
|
|
float pitch, float pan, float gain)
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
auto soundID = AudioEngine::play2d(filePath, loop, _effectVolume);
|
|
|
|
if (soundID != AudioEngine::INVALID_AUDIO_ID)
|
|
|
|
{
|
|
|
|
_soundIDs[soundID] = soundID;
|
|
|
|
|
|
|
|
AudioEngine::setFinishCallback(soundID, [this](int id, const std::string& filePath){
|
|
|
|
_soundIDs.erase(id);
|
|
|
|
});
|
2013-07-18 05:49:07 +08:00
|
|
|
}
|
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
return soundID;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return _jni_playEffect(filePath, loop, pitch, pan, gain);
|
|
|
|
}
|
|
|
|
}
|
2015-02-23 17:20:12 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
void AndroidJavaEngine::pauseEffect(unsigned int soundID)
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
AudioEngine::pause(soundID);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_jni_pauseEffect(soundID);
|
|
|
|
}
|
|
|
|
}
|
2015-02-23 17:20:12 +08:00
|
|
|
|
2015-05-29 14:52:25 +08:00
|
|
|
void AndroidJavaEngine::resumeEffect(unsigned int soundID)
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
AudioEngine::resume(soundID);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_jni_resumeEffect(soundID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AndroidJavaEngine::stopEffect(unsigned int soundID)
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
AudioEngine::stop(soundID);
|
|
|
|
_soundIDs.erase(soundID);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_jni_stopEffect(soundID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AndroidJavaEngine::pauseAllEffects()
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
for (auto& it : _soundIDs)
|
|
|
|
{
|
|
|
|
AudioEngine::pause(it.first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_jni_pauseAllEffects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AndroidJavaEngine::resumeAllEffects()
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
for (auto& it : _soundIDs)
|
|
|
|
{
|
|
|
|
AudioEngine::resume(it.first);
|
2015-02-23 20:01:19 +08:00
|
|
|
}
|
2013-07-23 07:12:18 +08:00
|
|
|
}
|
2015-05-29 14:52:25 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
_jni_resumeAllEffects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AndroidJavaEngine::stopAllEffects()
|
|
|
|
{
|
|
|
|
if (_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
for (auto& it : _soundIDs)
|
|
|
|
{
|
|
|
|
AudioEngine::stop(it.first);
|
|
|
|
}
|
|
|
|
_soundIDs.clear();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_jni_stopAllEffects();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AndroidJavaEngine::preloadEffect(const char* filePath)
|
|
|
|
{
|
|
|
|
if (!_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
_jni_preloadEffect(filePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AndroidJavaEngine::unloadEffect(const char* filePath)
|
|
|
|
{
|
|
|
|
if (!_implementBaseOnAudioEngine)
|
|
|
|
{
|
|
|
|
_jni_unloadEffect(filePath);
|
|
|
|
}
|
|
|
|
}
|