0

I started using the Superpowered native SDK for my music player app project but I get stuck passing a method to java from the End-Of-File event in the SuperpoweredAdvancedAudioPlayer callback. Please pardon me if I am doing it all wrong as I am new to using the native JNI C side of Android. Any attempt or help is much appreciated. Thank you in advance.

    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;
        }
    }

1 Answers1

1

Calling Java from the native layer is even more complex than calling the native layer from Java. Furthermore, blocking native threads processing audio by Java is not a recommended practice (you'll hear audio glitches). Therefore I recommend to take an inverse approach.

Set some variable when you get EOF, and poll that variable periodically (like every 50 ms) from Java, calling the native layer.

Gabor Szanto
  • 1,329
  • 8
  • 12