We're creating a chrome extension to download videos, currently I have this function :
function downloadvideo(video)
{
const url = URL.createObjectURL(video.captureStream());
const aelem = document.createElement('a');
document.body.appendChild(aelem);
aelem.setAttribute("href",url);
aelem.setAttribute("download","video.mp4");
aelem.click();
//URL.revokeObjectURL(url);
}
Here video parameter is a html5 video element, I'm using caputreStream because some websites(notably youtube) uses blob url which are revoked apparently So I create a new Blob url from MediaStream.
The function above is executed as part of video's onloadeddata event.
The dialog is shown and the filename is correct but when I click "Save" chrome says "failed : could not find the file".
So how to make it actually work ?
By the way I tried to do ajax against url but chrome refuses with the message : "Cross-origin is only supported for schemes http,https,chrome,chrome-extension" :3 .