Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 ObjectURL support for html5 video

I need a way of playing hls m3u8 playlists that are created in the clients webbrowser and not using and external file.

I am currently generating a string and creating a file that is later linked using Object URLs.

const playlistFile = new File([playlistString], playlistName, { type: 'application/x-mpegURL' });  
const playlistURL = URL.createObjectURL(playlistFile);  

This URL is then used as the source in the video element.

<video playsinline="" controls="" src="blob:http://localhost:8080/b9a0b81f-d469-4004-9f6b-a577325e2cf3"></video>  

This system works fine in all iOS 10 version and on OSX, but as soon as I run it on a device running any iOS 11 version I get an error code 4 "MEDIA_ERR_SRC_NOT_SUPPORTED" from the video element.

I'm not able to find any path notes saying anything that may indicate a change to why this does not work in iOS 11. Is there any other way to solve this problem that works in bith iOS 10 and 11?

Any help or insight into this problem would be appriciated.

Edit: I created a jsfiddle to help understand the problem. https://jsfiddle.net/x2oa8nh2/8/

The upper video works on iOS 10 and 11 (And OSX Safari). The bottom one does not work on iOS 11.

like image 777
user2319925 Avatar asked Dec 04 '17 16:12

user2319925


People also ask

Why doesn’t HTML5 work on iOS devices?

The problem is that iOS devices DO NOT support this attribute. It’s actually less of a support issue but more of Apple intentionally choosing not to recognize the attribute at all. In other words, I’m suggesting your HTML5 might be working justing fine and you just don’t know it.

How do I Make my HTML5 video autoplay on iOS?

To make your HTML5 Video autoplay onload you can add the autoplay attribute to the video tag. … The problem is that iOS devices DO NOT support this attribute. It’s actually less of a support issue but more of Apple intentionally choosing not to recognize the attribute at all.

What is HTML5 video and how to use it?

It’s called HTML5 and more specifically for this post – HTML5 Video. For maximum browser support, use three types of video. Add them as <source> tags, wrap them all up in a video tag and you’re off and running. In its simplest form, a HTML5 video is implemented like so:

Which mobile browsers support HTML5?

Mobile HTML5 compatibility on iPhone, Android, Windows Phone, BlackBerry, Firefox OS and other mobile devices HTML5 compatibility on mobile and tablet browsers with testing on real devices Feature Safari iOS Android Browser Samsung Internet Google Chrome Amazon Silk BlackBerry Browser Nokia Browser Internet Explorer Opera Mobile Opera mini


1 Answers

Perhaps a touch hacky, but if you use base64 data URIs, it will resolve this issue. In my use-case, I was working with an HLS M3U8 playlist, so the MIME type has been tweaked accordingly:

const m3u8 = "[M3U8 string data]";
const hlsMimeType = "application/vnd.apple.mpegurl";

nativeVideo.type = hlsMimeType;
nativeVideo.src = `data:${hlsMimeType};base64,${btoa(m3u8)}`;

Looks like it will work in practice on anything that supports HTML5 video.

like image 76
Chris Calo Avatar answered Oct 19 '22 12:10

Chris Calo