问题描述
尝试使用createObjectDataURL更改视频源文件。它适用于Firefox,但不适用于Chrome(版本12.0.742.122 m)。代码不会抛出任何错误,但会为createObjectDataURL返回undefined。我尝试了所有的可能性,但它总是返回undefined。
Trying to change video source file using createObjectDataURL. It is working fine with Firefox but not working in Chrome (version 12.0.742.122 m). code is not throwing any error but returns undefined for createObjectDataURL. I tried all the possibilities but it always returns undefined.
<!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>
请帮帮我。它已经花了很多时间。
先谢谢。
Please help me. It has already taken lot of time.Thanks in Advance.
推荐答案
当我打开本地文件作为本地文件时,我遇到了同样的问题铬。我不得不使用Apache并通过localhost打开它。
I had the same problem, when I was opening the page as a local file in Chrome. I had to use Apache and open it through localhost.
这篇关于createObjectURL在Chrome中返回undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!