javaandroidkotlinapple-musickit

Android Apple Musickit Decoding sample error -1inputFormat


I integrated Apple Musickit into an Android app. Randomly when I press play / pause / play I will get:

onPlaybackError() = com.apple.android.music.playback.model.a: Decoding sample error. ERROR decoding sample: -1inputFormat: Format(1, null, audio/mp4a-latm, -1, und, [-1, -1, -1.0], [2, 44100]) outputFormat: sampleRate[ 44100 ] numOfChannels[ 2 ] framesPerPacket[ 1024 ] outputFormat[ 1 encryption: PROTECTION_TYPE_PASTIS_FMP4 keyLen: 2364 keyHash: 134967062

Followed by:

onPlaybackError() = java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.a.a.a.g.j.c()' on a null object reference

Notice sometimes pressing play / pause / play will work correctly and other times I will get this. Then I just have to press pause / play again and it will work.

Anyone know a solution to this?


Solution

  • The cause was from loading these libraries more then once.

    System.loadLibrary("c++_shared");
    System.loadLibrary("appleMusicSDK");
    

    I was loading them on every play / song change instead of only the first time playing a song. I created a initializePlayer function to handle this.