In Firefox
, I'm trying to load an audio file from the user's file system.
I've read that I can create a File
object based on a path here
The code will be run inside a firefox addon, so have access to privilaged code.
Any ideas why this is causing an error in console and for the document.getElementById('player')
element to vanish?
http://jsfiddle.net/bobbyrne01/sp5qr7hh/
^ fiddle is just for demonstration purposes, it will ultimately be run inside a firefox addon.
html
..
<audio id="player" preload="auto" controls></audio>
js
..
var reader = new FileReader();
reader.onload = function(d) {
console.log(d.target.result);
document.getElementById('player').src = d.target.result;
};
reader.readAsDataURL(new File([""], "file:///home/rob/audio.mp3"));
console output ..
"data:application/octet-stream;base64," _display:24
HTTP "Content-Type" of "application/octet-stream" is not supported. Load of media resource data:application/octet-stream;base64, failed.
filesystem
..
rob@work:~$ pwd
/home/rob
rob@work:~$ ls audio.mp3
audio.mp3