(spotify) play and pause when controlling

This commit is contained in:
2020-07-22 22:39:24 +02:00
parent 149d6eb2ad
commit 857d9083ca
3 changed files with 27 additions and 3 deletions

View File

@@ -23,8 +23,19 @@ export default defineComponent({
required: true
}
},
setup(props) {
const { ready, play, pause } = useSpotify()
setup(props, { emit }) {
const onPlay = () => {
if (!props.play) {
emit('play')
}
}
const onPause = () => {
if (props.play) {
emit('pause')
}
}
const { ready, play, pause } = useSpotify(onPlay, onPause)
watchEffect(() => {
props.play ? play() : pause()