0

我开始为我的音乐播放器应用程序项目使用 Superpowered 本机 SDK,但我在 SuperpoweredAdvancedAudioPlayer 回调中将方法从 End-Of-File 事件传递给 java 时遇到了困难。如果我做错了,请原谅我,因为我是使用 Android 原生 JNI C 端的新手。非常感谢任何尝试或帮助。先感谢您。

    static void playerEventCallbackA(void *clientData, SuperpoweredAdvancedAudioPlayerEvent event, void *value) {

            SuperpoweredAdvancedAudioPlayer *playerA = *((SuperpoweredAdvancedAudioPlayer **)clientData);
        if (event == SuperpoweredAdvancedAudioPlayerEvent_LoadSuccess) {

        }else if (event == SuperpoweredAdvancedAudioPlayerEvent_EOF && !playerA->looping) {


        *The event to notify Java for end of file takes place here. 
Please help to suggest any line of code or method that can notify 
Android when this event kicks in. Personally, I have searched online,
 all I found similar was an "Interface" method on java side which 
I have no idea about. Please help*

    }else if (event == SuperpoweredAdvancedAudioPlayerEvent_LoadError) {

             delete playerA;
        }
    }
4

1 回答 1

1

从原生层调用 Java 比从 Java 调用原生层还要复杂。此外,不推荐使用 Java 阻止处理音频的本机线程(您会听到音频故障)。因此,我建议采取逆向方法。

当您获得 EOF 时设置一些变量,并从 Java 定期(如每 50 毫秒)轮询该变量,调用本机层。

于 2017-08-15T17:26:21.617 回答