javascript - play video from data in File object - Stack Overflow

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

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"

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745614393a4636143.html

相关推荐

  • javascript - play video from data in File object - Stack Overflow

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

    10小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信