Skip to content

Commit

Permalink
live playlist mode
Browse files Browse the repository at this point in the history
  • Loading branch information
IrosTheBeggar committed Feb 7, 2024
1 parent b66c6d5 commit c686ace
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 46 deletions.
59 changes: 32 additions & 27 deletions webapp/alpha/m.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ async function init() {
document.getElementById('set_live_playlist').classList.remove('green');
document.getElementById('set_live_playlist').classList.add('blue');
document.getElementById('set_live_playlist').value = 'Disable Live Playlist';
document.getElementById('live-playlist-hide-these').hidden = true;
}

}catch(err) {}
Expand Down Expand Up @@ -868,6 +869,16 @@ async function setLivePlaylist() {
try{
document.getElementById('set_live_playlist').disabled = true;

if (VUEPLAYERCORE.livePlaylist.name !== false) {
VUEPLAYERCORE.livePlaylist.name = false;
document.getElementById('set_live_playlist').classList.remove('blue');
document.getElementById('set_live_playlist').classList.add('green');
document.getElementById('set_live_playlist').value = 'Enable Live Playlist';
document.getElementById('live-playlist-hide-these').hidden = false;
myModal.close();
return;
}

let livePlaylistName;

if (document.getElementById('radio-use-existing').checked === true) {
Expand All @@ -893,38 +904,32 @@ async function setLivePlaylist() {
localStorage.removeItem('live-playlist-auto-start');
}

if (VUEPLAYERCORE.livePlaylist.name !== false) {
VUEPLAYERCORE.livePlaylist.name = false;
document.getElementById('set_live_playlist').classList.remove('blue');
document.getElementById('set_live_playlist').classList.add('green');
document.getElementById('set_live_playlist').value = 'Enable Live Playlist';
} else {
// set live var
VUEPLAYERCORE.livePlaylist.name = livePlaylistName;
// set live var
VUEPLAYERCORE.livePlaylist.name = livePlaylistName;

// get current playlist
const response = await MSTREAMAPI.loadPlaylist(VUEPLAYERCORE.livePlaylist.name);
// get current playlist
const response = await MSTREAMAPI.loadPlaylist(VUEPLAYERCORE.livePlaylist.name);

// set the queue to the current playlist
if (response.length > 0) {
MSTREAMPLAYER.clearPlaylist();
response.forEach(value => {
VUEPLAYERCORE.addSongWizard(value.filepath, value.metadata, false, undefined, false, true);
});
} else {
// save current queue
const songs = [];
for (let i = 0; i < MSTREAMPLAYER.playlist.length; i++) {
songs.push(MSTREAMPLAYER.playlist[i].filepath);
}
MSTREAMAPI.savePlaylist(livePlaylistName, songs, true);
// set the queue to the current playlist
if (response.length > 0) {
MSTREAMPLAYER.clearPlaylist();
response.forEach(value => {
VUEPLAYERCORE.addSongWizard(value.filepath, value.metadata, false, undefined, false, true);
});
} else {
// save current queue
const songs = [];
for (let i = 0; i < MSTREAMPLAYER.playlist.length; i++) {
songs.push(MSTREAMPLAYER.playlist[i].filepath);
}

document.getElementById('set_live_playlist').classList.remove('green');
document.getElementById('set_live_playlist').classList.add('blue');
document.getElementById('set_live_playlist').value = 'Disable Live Playlist';
MSTREAMAPI.savePlaylist(livePlaylistName, songs, true);
}

document.getElementById('set_live_playlist').classList.remove('green');
document.getElementById('set_live_playlist').classList.add('blue');
document.getElementById('set_live_playlist').value = 'Disable Live Playlist';
document.getElementById('live-playlist-hide-these').hidden = true;

// close modal
myModal.close();
} catch(err) {
Expand Down
41 changes: 22 additions & 19 deletions webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,26 +171,29 @@ <h5>Live Playlist Mode</h5>
</label>
<br>

<p>
<label>
<input class="with-gap" name="group1" type="radio" checked />
<span>Make a new playlist</span>
</label>
<input id="new-live-playlist-name" type="text" name="live-queue-name" placeholder="Playlist Name" autocomplete="off" class="make-white">
</p>
<div id="live-playlist-hide-these">
<p>
<label>
<input class="with-gap" name="group1" type="radio" checked />
<span>Make a new playlist</span>
</label>
<input id="new-live-playlist-name" type="text" name="live-queue-name" placeholder="Playlist Name" autocomplete="off" class="make-white">
</p>

<p>
<label>
<input class="with-gap" name="group1" type="radio" id="radio-use-existing" />
<span>Use an existing playlist</span>
</label>
</p>
<p>
<select id="live-playlist-select" class="browser-default">
<option value="" disabled selected>Select Playlist</option>
</select>
<!-- <label>Materialize Select</label> -->
</p>
</div>

<p>
<label>
<input class="with-gap" name="group1" type="radio" id="radio-use-existing" />
<span>Use an existing playlist</span>
</label>
</p>
<p>
<select id="live-playlist-select" class="browser-default">
<option value="" disabled selected>Select Playlist</option>
</select>
<!-- <label>Materialize Select</label> -->
</p>

<input id="set_live_playlist" type="submit" class="btn green" value="Enable Live Playlist">
</form>
Expand Down

0 comments on commit c686ace

Please sign in to comment.