15

I would like to fire an Intent to play a HLS (HTTP Live Stream) video.

What should I put in the type field to fire just the video players that support HLS?

I tried unsuccessfully the following:

video/m3u

video/m3u8

video/hls

application/x-mpegURL

vnd.apple.mpegURL

video/MP2T

application/vnd.apple.mpegurl

Ideas please...

5
  • The question relates to Android 3.0+, where HLS should be supported. Commented Feb 7, 2012 at 18:05
  • 1
    I'm successful playing HLS using mimetype 'video/*', but other players that do not support HLS can be fired as well, which results in crashes and freezes. Commented Feb 7, 2012 at 18:08
  • I couldn't find any documentation regarding the HLS (HTTP Live Stream) mime type except: developer.apple.com/library/ios/#documentation/… Commented Feb 9, 2012 at 10:41
  • 1
    Eventually, I used 'video/mp4' - from my tests, it gives a good enough result, because, from my experience, a lot of players handling 'video/mp4' can handle HLS as well. Commented Jul 12, 2012 at 10:37
  • ExoPlayer player please notice 「If your URI doesn’t end with .m3u8, you can pass MimeTypes.APPLICATION_M3U8 to setMimeType of MediaItem.Builder to explicitly indicate the type of the content.」ref
    – http8086
    Commented Nov 25, 2022 at 7:37

5 Answers 5

11

You should put the Content-Type type specified in the RFC: application/vnd.apple.mpegurl. See section 3.1 of https://datatracker.ietf.org/doc/html/draft-pantos-http-live-streaming-08

Android support for HLS is extremely poor. You will need some third party software on many devices, especially for versions less than 3. Google doesn't seem to care, or at least not to regression test.

1
  • 1
    As I wrote in the answer, I already tried 'application/vnd.apple.mpegurl' without success. Thanks anyway for trying. Commented Jun 6, 2012 at 12:56
6

Android code (ICS, JB) looks at the URL to determine player selection! If the URL contains the keyword m3u8, then and only then, will it play HLS. This is obviously a bug in Android.

1
4

The Mimetype for HLS format video is "application/x-mpegURL"

<video>
     <source src="example.m3u8" type="application/x-mpegURL">
</video>

This is according to Apple's official documentation (The creators of HLS). https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/DeployingHTTPLiveStreaming/DeployingHTTPLiveStreaming.html

2

Having the same issue but "audio/x-mpegURL" seems to work as is what the sample HLS stream on Apples site uses http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8 - testing on a Galaxy Nexus BTW.

Bit confusing though hence why I'm looking around.

6
  • audio? I'd like to play video. The point is that there are a lot of video players out there - implemented by manufacturers and store apps. If they don't handle HLS but handle 'audio/x-mpegURL' - this will NOT work. Commented Jul 12, 2012 at 10:33
  • Don't disagree that "audio" makes no sense. I'm just mentioning that it's what triggers the native player on my Galaxy Nexus.
    – Janaka
    Commented Aug 1, 2012 at 14:13
  • What native player? Google music? Commented Nov 22, 2012 at 16:11
  • Not Google Music. It's probably one of the few components in Android that isn't an app. If it is it's part of the Gallery app. BTW I've not tested this on Android 4.1 or 4.2, therefore no idea if this behaviour has changed (as it seems like a bug).
    – Janaka
    Commented Nov 26, 2012 at 19:10
  • 1
    I knew you would say that :) was too lazy to do that yest.
    – Janaka
    Commented Nov 27, 2012 at 10:30
1

The problem

When I used

<video id="player"
       src="http://hlsserver.example/auth/and/get/hls?authkey=42" 
       controls>
</video>

it failed with videoElement.error == error.MEDIA_ERR_SRC_NOT_SUPPORTED [1] on Chrome 40, even though Chrome requested the src URL three times as seen in tcpdump. This is the response from the server:

HTTP/1.1 200 OK
Content-Type: application/vnd.apple.mpegurl
[...]

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Swedish",AUTOSELECT=YES,DEFAULT=YES,URI="blah",LANGUAGE="swe"
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=500000,SUBTITLES="subs"
/stream-proxy/blah1
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=700000,SUBTITLES="subs"
/stream-proxy/blah2
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1000000,SUBTITLES="subs"
/stream-proxy/blah3

Footnotes

  1. MEDIA_ERR_SRC_NOT_SUPPORTED has a value of 4.

The solution

It seems like thoma.ing's answer is correct for Chrome 40 on Android 4.4.4 at least:

Android code (ICS, JB) looks at the URL to determine player selection! If the URL contains the keyword m3u8, then and only then, will it play HLS. This is obviously a bug in Android.

When I changed the video src URL to include the m3u8 keyword it started working perfectly fine on Chrome.

<video id="player"
       src="http://hlsserver.example/auth/and/get/hls?authkey=42&m3u8=yes"
       controls>
</video>
2
  • 1
    Hi. The question is about what mime-type to put in Android's intent, in order to be redirected to the appropriate activity/app. No html in the question - just a direct link to an HLS file. Commented Mar 26, 2015 at 8:34
  • My url is blablamdev.testcompany.com/msng/cdcc/AppleHLS1/… meida id/*~hmac=61a45cdb6e6f9fde4835522ad40fe9df0a7a2f , how should I change in java/android. i m getting error say " Caused by: com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403" when play this video in exo player. Commented May 13, 2021 at 6:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.