在调用stop方法后回调一个函数,然后在函数里面判断是否播放下一个URL
private static boolean playNext = false;
public void onCallPlayNext(){
if (playNext){
playNext = false;
prepared();
}
}
切换时将资源释放再重新播放
/**
* 播放下一曲回调
*/
public void onCallPlayNext(){
if (playNext){
playNext = false;
prepared();
}
}
extern "C"
JNIEXPORT void JNICALL
Java_com_example_myplayer_player_JfPlayer_n_1stop(JNIEnv *env, jobject instance) {
if (!nexit){
return;
}
// TODO
jclass jclz = env->GetObjectClass(instance);
jmethodID jmid_play_next = env->GetMethodID(jclz,"onCallPlayNext","()V");
nexit = false;
if (ffmpeg != NULL){
ffmpeg->release();
delete(ffmpeg);
ffmpeg = NULL;
if (callJava != NULL){
delete(callJava);
callJava = NULL;
}
if (playStatus != NULL){
delete(playStatus);
playStatus = NULL;
}
}
nexit = true;
env->CallVoidMethod(instance,jmid_play_next);
}
网友评论