javascriptfirefoxasp.net-web-apifirefox-addon

Cross platform Files APIs - Open and list folders


I'm going to start this mozilla student project: https://github.com/Mozilla-Student-Projects/Projects-Tracker/issues/54 I'm a little confused about the WebAPIs, because as far as I know, it's not possible to manage files with JS. Someone can point me the right direction to research and test??

I enabled the Firefox DeviceStorage, but I'm not able to getDeviceStorage, the status keeps on 'pending'.

Thx


Solution

  • If you're working on an MDN summer project, you should start here!

    https://developer.mozilla.org/en/docs/Web/API/File

    The summer school thread that you've linked to is looking for a browser app, so I think you'd use the File API to browse for MP3s - here's a fiddle showing it working with an MP3 -

    http://jsfiddle.net/derickbailey/s4P2v/

    I've patched this fiddle here:

    http://jsfiddle.net/s4P2v/129/

    with autoplay="true" so that it actually plays the MP3.

    html...
    <audio id="audio" autoplay="true"></audio>
    
    js....
    $("#audio").prop("src", objectUrl);
    

    Using the File API, you could use the info to write multiple audio tags - https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video - one per MP3 file.

    The audio tags would would then let you play the files... and you have the beginnings of an MP3 player.