YwYMusic/src/stores/player.ts

23 lines
531 B
TypeScript

import { defineStore } from "pinia"
import type { Song } from "@/mocks/music"
export const usePlayerStore = defineStore("player", {
state: () => ({
current: null as Song | null,
queue: [] as Song[],
isPlaying: false,
currentTime: 0,
volume: 70,
src: "",
}),
actions: {
playSong(song: Song, queue?: Song[], src = "") {
this.current = song
this.currentTime = 0
this.src = src
if (queue && queue.length > 0) this.queue = [...queue]
this.isPlaying = true
},
},
})