loop one song option

This commit is contained in:
IrosTheBeggar 2022-04-26 21:31:35 -04:00
parent 780fbc56d8
commit 6d5fb03e3f
2 changed files with 19 additions and 8 deletions

View File

@ -612,6 +612,7 @@ const MSTREAMPLAYER = (() => {
currentTime: 0,
playing: false,
shouldLoop: false,
shouldLoopOne: false,
shuffle: false,
volume: 100,
metadata: {
@ -702,6 +703,9 @@ const MSTREAMPLAYER = (() => {
function callMeOnStreamEnd() {
mstreamModule.playerStats.playing = false;
if (mstreamModule.playerStats.shouldLoopOne === true) {
return goToSong(mstreamModule.positionCache.val);
}
// Go to next song
goToNextSong();
}
@ -770,15 +774,19 @@ const MSTREAMPLAYER = (() => {
// Loop
mstreamModule.setRepeat = (newValue) => {
if (typeof (newValue) !== "boolean") { return; }
if (mstreamModule.playerStats.autoDJ === true) { return; }
mstreamModule.playerStats.shouldLoop = newValue;
}
mstreamModule.toggleRepeat = () => {
if (mstreamModule.playerStats.autoDJ === true) { return; }
mstreamModule.playerStats.shouldLoop = !mstreamModule.playerStats.shouldLoop;
return mstreamModule.playerStats.shouldLoop;
if (mstreamModule.playerStats.shouldLoopOne === true) {
mstreamModule.playerStats.shouldLoop = false;
mstreamModule.playerStats.shouldLoopOne = false;
} else if (mstreamModule.playerStats.shouldLoop === true) {
mstreamModule.playerStats.shouldLoop = false;
mstreamModule.playerStats.shouldLoopOne = true;
} else {
mstreamModule.playerStats.shouldLoop = true;
mstreamModule.playerStats.shouldLoopOne = false;
}
}
// Random Song
@ -841,6 +849,7 @@ const MSTREAMPLAYER = (() => {
// Turn off shuffle & loop
mstreamModule.playerStats.shuffle = false;
mstreamModule.playerStats.shouldLoop = false;
mstreamModule.playerStats.shouldLoopOne = false;
// Add song if necessary
if (mstreamModule.playlist.length === 0 || mstreamModule.positionCache.val === mstreamModule.playlist.length - 1) {

View File

@ -395,7 +395,9 @@
</div>
<div class="flex">
<div v-if="altLayout.audioBookCtrls === false" class="button-block">
<svg class="pointer margin-lr" v-on:click="toggleRepeat" v-bind:class="{ 'aux-button-active': playerStats.shouldLoop }" xmlns="http://www.w3.org/2000/svg" version="1" viewBox="0 0 24 24" width="25" height="25"><path d="M17 2v3H6C4.3 5 3 6.3 3 8v6.813l2-1.626V8c0-.6.4-1 1-1h11v3l5-4-5-4zm4 7.188l-2 1.624V16c0 .6-.4 1-1 1H7v-3l-5 4 5 4v-3h11c1.7 0 3-1.3 3-3V9.187z"/></svg>
<svg v-if="playerStats.shouldLoopOne === false" class="pointer margin-lr" v-on:click="toggleRepeat" v-bind:class="{ 'aux-button-active': playerStats.shouldLoop }" xmlns="http://www.w3.org/2000/svg" version="1" viewBox="0 0 24 24" width="25" height="25"><path d="M17 2v3H6C4.3 5 3 6.3 3 8v6.813l2-1.626V8c0-.6.4-1 1-1h11v3l5-4-5-4zm4 7.188l-2 1.624V16c0 .6-.4 1-1 1H7v-3l-5 4 5 4v-3h11c1.7 0 3-1.3 3-3V9.187z"/></svg>
<svg v-else class="pointer margin-lr aux-button-active" v-on:click="toggleRepeat" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="25" height="25"><path d="M23.3 29.9V20.45H20.5V18H25.75V29.9ZM14 44 6 36 14 28 16.1 30.2 11.8 34.5H35V26.5H38V37.5H11.8L16.1 41.8ZM10 21.5V10.5H36.2L31.9 6.2L34 4L42 12L34 20L31.9 17.8L36.2 13.5H13V21.5Z"/></svg>
<svg class="pointer margin-lr" v-on:click="toggleShuffle" v-bind:class="{ 'aux-button-active': playerStats.shuffle }" xmlns="http://www.w3.org/2000/svg" version="1" viewBox="0 0 24 24" width="25" height="25"><path d="M17 2v3h-2.813c-1.1 0-2.187.588-2.687 1.688L6.594 16.5c-.1.3-.482.5-.782.5H2v2h3.813c1.1 0 2.187-.587 2.687-1.688L13.406 7.5c.1-.3.481-.5.781-.5H17v3l5-4-5-4zM2 5v2h3.813c.3 0 .675.194.875.594l1.718 3.312L9.5 8.687l-1-2C7.9 5.588 6.912 5 5.812 5H2zm9.594 8.094L10.5 15.313l1 2c.5 1 1.488 1.687 2.688 1.687H17v3l5-4-5-4v3h-2.813c-.3 0-.675-.194-.874-.594l-1.72-3.312z"/></svg>
<svg class="auto-dj" v-on:click="toggleAutoDJ" v-bind:class="{ 'aux-button-active': playerStats.autoDJ }" class="center" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid" style="width:25px;webkit-logical-width:25px;webkit-logical-height:25px;user-select:none;transform-origin:12.5px 12.5px;r:0;perspective-origin:12.5px 12.5px;overflow-y:hidden;overflow-x:hidden;inline-size:25px;height:25px;d:none;block-size:25px;background:0% 0%/auto padding-box border-box" overflow="hidden" display="block" ><g transform="translate(-.938 19.85)" style="y:0;user-select:none;transform:matrix(1,0,0,1,-.9375,19.85);perspective-origin:0 0"><g class="ld" style="y:0;x:0;user-select:none;transform-origin:7.9375px 0;transform:none;r:0;perspective-origin:0 0;line-height:31.4286px;font:400 22px/31.4286px 'Varela Round','century gothic',verdana;d:none"><text style="y:0;user-select:none;r:0;perspective-origin:7.9375px 0;line-height:31.4286px;font:400 22px/31.4286px Arial" white-space="nowrap" display="block">D</text></g></g><g transform="translate(14.938 19.85)" style="y:0;user-select:none;transform:matrix(1,0,0,1,14.9375,19.85);perspective-origin:0 0"><g class="ld" style="y:0;x:0;user-select:none;transform-origin:5.5px 0;transform:none;r:0;perspective-origin:0 0;line-height:31.4286px;font:400 22px/31.4286px 'Varela Round','century gothic',verdana;d:none"><text style="y:0;user-select:none;r:0;perspective-origin:5.5px 0;line-height:31.4286px;font:400 22px/31.4286px Arial" white-space="nowrap" display="block">J</text></g></g></svg>
</div>