|
@@ -601,13 +601,13 @@ export default {
|
|
if (this.socket.connected) this.join();
|
|
if (this.socket.connected) this.join();
|
|
io.onConnect(this.join);
|
|
io.onConnect(this.join);
|
|
|
|
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"stations.existsByName",
|
|
"stations.existsByName",
|
|
this.stationIdentifier,
|
|
this.stationIdentifier,
|
|
res => {
|
|
res => {
|
|
if (res.status === "failure" || !res.exists) {
|
|
if (res.status === "failure" || !res.exists) {
|
|
// station identifier may be using stationid instead
|
|
// station identifier may be using stationid instead
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"stations.existsById",
|
|
"stations.existsById",
|
|
this.stationIdentifier,
|
|
this.stationIdentifier,
|
|
res => {
|
|
res => {
|
|
@@ -650,7 +650,7 @@ export default {
|
|
if (!this.playerReady) this.youtubeReady();
|
|
if (!this.playerReady) this.youtubeReady();
|
|
else this.playVideo();
|
|
else this.playVideo();
|
|
|
|
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"songs.getOwnSongRatings",
|
|
"songs.getOwnSongRatings",
|
|
data.currentSong.songId,
|
|
data.currentSong.songId,
|
|
song => {
|
|
song => {
|
|
@@ -882,7 +882,7 @@ export default {
|
|
return this.isOwnerOnly() || this.isAdminOnly();
|
|
return this.isOwnerOnly() || this.isAdminOnly();
|
|
},
|
|
},
|
|
removeFromQueue(songId) {
|
|
removeFromQueue(songId) {
|
|
- window.socket.emit(
|
|
|
|
|
|
+ window.socket.dispatch(
|
|
"stations.removeFromQueue",
|
|
"stations.removeFromQueue",
|
|
this.station._id,
|
|
this.station._id,
|
|
songId,
|
|
songId,
|
|
@@ -1176,14 +1176,18 @@ export default {
|
|
this.timeElapsed = utils.formatTime(duration);
|
|
this.timeElapsed = utils.formatTime(duration);
|
|
},
|
|
},
|
|
toggleLock() {
|
|
toggleLock() {
|
|
- window.socket.emit("stations.toggleLock", this.station._id, res => {
|
|
|
|
- if (res.status === "success") {
|
|
|
|
- new Toast({
|
|
|
|
- content: "Successfully toggled the queue lock.",
|
|
|
|
- timeout: 4000
|
|
|
|
- });
|
|
|
|
- } else new Toast({ content: res.message, timeout: 8000 });
|
|
|
|
- });
|
|
|
|
|
|
+ window.socket.dispatch(
|
|
|
|
+ "stations.toggleLock",
|
|
|
|
+ this.station._id,
|
|
|
|
+ res => {
|
|
|
|
+ if (res.status === "success") {
|
|
|
|
+ new Toast({
|
|
|
|
+ content: "Successfully toggled the queue lock.",
|
|
|
|
+ timeout: 4000
|
|
|
|
+ });
|
|
|
|
+ } else new Toast({ content: res.message, timeout: 8000 });
|
|
|
|
+ }
|
|
|
|
+ );
|
|
},
|
|
},
|
|
changeVolume() {
|
|
changeVolume() {
|
|
const volume = this.volumeSliderValue;
|
|
const volume = this.volumeSliderValue;
|
|
@@ -1223,36 +1227,45 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
skipStation() {
|
|
skipStation() {
|
|
- this.socket.emit("stations.forceSkip", this.station._id, data => {
|
|
|
|
- if (data.status !== "success")
|
|
|
|
- new Toast({
|
|
|
|
- content: `Error: ${data.message}`,
|
|
|
|
- timeout: 8000
|
|
|
|
- });
|
|
|
|
- else
|
|
|
|
- new Toast({
|
|
|
|
- content:
|
|
|
|
- "Successfully skipped the station's current song.",
|
|
|
|
- timeout: 4000
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
|
|
+ "stations.forceSkip",
|
|
|
|
+ this.station._id,
|
|
|
|
+ data => {
|
|
|
|
+ if (data.status !== "success")
|
|
|
|
+ new Toast({
|
|
|
|
+ content: `Error: ${data.message}`,
|
|
|
|
+ timeout: 8000
|
|
|
|
+ });
|
|
|
|
+ else
|
|
|
|
+ new Toast({
|
|
|
|
+ content:
|
|
|
|
+ "Successfully skipped the station's current song.",
|
|
|
|
+ timeout: 4000
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ );
|
|
},
|
|
},
|
|
voteSkipStation() {
|
|
voteSkipStation() {
|
|
- this.socket.emit("stations.voteSkip", this.station._id, data => {
|
|
|
|
- if (data.status !== "success")
|
|
|
|
- new Toast({
|
|
|
|
- content: `Error: ${data.message}`,
|
|
|
|
- timeout: 8000
|
|
|
|
- });
|
|
|
|
- else
|
|
|
|
- new Toast({
|
|
|
|
- content: "Successfully voted to skip the current song.",
|
|
|
|
- timeout: 4000
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
|
|
+ "stations.voteSkip",
|
|
|
|
+ this.station._id,
|
|
|
|
+ data => {
|
|
|
|
+ if (data.status !== "success")
|
|
|
|
+ new Toast({
|
|
|
|
+ content: `Error: ${data.message}`,
|
|
|
|
+ timeout: 8000
|
|
|
|
+ });
|
|
|
|
+ else
|
|
|
|
+ new Toast({
|
|
|
|
+ content:
|
|
|
|
+ "Successfully voted to skip the current song.",
|
|
|
|
+ timeout: 4000
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ );
|
|
},
|
|
},
|
|
resumeStation() {
|
|
resumeStation() {
|
|
- this.socket.emit("stations.resume", this.station._id, data => {
|
|
|
|
|
|
+ this.socket.dispatch("stations.resume", this.station._id, data => {
|
|
if (data.status !== "success")
|
|
if (data.status !== "success")
|
|
new Toast({
|
|
new Toast({
|
|
content: `Error: ${data.message}`,
|
|
content: `Error: ${data.message}`,
|
|
@@ -1266,7 +1279,7 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
pauseStation() {
|
|
pauseStation() {
|
|
- this.socket.emit("stations.pause", this.station._id, data => {
|
|
|
|
|
|
+ this.socket.dispatch("stations.pause", this.station._id, data => {
|
|
if (data.status !== "success")
|
|
if (data.status !== "success")
|
|
new Toast({
|
|
new Toast({
|
|
content: `Error: ${data.message}`,
|
|
content: `Error: ${data.message}`,
|
|
@@ -1309,7 +1322,7 @@ export default {
|
|
},
|
|
},
|
|
toggleLike() {
|
|
toggleLike() {
|
|
if (this.liked)
|
|
if (this.liked)
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"songs.unlike",
|
|
"songs.unlike",
|
|
this.currentSong.songId,
|
|
this.currentSong.songId,
|
|
data => {
|
|
data => {
|
|
@@ -1321,7 +1334,7 @@ export default {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
else
|
|
else
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"songs.like",
|
|
"songs.like",
|
|
this.currentSong.songId,
|
|
this.currentSong.songId,
|
|
data => {
|
|
data => {
|
|
@@ -1335,7 +1348,7 @@ export default {
|
|
},
|
|
},
|
|
toggleDislike() {
|
|
toggleDislike() {
|
|
if (this.disliked)
|
|
if (this.disliked)
|
|
- return this.socket.emit(
|
|
|
|
|
|
+ return this.socket.dispatch(
|
|
"songs.undislike",
|
|
"songs.undislike",
|
|
this.currentSong.songId,
|
|
this.currentSong.songId,
|
|
data => {
|
|
data => {
|
|
@@ -1347,7 +1360,7 @@ export default {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
- return this.socket.emit(
|
|
|
|
|
|
+ return this.socket.dispatch(
|
|
"songs.dislike",
|
|
"songs.dislike",
|
|
this.currentSong.songId,
|
|
this.currentSong.songId,
|
|
data => {
|
|
data => {
|
|
@@ -1369,7 +1382,7 @@ export default {
|
|
if (queueSong.requestedBy === this.userId) isInQueue = true;
|
|
if (queueSong.requestedBy === this.userId) isInQueue = true;
|
|
});
|
|
});
|
|
if (!isInQueue && this.privatePlaylistQueueSelected) {
|
|
if (!isInQueue && this.privatePlaylistQueueSelected) {
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"playlists.getFirstSong",
|
|
"playlists.getFirstSong",
|
|
this.privatePlaylistQueueSelected,
|
|
this.privatePlaylistQueueSelected,
|
|
data => {
|
|
data => {
|
|
@@ -1378,13 +1391,13 @@ export default {
|
|
if (data.song.duration < 15 * 60) {
|
|
if (data.song.duration < 15 * 60) {
|
|
this.automaticallyRequestedSongId =
|
|
this.automaticallyRequestedSongId =
|
|
data.song.songId;
|
|
data.song.songId;
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"stations.addToQueue",
|
|
"stations.addToQueue",
|
|
this.station._id,
|
|
this.station._id,
|
|
data.song.songId,
|
|
data.song.songId,
|
|
data2 => {
|
|
data2 => {
|
|
if (data2.status === "success")
|
|
if (data2.status === "success")
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"playlists.moveSongToBottom",
|
|
"playlists.moveSongToBottom",
|
|
this
|
|
this
|
|
.privatePlaylistQueueSelected,
|
|
.privatePlaylistQueueSelected,
|
|
@@ -1398,7 +1411,7 @@ export default {
|
|
timeout: 3000
|
|
timeout: 3000
|
|
});
|
|
});
|
|
|
|
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"playlists.moveSongToBottom",
|
|
"playlists.moveSongToBottom",
|
|
this.privatePlaylistQueueSelected,
|
|
this.privatePlaylistQueueSelected,
|
|
data.song.songId,
|
|
data.song.songId,
|
|
@@ -1430,223 +1443,242 @@ export default {
|
|
this.$refs.playerDebugBox.resetBox();
|
|
this.$refs.playerDebugBox.resetBox();
|
|
},
|
|
},
|
|
join() {
|
|
join() {
|
|
- this.socket.emit("stations.join", this.stationIdentifier, res => {
|
|
|
|
- if (res.status === "success") {
|
|
|
|
- setTimeout(() => {
|
|
|
|
- this.loading = false;
|
|
|
|
- }, 1000); // prevents popping in of youtube embed etc.
|
|
|
|
-
|
|
|
|
- const {
|
|
|
|
- _id,
|
|
|
|
- displayName,
|
|
|
|
- name,
|
|
|
|
- description,
|
|
|
|
- privacy,
|
|
|
|
- locked,
|
|
|
|
- partyMode,
|
|
|
|
- owner,
|
|
|
|
- privatePlaylist,
|
|
|
|
- type,
|
|
|
|
- genres,
|
|
|
|
- blacklistedGenres,
|
|
|
|
- isFavorited,
|
|
|
|
- theme
|
|
|
|
- } = res.data;
|
|
|
|
-
|
|
|
|
- // change url to use station name instead of station id
|
|
|
|
- if (name !== this.stationIdentifier) {
|
|
|
|
- // eslint-disable-next-line no-restricted-globals
|
|
|
|
- history.pushState({}, null, name);
|
|
|
|
- }
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
|
|
+ "stations.join",
|
|
|
|
+ this.stationIdentifier,
|
|
|
|
+ res => {
|
|
|
|
+ if (res.status === "success") {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.loading = false;
|
|
|
|
+ }, 1000); // prevents popping in of youtube embed etc.
|
|
|
|
+
|
|
|
|
+ const {
|
|
|
|
+ _id,
|
|
|
|
+ displayName,
|
|
|
|
+ name,
|
|
|
|
+ description,
|
|
|
|
+ privacy,
|
|
|
|
+ locked,
|
|
|
|
+ partyMode,
|
|
|
|
+ owner,
|
|
|
|
+ privatePlaylist,
|
|
|
|
+ type,
|
|
|
|
+ genres,
|
|
|
|
+ blacklistedGenres,
|
|
|
|
+ isFavorited,
|
|
|
|
+ theme
|
|
|
|
+ } = res.data;
|
|
|
|
+
|
|
|
|
+ // change url to use station name instead of station id
|
|
|
|
+ if (name !== this.stationIdentifier) {
|
|
|
|
+ // eslint-disable-next-line no-restricted-globals
|
|
|
|
+ history.pushState({}, null, name);
|
|
|
|
+ }
|
|
|
|
|
|
- this.joinStation({
|
|
|
|
- _id,
|
|
|
|
- name,
|
|
|
|
- displayName,
|
|
|
|
- description,
|
|
|
|
- privacy,
|
|
|
|
- locked,
|
|
|
|
- partyMode,
|
|
|
|
- owner,
|
|
|
|
- privatePlaylist,
|
|
|
|
- type,
|
|
|
|
- genres,
|
|
|
|
- blacklistedGenres,
|
|
|
|
- isFavorited,
|
|
|
|
- theme
|
|
|
|
- });
|
|
|
|
|
|
+ this.joinStation({
|
|
|
|
+ _id,
|
|
|
|
+ name,
|
|
|
|
+ displayName,
|
|
|
|
+ description,
|
|
|
|
+ privacy,
|
|
|
|
+ locked,
|
|
|
|
+ partyMode,
|
|
|
|
+ owner,
|
|
|
|
+ privatePlaylist,
|
|
|
|
+ type,
|
|
|
|
+ genres,
|
|
|
|
+ blacklistedGenres,
|
|
|
|
+ isFavorited,
|
|
|
|
+ theme
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ const currentSong = res.data.currentSong
|
|
|
|
+ ? res.data.currentSong
|
|
|
|
+ : {};
|
|
|
|
+
|
|
|
|
+ if (currentSong.artists)
|
|
|
|
+ currentSong.artists = currentSong.artists.join(
|
|
|
|
+ ", "
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if (currentSong && !currentSong.thumbnail)
|
|
|
|
+ currentSong.ytThumbnail = `https://img.youtube.com/vi/${currentSong.songId}/mqdefault.jpg`;
|
|
|
|
+
|
|
|
|
+ this.updateCurrentSong(currentSong);
|
|
|
|
+
|
|
|
|
+ this.startedAt = res.data.startedAt;
|
|
|
|
+ this.updateStationPaused(res.data.paused);
|
|
|
|
+ this.timePaused = res.data.timePaused;
|
|
|
|
+ this.updateUserCount(res.data.userCount);
|
|
|
|
+ this.updateUsers(res.data.users);
|
|
|
|
+ this.pausedAt = res.data.pausedAt;
|
|
|
|
|
|
- const currentSong = res.data.currentSong
|
|
|
|
- ? res.data.currentSong
|
|
|
|
- : {};
|
|
|
|
-
|
|
|
|
- if (currentSong.artists)
|
|
|
|
- currentSong.artists = currentSong.artists.join(", ");
|
|
|
|
-
|
|
|
|
- if (currentSong && !currentSong.thumbnail)
|
|
|
|
- currentSong.ytThumbnail = `https://img.youtube.com/vi/${currentSong.songId}/mqdefault.jpg`;
|
|
|
|
-
|
|
|
|
- this.updateCurrentSong(currentSong);
|
|
|
|
-
|
|
|
|
- this.startedAt = res.data.startedAt;
|
|
|
|
- this.updateStationPaused(res.data.paused);
|
|
|
|
- this.timePaused = res.data.timePaused;
|
|
|
|
- this.updateUserCount(res.data.userCount);
|
|
|
|
- this.updateUsers(res.data.users);
|
|
|
|
- this.pausedAt = res.data.pausedAt;
|
|
|
|
-
|
|
|
|
- if (res.data.currentSong) {
|
|
|
|
- this.updateNoSong(false);
|
|
|
|
- this.youtubeReady();
|
|
|
|
- this.playVideo();
|
|
|
|
- this.socket.emit(
|
|
|
|
- "songs.getOwnSongRatings",
|
|
|
|
- res.data.currentSong.songId,
|
|
|
|
- data => {
|
|
|
|
- if (this.currentSong.songId === data.songId) {
|
|
|
|
- this.liked = data.liked;
|
|
|
|
- this.disliked = data.disliked;
|
|
|
|
|
|
+ if (res.data.currentSong) {
|
|
|
|
+ this.updateNoSong(false);
|
|
|
|
+ this.youtubeReady();
|
|
|
|
+ this.playVideo();
|
|
|
|
+ this.socket.dispatch(
|
|
|
|
+ "songs.getOwnSongRatings",
|
|
|
|
+ res.data.currentSong.songId,
|
|
|
|
+ data => {
|
|
|
|
+ if (
|
|
|
|
+ this.currentSong.songId === data.songId
|
|
|
|
+ ) {
|
|
|
|
+ this.liked = data.liked;
|
|
|
|
+ this.disliked = data.disliked;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- if (this.playerReady) this.player.pauseVideo();
|
|
|
|
- this.updateNoSong(true);
|
|
|
|
- }
|
|
|
|
|
|
+ );
|
|
|
|
+ } else {
|
|
|
|
+ if (this.playerReady) this.player.pauseVideo();
|
|
|
|
+ this.updateNoSong(true);
|
|
|
|
+ }
|
|
|
|
|
|
- if (type === "community" && partyMode === true) {
|
|
|
|
- this.socket.emit("stations.getQueue", _id, res => {
|
|
|
|
- if (res.status === "success") {
|
|
|
|
- this.updateSongsList(res.queue);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ if (type === "community" && partyMode === true) {
|
|
|
|
+ this.socket.dispatch(
|
|
|
|
+ "stations.getQueue",
|
|
|
|
+ _id,
|
|
|
|
+ res => {
|
|
|
|
+ if (res.status === "success") {
|
|
|
|
+ this.updateSongsList(res.queue);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (this.isOwnerOrAdmin()) {
|
|
|
|
+ keyboardShortcuts.registerShortcut(
|
|
|
|
+ "station.pauseResume",
|
|
|
|
+ {
|
|
|
|
+ keyCode: 32,
|
|
|
|
+ shift: false,
|
|
|
|
+ ctrl: true,
|
|
|
|
+ preventDefault: true,
|
|
|
|
+ handler: () => {
|
|
|
|
+ if (this.stationPaused)
|
|
|
|
+ this.resumeStation();
|
|
|
|
+ else this.pauseStation();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ keyboardShortcuts.registerShortcut(
|
|
|
|
+ "station.skipStation",
|
|
|
|
+ {
|
|
|
|
+ keyCode: 39,
|
|
|
|
+ shift: false,
|
|
|
|
+ ctrl: true,
|
|
|
|
+ preventDefault: true,
|
|
|
|
+ handler: () => {
|
|
|
|
+ this.skipStation();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
|
|
- if (this.isOwnerOrAdmin()) {
|
|
|
|
keyboardShortcuts.registerShortcut(
|
|
keyboardShortcuts.registerShortcut(
|
|
- "station.pauseResume",
|
|
|
|
|
|
+ "station.lowerVolumeLarge",
|
|
{
|
|
{
|
|
- keyCode: 32,
|
|
|
|
|
|
+ keyCode: 40,
|
|
shift: false,
|
|
shift: false,
|
|
ctrl: true,
|
|
ctrl: true,
|
|
preventDefault: true,
|
|
preventDefault: true,
|
|
handler: () => {
|
|
handler: () => {
|
|
- if (this.stationPaused)
|
|
|
|
- this.resumeStation();
|
|
|
|
- else this.pauseStation();
|
|
|
|
|
|
+ this.volumeSliderValue -= 1000;
|
|
|
|
+ this.changeVolume();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
keyboardShortcuts.registerShortcut(
|
|
keyboardShortcuts.registerShortcut(
|
|
- "station.skipStation",
|
|
|
|
|
|
+ "station.lowerVolumeSmall",
|
|
{
|
|
{
|
|
- keyCode: 39,
|
|
|
|
- shift: false,
|
|
|
|
|
|
+ keyCode: 40,
|
|
|
|
+ shift: true,
|
|
ctrl: true,
|
|
ctrl: true,
|
|
preventDefault: true,
|
|
preventDefault: true,
|
|
handler: () => {
|
|
handler: () => {
|
|
- this.skipStation();
|
|
|
|
|
|
+ this.volumeSliderValue -= 100;
|
|
|
|
+ this.changeVolume();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
);
|
|
- }
|
|
|
|
-
|
|
|
|
- keyboardShortcuts.registerShortcut(
|
|
|
|
- "station.lowerVolumeLarge",
|
|
|
|
- {
|
|
|
|
- keyCode: 40,
|
|
|
|
- shift: false,
|
|
|
|
- ctrl: true,
|
|
|
|
- preventDefault: true,
|
|
|
|
- handler: () => {
|
|
|
|
- this.volumeSliderValue -= 1000;
|
|
|
|
- this.changeVolume();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
|
|
- keyboardShortcuts.registerShortcut(
|
|
|
|
- "station.lowerVolumeSmall",
|
|
|
|
- {
|
|
|
|
- keyCode: 40,
|
|
|
|
- shift: true,
|
|
|
|
- ctrl: true,
|
|
|
|
- preventDefault: true,
|
|
|
|
- handler: () => {
|
|
|
|
- this.volumeSliderValue -= 100;
|
|
|
|
- this.changeVolume();
|
|
|
|
|
|
+ keyboardShortcuts.registerShortcut(
|
|
|
|
+ "station.increaseVolumeLarge",
|
|
|
|
+ {
|
|
|
|
+ keyCode: 38,
|
|
|
|
+ shift: false,
|
|
|
|
+ ctrl: true,
|
|
|
|
+ preventDefault: true,
|
|
|
|
+ handler: () => {
|
|
|
|
+ this.volumeSliderValue += 1000;
|
|
|
|
+ this.changeVolume();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ );
|
|
|
|
|
|
- keyboardShortcuts.registerShortcut(
|
|
|
|
- "station.increaseVolumeLarge",
|
|
|
|
- {
|
|
|
|
- keyCode: 38,
|
|
|
|
- shift: false,
|
|
|
|
- ctrl: true,
|
|
|
|
- preventDefault: true,
|
|
|
|
- handler: () => {
|
|
|
|
- this.volumeSliderValue += 1000;
|
|
|
|
- this.changeVolume();
|
|
|
|
|
|
+ keyboardShortcuts.registerShortcut(
|
|
|
|
+ "station.increaseVolumeSmall",
|
|
|
|
+ {
|
|
|
|
+ keyCode: 38,
|
|
|
|
+ shift: true,
|
|
|
|
+ ctrl: true,
|
|
|
|
+ preventDefault: true,
|
|
|
|
+ handler: () => {
|
|
|
|
+ this.volumeSliderValue += 100;
|
|
|
|
+ this.changeVolume();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- );
|
|
|
|
|
|
+ );
|
|
|
|
|
|
- keyboardShortcuts.registerShortcut(
|
|
|
|
- "station.increaseVolumeSmall",
|
|
|
|
- {
|
|
|
|
- keyCode: 38,
|
|
|
|
- shift: true,
|
|
|
|
- ctrl: true,
|
|
|
|
- preventDefault: true,
|
|
|
|
- handler: () => {
|
|
|
|
- this.volumeSliderValue += 100;
|
|
|
|
- this.changeVolume();
|
|
|
|
|
|
+ keyboardShortcuts.registerShortcut(
|
|
|
|
+ "station.toggleDebug",
|
|
|
|
+ {
|
|
|
|
+ keyCode: 68,
|
|
|
|
+ shift: false,
|
|
|
|
+ ctrl: true,
|
|
|
|
+ preventDefault: true,
|
|
|
|
+ handler: () => {
|
|
|
|
+ this.togglePlayerDebugBox();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- keyboardShortcuts.registerShortcut("station.toggleDebug", {
|
|
|
|
- keyCode: 68,
|
|
|
|
- shift: false,
|
|
|
|
- ctrl: true,
|
|
|
|
- preventDefault: true,
|
|
|
|
- handler: () => {
|
|
|
|
- this.togglePlayerDebugBox();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ );
|
|
|
|
|
|
- // UNIX client time before ping
|
|
|
|
- const beforePing = Date.now();
|
|
|
|
- this.socket.emit("apis.ping", pong => {
|
|
|
|
- // UNIX client time after ping
|
|
|
|
- const afterPing = Date.now();
|
|
|
|
- // Average time in MS it took between the server responding and the client receiving
|
|
|
|
- const connectionLatency = (afterPing - beforePing) / 2;
|
|
|
|
- console.log(connectionLatency, beforePing - afterPing);
|
|
|
|
- // UNIX server time
|
|
|
|
- const serverDate = pong.date;
|
|
|
|
- // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
|
|
|
|
- const difference =
|
|
|
|
- serverDate + connectionLatency - afterPing;
|
|
|
|
- console.log("Difference: ", difference);
|
|
|
|
- if (difference > 3000 || difference < -3000) {
|
|
|
|
|
|
+ // UNIX client time before ping
|
|
|
|
+ const beforePing = Date.now();
|
|
|
|
+ this.socket.dispatch("apis.ping", pong => {
|
|
|
|
+ // UNIX client time after ping
|
|
|
|
+ const afterPing = Date.now();
|
|
|
|
+ // Average time in MS it took between the server responding and the client receiving
|
|
|
|
+ const connectionLatency =
|
|
|
|
+ (afterPing - beforePing) / 2;
|
|
console.log(
|
|
console.log(
|
|
- "System time difference is bigger than 3 seconds."
|
|
|
|
|
|
+ connectionLatency,
|
|
|
|
+ beforePing - afterPing
|
|
);
|
|
);
|
|
- }
|
|
|
|
- this.systemDifference = difference;
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- this.loading = false;
|
|
|
|
- this.exists = false;
|
|
|
|
|
|
+ // UNIX server time
|
|
|
|
+ const serverDate = pong.date;
|
|
|
|
+ // Difference between the server UNIX time and the client UNIX time after ping, with the connectionLatency added to the server UNIX time
|
|
|
|
+ const difference =
|
|
|
|
+ serverDate + connectionLatency - afterPing;
|
|
|
|
+ console.log("Difference: ", difference);
|
|
|
|
+ if (difference > 3000 || difference < -3000) {
|
|
|
|
+ console.log(
|
|
|
|
+ "System time difference is bigger than 3 seconds."
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ this.systemDifference = difference;
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ this.loading = false;
|
|
|
|
+ this.exists = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ );
|
|
},
|
|
},
|
|
favoriteStation() {
|
|
favoriteStation() {
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"stations.favoriteStation",
|
|
"stations.favoriteStation",
|
|
this.station._id,
|
|
this.station._id,
|
|
res => {
|
|
res => {
|
|
@@ -1660,7 +1692,7 @@ export default {
|
|
);
|
|
);
|
|
},
|
|
},
|
|
unfavoriteStation() {
|
|
unfavoriteStation() {
|
|
- this.socket.emit(
|
|
|
|
|
|
+ this.socket.dispatch(
|
|
"stations.unfavoriteStation",
|
|
"stations.unfavoriteStation",
|
|
this.station._id,
|
|
this.station._id,
|
|
res => {
|
|
res => {
|