Android HLS video mime type

浪子不回头ぞ 提交于 2019-11-30 03:52:57

问题


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


回答1:


You should put the Content-Type type specified in the RFC: application/vnd.apple.mpegurl. See section 3.1 of http://tools.ietf.org/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.




回答2:


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.




回答3:


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.




回答4:


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>


来源:https://stackoverflow.com/questions/9178321/android-hls-video-mime-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!