1

I am working on a media player, and I want to be able to queue local files in an array, play it, and even export it as a playlist (for later import).

I found this question, with a lot of helpful information: Using local file for Web Audio API in Javascript However, the Base64 method would make the playlist too big, and the other solution creates a sandboxed file link (which are deleted from the browser when the session is closed).

Is there any good way to do this?

EDIT: Here's an example of what I want:

var playlist = {'file:///home/user/music/track1.mp3','file:///home/user/music/track2.mp3','file:///home/user/music/track3.mp3'};

It doesn't have to look like this, i just want something similar.

2
  • You want the files to be saved somewhere ,even when the session is closed? Commented Feb 21, 2014 at 10:55
  • @NevinMadhukarK I want to reference files on the user's harddisk, so he can make a playlist and load it up again later. Commented Feb 21, 2014 at 10:56

1 Answer 1

0

Why not try localstorage feature on html5. Its helps store data even after the session is expired.

http://www.w3schools.com/html/html5_webstorage.asp

http://diveintohtml5.info/storage.html

What i did in my music player,was store the file data path in the localstorage. And whenever i needed it ,i retrieved it and replaced the current song with the one i wanted.

// Store localStorage.setItem("Path","file:///home/user/music/track1.mp3'");

//Retrieve
currentSong=localStorage.getItem('Path');

For multiple songs,u could create objects and do similar to this: Storing Objects in HTML5 localStorage

Sign up to request clarification or add additional context in comments.

7 Comments

Will test this out when I get home! Can i export the full localStorage to a file? I could use this to store the whole playlist.
You can transfer the entire object file stored in localStorage as JSON format into a file. Do check the last link i provided. That helped me do my project. :) And do accept my answer if it helped you out. :)
I tried your method ( jsfiddle.net/Tv8Cm/56 ), but I get error "Not allowed to load local resource: file:///file.mp3" When trying to load the file. Is there issues with my code?
I think you should check this : stackoverflow.com/questions/10813408/html5-video-not-playing Am 100% sure,the methode i told will work. Just google when u have future doubts. Its all there.
Hi there, can you provide working fiddle or link to your player? As i am pretty sure that you can not really reuse saved file path
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.