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 badges1 Answer
Reset to default 6URL.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 badges1 Answer
Reset to default 6URL.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
版权声明:本文标题:javascript - play video from data in File object - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745614392a2159198.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论