|
@@ -820,6 +820,7 @@ import Toast from "toasters";
|
|
|
import { ContentLoader } from "vue-content-loader";
|
|
|
|
|
|
import aw from "@/aw";
|
|
|
+import ms from "@/ms";
|
|
|
import ws from "@/ws";
|
|
|
import keyboardShortcuts from "@/keyboardShortcuts";
|
|
|
|
|
@@ -1053,6 +1054,21 @@ export default {
|
|
|
}
|
|
|
);
|
|
|
|
|
|
+ ms.setListeners(0, {
|
|
|
+ play: () => {
|
|
|
+ if (this.isOwnerOrAdmin()) this.resumeStation();
|
|
|
+ else this.resumeLocalStation();
|
|
|
+ },
|
|
|
+ pause: () => {
|
|
|
+ if (this.isOwnerOrAdmin()) this.pauseStation();
|
|
|
+ else this.pauseLocalStation();
|
|
|
+ },
|
|
|
+ nexttrack: () => {
|
|
|
+ if (this.isOwnerOrAdmin()) this.skipStation();
|
|
|
+ else this.voteSkipStation();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
this.socket.on("event:station.nextSong", res => {
|
|
|
const { currentSong, startedAt, paused, timePaused } = res.data;
|
|
|
|
|
@@ -1249,6 +1265,9 @@ export default {
|
|
|
beforeUnmount() {
|
|
|
document.body.style.cssText = "";
|
|
|
|
|
|
+ ms.removeListeners(0);
|
|
|
+ ms.removeMediaSessionData(0);
|
|
|
+
|
|
|
/** Reset Songslist */
|
|
|
this.updateSongsList([]);
|
|
|
|
|
@@ -1289,6 +1308,18 @@ export default {
|
|
|
isOwnerOrAdmin() {
|
|
|
return this.isOwnerOnly() || this.isAdminOnly();
|
|
|
},
|
|
|
+ updateMediaSessionData(currentSong) {
|
|
|
+ if (currentSong) {
|
|
|
+ ms.setMediaSessionData(
|
|
|
+ 0,
|
|
|
+ !this.localPaused && !this.stationPaused, // This should be improved later
|
|
|
+ this.currentSong.title,
|
|
|
+ this.currentSong.artists.join(", "),
|
|
|
+ null,
|
|
|
+ this.currentSong.thumbnail
|
|
|
+ );
|
|
|
+ } else ms.removeMediaSessionData(0);
|
|
|
+ },
|
|
|
removeFromQueue(youtubeId) {
|
|
|
window.socket.dispatch(
|
|
|
"stations.removeFromQueue",
|
|
@@ -1363,6 +1394,8 @@ export default {
|
|
|
|
|
|
clearTimeout(window.stationNextSongTimeout);
|
|
|
|
|
|
+ this.updateMediaSessionData(currentSong);
|
|
|
+
|
|
|
this.startedAt = startedAt;
|
|
|
this.updateStationPaused(paused);
|
|
|
this.timePaused = timePaused;
|
|
@@ -1475,6 +1508,7 @@ export default {
|
|
|
},
|
|
|
youtubeReady() {
|
|
|
if (!this.player) {
|
|
|
+ ms.setYTReady(false);
|
|
|
this.player = new window.YT.Player("stationPlayer", {
|
|
|
height: 270,
|
|
|
width: 480,
|
|
@@ -1494,6 +1528,7 @@ export default {
|
|
|
events: {
|
|
|
onReady: () => {
|
|
|
this.playerReady = true;
|
|
|
+ ms.setYTReady(true);
|
|
|
|
|
|
let volume = parseInt(
|
|
|
localStorage.getItem("volume")
|
|
@@ -1784,6 +1819,7 @@ export default {
|
|
|
this.pauseLocalPlayer();
|
|
|
},
|
|
|
resumeLocalPlayer() {
|
|
|
+ this.updateMediaSessionData(this.currentSong);
|
|
|
if (!this.noSong) {
|
|
|
if (this.playerReady) {
|
|
|
this.player.seekTo(
|
|
@@ -1795,6 +1831,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
pauseLocalPlayer() {
|
|
|
+ this.updateMediaSessionData(this.currentSong);
|
|
|
if (!this.noSong) {
|
|
|
this.timeBeforePause = this.getTimeElapsed();
|
|
|
if (this.playerReady) this.player.pauseVideo();
|