I am trying to implement dynamic loading for an html5 tag.
when the user selects a video file through the <input type="file"> element, I want to dynamically load it into the <video> element and add it to the body.
The following code works in Chrome, but not in Safari:
function load_video(file) { // this came from <input type="file"> change event var reader = new FileReader(); reader.onload = function(event) { var blob = new Blob([event.target.result]); window.URL = window.URL || window.webkitURL; var blobURL = window.URL.createObjectURL(blob); $('body').append('<video controls width="320" src="' + blobURL + '" onloadedmetadata="alert('loaded meta data!')"></video>'); } }
currently, if I replaced src="' + blobURL + '" with a local file path, say /media/videos/vid1.mp4 , loading the video in Safari too, but I need to download the video from blobURL .
any suggestions?
Thank you very much.
UPDATE:
as Rod says, unfortunately, this is a known bug in Safari (not supported by its backend).
javascript html5-video blob
geevee Sep 30 '13 at 7:12 2013-09-30 07:12
source share