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.
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.
Share Improve this question edited Jul 19, 2011 at 23:44 Crescent Fresh 117k27 gold badges157 silver badges140 bronze badges asked Jul 19, 2011 at 23:37 RupsaRupsa 1111 gold badge1 silver badge4 bronze badges 2- Hey. I had the same problem, getting the error: 'Not able to load resource' while using window.URL.createObjectURL, though I have figured it out, that local resource won't load, however, if you host this HTML page on the Internet, then it would work smoothly, without any hassle – Apoorv Saxena Commented Sep 19, 2012 at 20:13
- See stackoverflow.com/questions/24485077/… HTH – Alan Larimer Commented Jun 28, 2017 at 12:10
4 Answers
Reset to default 4I 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.
This seems to be a bug in Chromium, though the status of the bug is unclear to me: http://code.google.com/p/chromium/issues/detail?id=91136
Crossposting my comment there:
I can confirm this issue on Windows Chrome 17.0.932.0 dev-m. An easy way to confirm [the bug] is this page: http://html5-demos.appspot.com/static/a.download.html. It works when used online. After saving to disk, the download fails.
Edit: Just found this similar bug report (FileReader API not working for local content): http://code.google.com/p/chromium/issues/detail?id=60889 This is marked won't fix
for a reason that appears applicable to the bug discussed here.
I think you should use window.webkitURL.createObjectURL() as noted in https://developer.mozilla.org/en/DOM/window.URL.createObjectURL
Note: This method is prefixed in Chrome and Webkit as window.webkitURL.createObjectURL().
If you get stuck in this
video.srcObject = mediaSource;
Use teh code above. Set the srcObject to your stream.