diff options
author | Indrajith K L | 2022-12-05 03:43:35 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-05 03:43:35 +0530 |
commit | b9a255e13acab4b182f9499a6d943385349cd85b (patch) | |
tree | 32a4fe62b8862286a49e6ac5d61e9780edc4e0cb | |
parent | af7303fc62a7a3cb1c660bca51d4acbc27eaab22 (diff) | |
download | retrowave-player-b9a255e13acab4b182f9499a6d943385349cd85b.tar.gz retrowave-player-b9a255e13acab4b182f9499a6d943385349cd85b.tar.bz2 retrowave-player-b9a255e13acab4b182f9499a6d943385349cd85b.zip |
Adds Playlist Download
* Removed unusable history.json
* Adds legit m3u playlist download so that users can load it
into mpd or other music players
-rw-r--r-- | player.js | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -200,12 +200,21 @@ function downloadHistory() { const historyArray = getHistory(); let element = document.createElement("a"); + let playListData = '#EXTM3U'; + historyArray.forEach((musicData) => { + playListData = `${playListData} + +#EXTINF:${(musicData.duration/60000).toFixed(2)}, ${musicData.title} +https://retrowave.ru/${musicData.streamUrl} +`; + }); + element.setAttribute( "href", - "data:application/json;charset=utf-8," + - encodeURIComponent(JSON.stringify(historyArray)) + "data:audio/x-mpegurl;;charset=utf-8," + + encodeURIComponent(playListData) ); - element.setAttribute("download", "history.json"); + element.setAttribute("download", "retrowave_playlist.m3u"); element.style.display = "none"; document.body.appendChild(element); |