React Native — Android ExoPlayer — Flac Support
I wanted to use react-native-track-player to play song in my app.
But unfortunately, it doesn’t come with support for Flac extension.
10-10 09:13:50.985 28050 28290 E ExoPlayerImplInternal: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor, AmrExtractor, Ac4Extractor) could read the stream.
10-10 09:13:50.985 28050 28290 E ExoPlayerImplInternal: at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractorHolder.selectExtractor(ProgressiveMediaPeriod.java:1059)
10-10 09:13:50.985 28050 28290 E ExoPlayerImplInternal: at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:947)
10-10 09:13:50.985 28050 28290 E ExoPlayerImplInternal: at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
10-10 09:13:50.985 28050 28290 E ExoPlayerImplInternal: at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
10-10 09:13:50.985 28050 28290 E ExoPlayerImplInternal: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
10-10 09:13:50.985 28050 28290 E ExoPlayerImplInternal: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
10-10 09:13:50.985 28050 28290 E ExoPlayerImplInternal: at java.lang.Thread.run(Thread.java:784)
I tried…
So I add to the try to compile another ExoPlayer with this kind of support. (Doc here and then here)
BUT
I can’t get through…
Always getting this error
No virtual method getData()[B in class Lcom/google/android/exoplayer2/util/ParsableByteArray; or its super classes (declaration of 'com.google.android.exoplayer2.util.ParsableByteArray' appears in /data/app/com.chronozik-VQVtUzWN-Z6QsHIPa0P3fw==/base.apk!classes2.dex)
(Yes, I know we can see the name of my app in this log have a look)
I tried with several extensions for ExoPlayer like flac, ffmep, … Still the same error.
I almost gave up.
And finally, 3 months latter
With the new Readme in ExoPlayer Github, a new hope arrive.
I saw on bintray that Exoplayer could come with another extractor.
So I changed
# root build.gradle
allprojects {
repositories {
# Your repositories
google()
jcenter() }
}
And
# app/build.gradle
dependencies {
# Your dependencies
// Add Audio Support
implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.1'
implementation 'com.google.android.exoplayer:exoplayer-extractor:2.12.1'}
And finally it worked !
Conclusion
I won’t say, never give up because I did gave up for ~3 months. So I’ll say know the things that you give up and from time to time come back again with new acknowledge and try again !
(I still don’t know why I haven’t been able to install ExoPlayer extension so if anyone had any success in it please share)