admin管理员组

文章数量:1025270

Is it possible to play video by somehow passing data from a File object into a <video> tag?

I know you can base64 encode things to put include the data in the DOM, but I understand there are size limits on this, so can anyone think of another way, or a workaround for this?

For now it's just a bit of an experiment, so lets not worry too much about video file formats... just assume that the format works with the browser you're using.

Is it possible to play video by somehow passing data from a File object into a <video> tag?

I know you can base64 encode things to put include the data in the DOM, but I understand there are size limits on this, so can anyone think of another way, or a workaround for this?

For now it's just a bit of an experiment, so lets not worry too much about video file formats... just assume that the format works with the browser you're using.

Share Improve this question asked Mar 21, 2012 at 10:14 NathanNathan 11.2k4 gold badges40 silver badges50 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

URL.createObjectURL will create urls that link to the files, otherwise you will just crash your browser.

var URL = window.URL || window.webkitURL;
var src = URL.createObjectURL( file );

videoElem.src = src;

The urls will use blob scheme, example:

"blob:http%3A%2F%2Fstackoverflow./c04ac1f0-cd88-4587-9905-741b90c62684"

Is it possible to play video by somehow passing data from a File object into a <video> tag?

I know you can base64 encode things to put include the data in the DOM, but I understand there are size limits on this, so can anyone think of another way, or a workaround for this?

For now it's just a bit of an experiment, so lets not worry too much about video file formats... just assume that the format works with the browser you're using.

Is it possible to play video by somehow passing data from a File object into a <video> tag?

I know you can base64 encode things to put include the data in the DOM, but I understand there are size limits on this, so can anyone think of another way, or a workaround for this?

For now it's just a bit of an experiment, so lets not worry too much about video file formats... just assume that the format works with the browser you're using.

Share Improve this question asked Mar 21, 2012 at 10:14 NathanNathan 11.2k4 gold badges40 silver badges50 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

URL.createObjectURL will create urls that link to the files, otherwise you will just crash your browser.

var URL = window.URL || window.webkitURL;
var src = URL.createObjectURL( file );

videoElem.src = src;

The urls will use blob scheme, example:

"blob:http%3A%2F%2Fstackoverflow./c04ac1f0-cd88-4587-9905-741b90c62684"

本文标签: javascriptplay video from data in File objectStack Overflow