Exoplayer can't play some audio streams

4.9k Views Asked by At

I've developed some Android applications to listen to Internet radio stations.

For the audio stream, I had been using the Vitamio library. Unfortunately it is no longer supported and contains compatibility issues with Android 7.

After much trying, I decided to go to the ExoPlayer library. I was very pleased with the ease of use and constant updating. In addition, it decreased the size of my APK three times.

Unfortunatelly, ExoPlayer library is unable to play some audio streams. I've tried debugging, changing calls to URLs, and more. Unsuccessfully.

These are examples of streams that I can not play with the ExoPlayer library, but I could reproduce with Vitamio:

http://42747t.lp.azioncdn.net:1935/2747t/a/mp4:access_options/rtmp-live/atl_poa.sdp/playlist.m3u8 http://192747t.lp.azioncdn.net/2747t/a/mp4:access_options/rtmp-live/gau_centro.sdp/playlist.m3u8

Some of these streams are very important for my app success.

I do not have access to the server.

Here what says on logcat:

04-26 21:09:20.189 27953-27953/com.eneasgesing.radios.rs E/EventLogger: playerFailed [987.08] com.google.android.exoplayer2.ExoPlaybackException at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:345) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:154) at android.os.HandlerThread.run(HandlerThread.java:61) at com.google.android.exoplayer2.util.PriorityHandlerThread.run(PriorityHandlerThread.java:40) Caused by: com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor) could read the stream. at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractorHolder.selectExtractor(ExtractorMediaPeriod.java:713) at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:636) at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:295) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

2

There are 2 best solutions below

1
Nevermore On BEST ANSWER

It might help to see some of the code you're using to initiate the exoplayer, I'll assume you're using the standard ExtractorMediaSource

.m3u8 files are actually playlists, text files, which link to media files -- typically for livestreams. You'll need another MediaSource, try HLS, or HlsMediaSource instead of ExtractorMediaSource

HLS stands for HTTP Live Streaming.

0
Ankit Lathiya On

To play .m3u8 file use below code while initializing Exoplayer:

    Handler mHandler = new Handler();

    String userAgent = Util.getUserAgent(context, "Your Application Name");

    DataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory(
                    userAgent, null,
                    DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
                    1800000,
                    true);

    HlsMediaSource mediaSource = new HlsMediaSource(Uri.parse(mediaUrl),dataSourceFactory, 1800000,mHandler, null);

    if (mediaUrl != null) {
        videoPlayer.prepare(mediaSource);
        videoPlayer.setPlayWhenReady(true);
    }