Added shuffle and repeating
This commit is contained in:
1 parent
53e584b528
commit
43f2634660
2 files changed
+17
-3
No files matched your search
@@ -17,7 +17,7 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const song = useSong()
|
const song = useSong()
|
||||||
const { isPlaying, play, pause, next, prev } = usePlayer()
|
const { isPlaying, play, pause, next, prev, shuffle, repeat } = usePlayer()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -38,12 +38,16 @@ const { isPlaying, play, pause, next, prev } = usePlayer()
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<Icon name="lucide:shuffle" />
|
<Icon name="lucide:shuffle" @click="shuffle()" />
|
||||||
<Icon name="lucide:skip-back" @click="prev()" />
|
<Icon name="lucide:skip-back" @click="prev()" />
|
||||||
<Icon name="lucide:pause" v-if="isPlaying" @click="pause()" />
|
<Icon name="lucide:pause" v-if="isPlaying" @click="pause()" />
|
||||||
<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 name="lucide:repeat" />
|
<Icon
|
||||||
|
name="lucide:repeat"
|
||||||
|
:class="{ repeating: repeat }"
|
||||||
|
@click="repeat = !repeat"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="misc-btns"></div>
|
<div class="misc-btns"></div>
|
||||||
</template>
|
</template>
|
||||||
@@ -113,6 +117,11 @@ const { isPlaying, play, pause, next, prev } = usePlayer()
|
|||||||
span {
|
span {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.repeating {
|
||||||
|
color: $color-accent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -146,6 +146,10 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
sound.value = null
|
sound.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const shuffle = () => {
|
||||||
|
queue.value.sort(() => Math.random() - 0.5)
|
||||||
|
}
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
const getDuration = () =>
|
const getDuration = () =>
|
||||||
new Promise<number>((resolve) => {
|
new Promise<number>((resolve) => {
|
||||||
@@ -174,6 +178,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
prev,
|
prev,
|
||||||
addToQueue,
|
addToQueue,
|
||||||
clear,
|
clear,
|
||||||
|
shuffle,
|
||||||
getDuration,
|
getDuration,
|
||||||
getSecondsPlayed,
|
getSecondsPlayed,
|
||||||
setSecondsPlayed,
|
setSecondsPlayed,
|
||||||
|
|||||||
Reference in new issue
Block a user