Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
basically im making this site thats running LOCALLY on your computer
its a music player that you can drag mp3 files in and have them save to your device, and be able to play them with a cool UI. Its for school so thats why I want it, since all music sites are blocked.
but basically, I need to find a way to save audio files in LocalStorage unless there is another way to do it. If thats not possible is there any way to make it so that when you drag an MP3 into a specific folder it will show on the site (doubt it would work for security reasons though)

What I have tried:

ive tried localstorage and the song titles and stuff save but the audio itself doesnt
Posted
Updated 8-Feb-24 2:34am

Perhaps you're looking for the File System API?
File System API - Web APIs | MDN[^]

However, if you're loading a "loose" HTML page from disk, rather than via a web server, this probably won't work. APIs like this tend to be restricted to "secure" contexts, which means sites served over HTTPS, or sites served from "localhost". Random HTML files on disk don't qualify as "secure" for this purpose.
 
Share this answer
 
Comments
cn77 8-Feb-24 9:12am    
alright got it, but wouldnt it be possible to convert the mp3s to binary then base64 to play them? I wouldnt know how to actually put this into action though
Richard Deeming 8-Feb-24 9:40am    
MP3s, like any other file, are a sequence of bytes. The whole concept of converting it to binary makes absolutely no sense - they are already binary.
I wouldn't recommend it: LocalStorage is pretty small: 5Mb per app per browser, so you aren't going to get a lot in there.

Download to the client and let them store it locally, or stream it from your server.

And bypassing school restrictions isn't a brilliant idea if you think about it: if they put such restrictions in, they are going to check you adhere to them ...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900