소스 검색

Made some changes to next song skipping in a station

Kristian Vos 3 년 전
부모
커밋
ccb6b91d21
3개의 변경된 파일117개의 추가작업 그리고 21개의 파일을 삭제
  1. 12 0
      backend/index.js
  2. 0 2
      frontend/src/components/modals/EditSong.vue
  3. 105 19
      frontend/src/pages/Station/index.vue

+ 12 - 0
backend/index.js

@@ -412,6 +412,18 @@ class ModuleManager {
 			console.error.apply(null, _arguments);
 		}
 	}
+
+	/**
+	 * Locks down all modules
+	 */
+	_lockdown() {
+		this.lockdown = true;
+		Object.keys(this.modules).every(moduleKey => {
+			const module = this.modules[moduleKey];
+			module.setStatus("LOCKDOWN");
+			return true;
+		});
+	}
 }
 
 const moduleManager = new ModuleManager();

+ 0 - 2
frontend/src/components/modals/EditSong.vue

@@ -1584,8 +1584,6 @@ export default {
 					hostname: window.location.hostname
 				};
 
-				console.log("SENDING VIDEO DATA");
-
 				aw.sendVideoData(videoData);
 			} else {
 				this.activityWatchVideoLastStatus = "not_playing";

+ 105 - 19
frontend/src/pages/Station/index.vue

@@ -817,11 +817,26 @@ export default {
 			this.updateStationPaused(false);
 			if (!this.localPaused) this.resumeLocalPlayer();
 
-			if (this.currentSong)
-				window.stationNextSongTimeout = setTimeout(
-					this.skipSong,
-					this.getTimeRemaining()
-				);
+			if (this.currentSong) {
+				if (this.nextSong)
+					this.setNextCurrentSong({
+						currentSong: this.nextSong,
+						startedAt: Date.now() + this.getTimeRemaining(),
+						paused: false,
+						timePaused: 0
+					});
+				else
+					this.setNextCurrentSong({
+						currentSong: null,
+						startedAt: 0,
+						paused: false,
+						timePaused: 0,
+						pausedAt: 0
+					});
+				window.stationNextSongTimeout = setTimeout(() => {
+					this.skipSong("window.stationNextSongTimeout 2");
+				}, this.getTimeRemaining());
+			}
 		});
 
 		this.socket.on("event:station.deleted", () => {
@@ -885,6 +900,22 @@ export default {
 
 			this.updateNextSong(nextSong);
 
+			if (nextSong)
+				this.setNextCurrentSong({
+					currentSong: nextSong,
+					startedAt: Date.now() + this.getTimeRemaining(),
+					paused: false,
+					timePaused: 0
+				});
+			else
+				this.setNextCurrentSong({
+					currentSong: null,
+					startedAt: 0,
+					paused: false,
+					timePaused: 0,
+					pausedAt: 0
+				});
+
 			this.addPartyPlaylistSongToQueue();
 		});
 
@@ -898,6 +929,13 @@ export default {
 					: null;
 
 			this.updateNextSong(nextSong);
+
+			this.setNextCurrentSong({
+				currentSong: nextSong,
+				startedAt: Date.now() + this.getTimeRemaining(),
+				paused: false,
+				timePaused: 0
+			});
 		});
 
 		this.socket.on("event:station.voteSkipSong", () => {
@@ -1041,16 +1079,32 @@ export default {
 				}
 			);
 		},
-		setNextCurrentSong(nextCurrentSong) {
+		setNextCurrentSong(nextCurrentSong, skipSkipCheck = false) {
 			this.nextCurrentSong = nextCurrentSong;
-			if (this.getTimeRemaining() <= 0) {
+			if (this.getTimeRemaining() <= 0 && !skipSkipCheck) {
 				this.skipSong();
 			}
 		},
 		skipSong() {
-			console.log("SKIP_SONG_FN", this.nextCurrentSong);
 			if (this.nextCurrentSong && this.nextCurrentSong.currentSong) {
+				const songsList = this.songsList.concat([]);
+				if (
+					songsList.length > 0 &&
+					songsList[0].youtubeId ===
+						this.nextCurrentSong.currentSong.youtubeId
+				) {
+					songsList.splice(0, 1);
+					this.updateSongsList(songsList);
+				}
 				this.setCurrentSong(this.nextCurrentSong);
+			} else {
+				this.setCurrentSong({
+					currentSong: null,
+					startedAt: 0,
+					paused: this.stationPaused,
+					timePaused: 0,
+					pausedAt: 0
+				});
 			}
 		},
 		setCurrentSong(data) {
@@ -1070,13 +1124,16 @@ export default {
 					? this.songsList[0]
 					: null;
 			this.updateNextSong(nextSong);
-			this.nextCurrentSong = {
-				currentSong: null,
-				startedAt: 0,
-				paused,
-				timePaused: 0,
-				pausedAt: 0
-			};
+			this.setNextCurrentSong(
+				{
+					currentSong: null,
+					startedAt: 0,
+					paused,
+					timePaused: 0,
+					pausedAt: 0
+				},
+				true
+			);
 
 			clearTimeout(window.stationNextSongTimeout);
 
@@ -1092,10 +1149,30 @@ export default {
 				else this.playVideo();
 
 				if (!this.stationPaused) {
-					window.stationNextSongTimeout = setTimeout(
-						this.skipSong,
-						this.getTimeRemaining()
-					);
+					if (this.nextSong)
+						this.setNextCurrentSong(
+							{
+								currentSong: this.nextSong,
+								startedAt: Date.now() + this.getTimeRemaining(),
+								paused: false,
+								timePaused: 0
+							},
+							true
+						);
+					else
+						this.setNextCurrentSong(
+							{
+								currentSong: null,
+								startedAt: 0,
+								paused: false,
+								timePaused: 0,
+								pausedAt: 0
+							},
+							true
+						);
+					window.stationNextSongTimeout = setTimeout(() => {
+						this.skipSong("window.stationNextSongTimeout 1");
+					}, this.getTimeRemaining());
 				}
 
 				this.socket.dispatch(
@@ -1126,6 +1203,8 @@ export default {
 				this.updateNoSong(true);
 			}
 
+			console.log(666);
+
 			this.calculateTimeElapsed();
 			this.resizeSeekerbar();
 		},
@@ -1702,6 +1781,13 @@ export default {
 										: null;
 								}
 								this.updateNextSong(nextSong);
+								this.setNextCurrentSong({
+									currentSong: nextSong,
+									startedAt:
+										Date.now() + this.getTimeRemaining(),
+									paused: false,
+									timePaused: 0
+								});
 							}
 						});