14

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...

AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277
  • The question relates to Android 3.0+, where HLS should be supported. – AlikElzin-kilaka Feb 07 '12 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. – AlikElzin-kilaka Feb 07 '12 at 18:08
  • I couldn't find any documentation regarding the HLS (HTTP Live Stream) mime type except: https://developer.apple.com/library/ios/#documentation/networkinginternet/conceptual/streamingmediaguide/HTTPStreamingArchitecture/HTTPStreamingArchitecture.html – AlikElzin-kilaka Feb 09 '12 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. – AlikElzin-kilaka Jul 12 '12 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](https://exoplayer.dev/hls.html#using-mediaitem) – http8086 Nov 25 '22 at 07:37

5 Answers5

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.

Community
  • 1
  • 1
vipw
  • 7,593
  • 4
  • 25
  • 48
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.

thoma.ing
  • 71
  • 1
  • 1
  • This seems to be true for Chrome 40 on Android 4.4.4. See http://stackoverflow.com/a/28984555/202522 – joar Mar 11 '15 at 10:49
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.

Janaka
  • 307
  • 3
  • 10
  • 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. – AlikElzin-kilaka Jul 12 '12 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 Aug 01 '12 at 14:13
  • What native player? Google music? – AlikElzin-kilaka Nov 22 '12 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 Nov 26 '12 at 19:10
  • Everything is an app, whether built-in or installed. You can look at the log cat to see what it is. Thanks for the help. – AlikElzin-kilaka Nov 27 '12 at 05:58
  • 1
    I knew you would say that :) was too lazy to do that yest. – Janaka Nov 27 '12 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>
Community
  • 1
  • 1
joar
  • 15,077
  • 1
  • 29
  • 54
  • 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. – AlikElzin-kilaka Mar 26 '15 at 08:34
  • My url is https://blablamdev.testcompany.com/msng/cdcc/AppleHLS1/7eeccdce2.m3u8?media-auth=exp=162cd0cd91~acl=/mng/video 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. – charitha amarasinghe May 13 '21 at 06:38
1

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