Added repeat modes
This commit is contained in:
1 parent
b483ad84e4
commit
4ab58c8400
3 files changed
+36
-7
No files matched your search
@@ -12,6 +12,8 @@ const {
|
|||||||
prev,
|
prev,
|
||||||
shuffle,
|
shuffle,
|
||||||
repeat,
|
repeat,
|
||||||
|
repeatOnce,
|
||||||
|
cycleRepeat,
|
||||||
secondsPlayed,
|
secondsPlayed,
|
||||||
duration,
|
duration,
|
||||||
volume,
|
volume,
|
||||||
@@ -64,9 +66,9 @@ const durationFormatted = computed(() =>
|
|||||||
<Icon name="lucide:play" v-else @click="play()" />
|
<Icon name="lucide:play" v-else @click="play()" />
|
||||||
<Icon name="lucide:skip-forward" @click="next()" />
|
<Icon name="lucide:skip-forward" @click="next()" />
|
||||||
<Icon
|
<Icon
|
||||||
name="lucide:repeat"
|
:name="repeatOnce ? 'lucide:repeat-1' : 'lucide:repeat'"
|
||||||
:class="{ repeating: repeat }"
|
:class="{ repeating: repeat || repeatOnce }"
|
||||||
@click="repeat = !repeat"
|
@click="cycleRepeat()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ const {
|
|||||||
prev,
|
prev,
|
||||||
shuffle,
|
shuffle,
|
||||||
repeat,
|
repeat,
|
||||||
|
repeatOnce,
|
||||||
|
cycleRepeat,
|
||||||
secondsPlayed,
|
secondsPlayed,
|
||||||
duration,
|
duration,
|
||||||
volume,
|
volume,
|
||||||
@@ -47,6 +49,7 @@ const queueOpen = ref(false)
|
|||||||
<template>
|
<template>
|
||||||
<div id="width-fixer" ref="width-fixer-ref"></div>
|
<div id="width-fixer" ref="width-fixer-ref"></div>
|
||||||
<article class="player" ref="player-ref" :class="{ active: song }">
|
<article class="player" ref="player-ref" :class="{ active: song }">
|
||||||
|
<Icon name="lucide:repeat-1" class="icon-preload" aria-hidden="true" />
|
||||||
<template v-if="song">
|
<template v-if="song">
|
||||||
<div class="track">
|
<div class="track">
|
||||||
<NuxtImg
|
<NuxtImg
|
||||||
@@ -73,9 +76,9 @@ const queueOpen = ref(false)
|
|||||||
<Icon name="lucide:play" v-else @click="play()" />
|
<Icon name="lucide:play" v-else @click="play()" />
|
||||||
<Icon name="lucide:skip-forward" @click="next()" />
|
<Icon name="lucide:skip-forward" @click="next()" />
|
||||||
<Icon
|
<Icon
|
||||||
name="lucide:repeat"
|
:name="repeatOnce ? 'lucide:repeat-1' : 'lucide:repeat'"
|
||||||
:class="{ repeating: repeat }"
|
:class="{ repeating: repeat || repeatOnce }"
|
||||||
@click="repeat = !repeat"
|
@click="cycleRepeat()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="slider">
|
<div class="slider">
|
||||||
@@ -121,6 +124,10 @@ const queueOpen = ref(false)
|
|||||||
@use "@/styles/variables" as *;
|
@use "@/styles/variables" as *;
|
||||||
@use "@/styles/util" as *;
|
@use "@/styles/util" as *;
|
||||||
|
|
||||||
|
.icon-preload {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
#width-fixer {
|
#width-fixer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-1
@@ -29,6 +29,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
const currentQueue = ref<Track[]>([])
|
const currentQueue = ref<Track[]>([])
|
||||||
const currentSong = ref<Track | null>(null)
|
const currentSong = ref<Track | null>(null)
|
||||||
const repeat = ref(false)
|
const repeat = ref(false)
|
||||||
|
const repeatOnce = ref(false)
|
||||||
const isPlaying = ref(false)
|
const isPlaying = ref(false)
|
||||||
const beatEnergy = ref(0)
|
const beatEnergy = ref(0)
|
||||||
const storedVolume = ref(DEFAULT_VOLUME)
|
const storedVolume = ref(DEFAULT_VOLUME)
|
||||||
@@ -369,7 +370,13 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
onend: () => {
|
onend: () => {
|
||||||
stopBeatAnalysis("track ended")
|
stopBeatAnalysis("track ended")
|
||||||
void closeFullscreen()
|
void closeFullscreen()
|
||||||
next()
|
if (repeatOnce.value && sound.value === newSound) {
|
||||||
|
repeatOnce.value = false
|
||||||
|
newSound.seek(0)
|
||||||
|
newSound.play()
|
||||||
|
} else {
|
||||||
|
void next()
|
||||||
|
}
|
||||||
stopTracking()
|
stopTracking()
|
||||||
},
|
},
|
||||||
onstop: () => {
|
onstop: () => {
|
||||||
@@ -421,6 +428,17 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
updateMediaSession()
|
updateMediaSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cycleRepeat = () => {
|
||||||
|
if (repeatOnce.value) {
|
||||||
|
repeatOnce.value = false
|
||||||
|
repeat.value = true
|
||||||
|
} else if (repeat.value) {
|
||||||
|
repeat.value = false
|
||||||
|
} else {
|
||||||
|
repeatOnce.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const next = async (autoplay: boolean = true) => {
|
const next = async (autoplay: boolean = true) => {
|
||||||
if (currentSong.value) {
|
if (currentSong.value) {
|
||||||
prevQueue.value.unshift(currentSong.value)
|
prevQueue.value.unshift(currentSong.value)
|
||||||
@@ -571,6 +589,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
beatEnergy,
|
beatEnergy,
|
||||||
currentSong,
|
currentSong,
|
||||||
repeat,
|
repeat,
|
||||||
|
repeatOnce,
|
||||||
|
cycleRepeat,
|
||||||
play,
|
play,
|
||||||
pause,
|
pause,
|
||||||
next,
|
next,
|
||||||
|
|||||||
Reference in new issue
Block a user