add play next
This commit is contained in:
parent
ccad88da64
commit
b949db6efd
@ -3,6 +3,9 @@
|
|||||||
<template #button-content>
|
<template #button-content>
|
||||||
<Icon icon="three-dots-vertical"/>
|
<Icon icon="three-dots-vertical"/>
|
||||||
</template>
|
</template>
|
||||||
|
<b-dropdown-item-button @click="playNext()">
|
||||||
|
Play next
|
||||||
|
</b-dropdown-item-button>
|
||||||
<b-dropdown-item-button @click="toggleStarred()">
|
<b-dropdown-item-button @click="toggleStarred()">
|
||||||
{{ starred ? 'Unstar' : 'Star' }}
|
{{ starred ? 'Unstar' : 'Star' }}
|
||||||
</b-dropdown-item-button>
|
</b-dropdown-item-button>
|
||||||
@ -30,6 +33,9 @@
|
|||||||
}
|
}
|
||||||
this.starred = !this.starred;
|
this.starred = !this.starred;
|
||||||
},
|
},
|
||||||
|
playNext() {
|
||||||
|
return this.$store.dispatch("player/playNext", this.track);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
<!-- Controls--->
|
<!-- Controls--->
|
||||||
<div class="col-auto p-0">
|
<div class="col-auto p-0">
|
||||||
<b-button variant="link" class="m-2" @click="playPrevious">
|
<b-button variant="link" class="m-2" @click="previous">
|
||||||
<Icon icon="skip-start-fill"/>
|
<Icon icon="skip-start-fill"/>
|
||||||
</b-button>
|
</b-button>
|
||||||
<b-button variant="link" size="lg" class="m-2" @click="playPause">
|
<b-button variant="link" size="lg" class="m-2" @click="playPause">
|
||||||
<Icon :icon="isPlaying ? 'pause-fill' : 'play-fill'"/>
|
<Icon :icon="isPlaying ? 'pause-fill' : 'play-fill'"/>
|
||||||
</b-button>
|
</b-button>
|
||||||
<b-button variant="link" class="m-2" @click="playNext">
|
<b-button variant="link" class="m-2" @click="next">
|
||||||
<Icon icon="skip-end-fill"/>
|
<Icon icon="skip-end-fill"/>
|
||||||
</b-button>
|
</b-button>
|
||||||
</div>
|
</div>
|
||||||
@ -73,8 +73,8 @@ export default Vue.extend({
|
|||||||
methods: {
|
methods: {
|
||||||
...mapActions("player", [
|
...mapActions("player", [
|
||||||
"playPause",
|
"playPause",
|
||||||
"playNext",
|
"next",
|
||||||
"playPrevious",
|
"previous",
|
||||||
]),
|
]),
|
||||||
seek(event: any) {
|
seek(event: any) {
|
||||||
if (event.target) {
|
if (event.target) {
|
||||||
|
@ -72,6 +72,9 @@ export const playerModule: Module<State, any> = {
|
|||||||
state.queueIndex--;
|
state.queueIndex--;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setNextInQueue(state, track) {
|
||||||
|
state.queue.splice(state.queueIndex + 1, 0, track);
|
||||||
|
},
|
||||||
setProgress(state, value: any) {
|
setProgress(state, value: any) {
|
||||||
state.currentTime = value;
|
state.currentTime = value;
|
||||||
},
|
},
|
||||||
@ -95,12 +98,12 @@ export const playerModule: Module<State, any> = {
|
|||||||
audio.pause();
|
audio.pause();
|
||||||
commit("setPaused");
|
commit("setPaused");
|
||||||
},
|
},
|
||||||
async playNext({ commit, state }) {
|
async next({ commit, state }) {
|
||||||
commit("setQueueIndex", state.queueIndex + 1);
|
commit("setQueueIndex", state.queueIndex + 1);
|
||||||
commit("setPlaying");
|
commit("setPlaying");
|
||||||
await audio.play();
|
await audio.play();
|
||||||
},
|
},
|
||||||
async playPrevious({ commit, state }) {
|
async previous({ commit, state }) {
|
||||||
commit("setQueueIndex", state.queueIndex - 1);
|
commit("setQueueIndex", state.queueIndex - 1);
|
||||||
commit("setPlaying");
|
commit("setPlaying");
|
||||||
await audio.play();
|
await audio.play();
|
||||||
@ -114,6 +117,9 @@ export const playerModule: Module<State, any> = {
|
|||||||
seek({ commit, state }, value) {
|
seek({ commit, state }, value) {
|
||||||
commit("setPosition", state.duration * value);
|
commit("setPosition", state.duration * value);
|
||||||
},
|
},
|
||||||
|
playNext({ commit }, track) {
|
||||||
|
commit("setNextInQueue", track);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
@ -150,7 +156,7 @@ export function setupAudio(store: Store<any>) {
|
|||||||
store.commit("player/setDuration", audio.duration);
|
store.commit("player/setDuration", audio.duration);
|
||||||
}
|
}
|
||||||
audio.onended = (event) => {
|
audio.onended = (event) => {
|
||||||
store.dispatch("player/playNext");
|
store.dispatch("player/next");
|
||||||
}
|
}
|
||||||
audio.onerror = (event) => {
|
audio.onerror = (event) => {
|
||||||
store.commit("player/setPaused");
|
store.commit("player/setPaused");
|
||||||
@ -168,10 +174,10 @@ export function setupAudio(store: Store<any>) {
|
|||||||
store.dispatch("player/pause");
|
store.dispatch("player/pause");
|
||||||
});
|
});
|
||||||
mediaSession.setActionHandler('nexttrack', () => {
|
mediaSession.setActionHandler('nexttrack', () => {
|
||||||
store.dispatch("player/playNext");
|
store.dispatch("player/next");
|
||||||
});
|
});
|
||||||
mediaSession.setActionHandler('previoustrack', () => {
|
mediaSession.setActionHandler('previoustrack', () => {
|
||||||
store.dispatch("player/playPrevious");
|
store.dispatch("player/previous");
|
||||||
});
|
});
|
||||||
mediaSession.setActionHandler('stop', () => {
|
mediaSession.setActionHandler('stop', () => {
|
||||||
store.dispatch("player/pause");
|
store.dispatch("player/pause");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user