google / ExoPlayer

An extensible media player for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exo 2.1.1 can not play HLS if initial link before redirect does not end with .m3u8

mariom86 opened this issue · comments

**** Scenario 1 ****
In the first step our application instructs exo player to playout the link of the following form:
http://x.y.z.w/_SR_VFY4Lm0zdTgjMjAxNzAyMjhUMTI0NTAwIzIwMTcwMjI4VDEzMjkwMCNNalkzTXpCa1pXWmhkV3gwTVRRNE9ESTRNekU0Tnk0d01q (Please note that there is no .m3u8 extension at the end)

The server responds with redirect and the following link: http://x.y.z.w/kqrkgcei5qcmusvaartsd1qivrnee1ui/0000001/GlobalHlsManifest.m3u8 (Please note there is .m3u8 extension at the end)

Player fetches file from the redirect link which is properly formatted .m3u8 playlist, but reports the following error:

Player error: 
 com.google.android.exoplayer2.ExoPlaybackException
     at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:360)
     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.ExtractorMediaSource$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:699)
     at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:623)
     at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:295)
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
     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)

**** Scenario 2 ****
In case that we rewrite the requested link on the proxy so that our application instructs Exo player to playout http://x.y.z.w/_SR_VFY4Lm0zdTgjMjAxNzAyMjhUMTI0NTAwIzIwMTcwMjI4VDEzMjkwMCNNalkzTXpCa1pXWmhkV3gwTVRRNE9ESTRNekU0Tnk0d01q.m3u8 (Please note that there is .m3u8 extension at the end) redirect and playout works OK.

Extra 1:
Exo player version 2.1.1

Extra 2:
In the Exo player 1.5.2 the scenario 1 was working OK

Extra 3:
Workaround with rewriting links on proxy will not work for us in the production environment.

Extra 4:
We tested with multiple mobiles on different android versions.

You just need to provide a hint to the player to tell it that it's an HLS stream. The sample should work fine in the demo app if you add it to media.exolist.json as:

      {
        "name": "My Sample",
        "uri": "http://x.y.z.w/_SR_VFY4Lm0zdTgjMjAxNzAyMjhUMTI0NTAwIzIwMTcwMjI4VDEzMjkwMCNNalkzTXpCa1pXWmhkV3gwTVRRNE9ESTRNekU0Tnk0d01q",
        "extension": "m3u8"
      },

This ensures that a HlsMediaSource is instantiated, rather than a ExtractorMediaSource. Note that in ExoPlayer V1 you were always required to explicitly indicate the type (HLS/DASH/SS/OTHER).