Browse Source

fix: station player would play 0.1s of video when socket reconnects or station loads when the station was station/local paused

Kristian Vos 2 months ago
parent
commit
5f84ae3a93
1 changed files with 13 additions and 5 deletions
  1. 13 5
      frontend/src/pages/Station/index.vue

+ 13 - 5
frontend/src/pages/Station/index.vue

@@ -457,7 +457,7 @@ const calculateTimeElapsed = async () => {
 					}
 				});
 			}
-		} else {
+		} else if (!stationPaused.value && !localPaused.value) {
 			youtubePlayer.value.playVideo();
 			attemptsToPlayVideo.value += 1;
 		}
@@ -544,10 +544,17 @@ const playVideo = () => {
 	if (currentSongMediaType.value === "youtube") {
 		if (youtubePlayerReady.value) {
 			videoLoading.value = true;
-			youtubePlayer.value.loadVideoById(
-				currentYoutubeId.value,
-				getTimeElapsed() / 1000 + currentSong.value.skipDuration
-			);
+			if (stationPaused.value || localPaused.value) {
+				youtubePlayer.value.cueVideoById(
+					currentYoutubeId.value,
+					getTimeElapsed() / 1000 + currentSong.value.skipDuration
+				);
+			} else {
+				youtubePlayer.value.loadVideoById(
+					currentYoutubeId.value,
+					getTimeElapsed() / 1000 + currentSong.value.skipDuration
+				);
+			}
 		}
 	} else if (currentSongMediaType.value === "soundcloud") {
 		const soundcloudId = currentSongMediaValue.value;
@@ -582,6 +589,7 @@ const changePlayerVolume = () => {
 	changeSoundcloudPlayerVolume();
 };
 const playerPlay = () => {
+	if (stationPaused.value || localPaused.value) return;
 	console.debug(
 		TAG,
 		"PLAYER PLAY",