【发布时间】:2011-10-08 23:35:53
【问题描述】:
尝试使用 createObjectDataURL 更改视频源文件。它在 Firefox 中运行良好,但在 Chrome(版本 12.0.742.122 m)中无法运行。代码不会引发任何错误,但会为 createObjectDataURL 返回未定义。我尝试了所有的可能性,但它总是返回未定义。
<!DOCTYPE html>
<html>
<head>
<title>Check CreateObjectURL</title>
</head>
<script type="text/javascript" language="javascript">
window.URL = window.URL || window.webkitURL;
function ChangeProperty()
{
var v = document.getElementById("myvideo");
var file = document.getElementById("fileControl").files[0];
v.setAttribute("src",window.URL.createObjectURL(file));
}
</script>
<body>
<div >
<video id="myvideo" src="movie.ogg" controls ></video>
<input type="file" id="fileControl" />
<button id="btnprops" onClick="ChangeProperty()" >update</button>
</div>
</body>
</html>
请帮助我。它已经花费了很多时间。 提前致谢。
【问题讨论】:
-
嘿。我遇到了同样的问题,在使用 window.URL.createObjectURL 时出现错误:“无法加载资源”,尽管我已经弄清楚了,但是,如果您在互联网,那么它就会顺利运行,没有任何麻烦
标签: javascript file video upload