I am using ExoPlayer for playing video in Android. I have 3 local mp4 files and want to create playlist from that files. I'm use ConcatenatingMediaSource to add all files to one playlist.
override fun playFromList(list: List<VideoEntity>) {
val userAgent = Util.getUserAgent(this, getString(R.string.app_name))
//2
val concatenatedSource = ConcatenatingMediaSource()
list.forEach {
if (it.localPath != null) {
val dataSourceFactory = DefaultDataSourceFactory(this, userAgent)
val extractorFactory = DefaultExtractorsFactory()
val mediaSource = ProgressiveMediaSource
.Factory(dataSourceFactory, extractorFactory)
.createMediaSource(Uri.parse(it.localPath))
concatenatedSource.addMediaSource(mediaSource)
}
exoPlayer.prepare(concatenatedSource)
}
exoPlayer.playWhenReady = true
exoPlayerView.player = exoPlayer
}
Unfortunately, some files produce error when playing and make exoplayer crash (not play other video).
E/ExoPlayerImplInternal: Source error.
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.
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractorHolder.selectExtractor(ProgressiveMediaPeriod.java:1059)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:947)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
My question is, how to catch that error so I can skip the file and continue playing other files?
Thank you