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.
Deprecation of createObjectURL and replace with the new HTMLMediaElement.
The URL.createObjectURL() static method creates a string containing a URL representing the object given in the parameter. The URL lifetime is tied to the document in the window on which it was created. The new object URL represents the specified File object or Blob object.
Blob URL/Object URL is a pseudo protocol to allow Blob and File objects to be used as URL source for things like images, download links for binary data and so forth. For example, you can not hand an Image object raw byte-data as it would not know what to do with it.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With