예제 #1
0
파일: Audio.cpp 프로젝트: renbing/Giraffe
void Audio::pause()
{
	if( !m_player )
	{
		return;
	}

	JniHelper jniHelper;

	JNIEnv *env = jniHelper.getEnv();
	jmethodID method = jniHelper.getMethod(m_player, "pause", "()V");
	if( env != NULL && method != NULL )
	{
		env->CallVoidMethod(m_player, method);
	}
}
예제 #2
0
파일: Audio.cpp 프로젝트: renbing/Giraffe
Audio::~Audio()
{
	LOG("Audio destructor: %s", m_src.c_str());
	if( m_player )
	{
		JniHelper jniHelper;

		JNIEnv *env = jniHelper.getEnv();
		jmethodID method = jniHelper.getMethod(m_player, "release", "()V");
		if( env != NULL && method != NULL )
		{
			LOG("Audio release");
			env->CallVoidMethod(m_player, method);
		}
		jniHelper.DeleteGlobalRef(m_player);
	}
}
예제 #3
0
파일: Audio.cpp 프로젝트: renbing/Giraffe
Audio::Audio()
{
	m_autoplay = false;
	m_loop = false;
	m_player = NULL;
	m_muted = false;
	m_volume = 1.0;

	JniHelper jniHelper;
	JNIEnv *env = jniHelper.getEnv();
	jmethodID newAudioPlayer = jniHelper.getMethod(g_jgl, "newAudioPlayer", "()Lcom/woyouquan/Giraffe/JavaAudioPlayer;");
	if( env != NULL && newAudioPlayer != NULL )
	{
		jobject player = env->CallObjectMethod(g_jgl, newAudioPlayer);
		m_player = env->NewGlobalRef(player);
	}
}
예제 #4
0
파일: Audio.cpp 프로젝트: renbing/Giraffe
void Audio::set_autoplay(bool autoplay)
{
	m_autoplay = autoplay;

	if( !m_player )
	{
		return;
	}

	JniHelper jniHelper;

	JNIEnv *env = jniHelper.getEnv();
	jmethodID method = jniHelper.getMethod(m_player, "setAutoplay", "(Z)V");
	if( env != NULL && method != NULL )
	{
		env->CallVoidMethod(m_player, method, autoplay);
	}
}
예제 #5
0
파일: Audio.cpp 프로젝트: renbing/Giraffe
void Audio::set_loop(bool loop)
{
	m_loop = loop;

	if( !m_player )
	{
		return;
	}

	JniHelper jniHelper;

	JNIEnv *env = jniHelper.getEnv();
	jmethodID method = jniHelper.getMethod(m_player, "setLoop", "(Z)V");
	if( env != NULL && method != NULL )
	{
		env->CallVoidMethod(m_player, method, loop);
	}
}
예제 #6
0
파일: Audio.cpp 프로젝트: renbing/Giraffe
void Audio::set_volume(float volume)
{
	m_volume = volume;

	if( !m_player )
	{
		return;
	}

	float realVolume = m_muted ? 0.0 : m_volume;

	JniHelper jniHelper;

	JNIEnv *env = jniHelper.getEnv();
	jmethodID method = jniHelper.getMethod(m_player, "setVolume", "(F)V");
	if( env != NULL && method != NULL )
	{
		env->CallVoidMethod(m_player, method, realVolume);
	}
}
예제 #7
0
파일: Audio.cpp 프로젝트: renbing/Giraffe
void Audio::set_src(string src)
{
	m_src = src;

	if( !m_player )
	{
		return;
	}

	string fullPath = JSCContext::getInstance()->path() + m_src;
	TRACE("Audio audio src:%s", fullPath.c_str());

	JniHelper jniHelper;

	JNIEnv *env = jniHelper.getEnv();
	jmethodID setSource = jniHelper.getMethod(m_player, "setSource", "(Ljava/lang/String;)V");
	if( env != NULL && setSource != NULL )
	{
		jstring path = env->NewStringUTF( fullPath.c_str() );
		env->CallVoidMethod(m_player, setSource, path);
        TRACE("Audio setSource");
	}
}