Browse Source

fix: station pausing when a media modal started playing didn't work if a player was paused/resumed directly

Kristian Vos 2 years ago
parent
commit
17f5f46fe3

+ 11 - 9
frontend/src/components/modals/EditSong/index.vue

@@ -336,7 +336,7 @@ const unloadSong = (_youtubeId, songId?) => {
 	songDeleted.value = false;
 	stopVideo();
 	pauseVideo(true);
-	updateMediaModalPlayingAudio(false);
+
 	resetSong(_youtubeId);
 	thumbnailNotSquare.value = false;
 	thumbnailWidth.value = null;
@@ -428,7 +428,7 @@ const drawCanvas = () => {
 
 const seekTo = position => {
 	pauseVideo(false);
-	updateMediaModalPlayingAudio(true);
+
 	video.value.player.seekTo(position);
 };
 
@@ -466,7 +466,7 @@ const init = () => {
 		) {
 			stopVideo();
 			pauseVideo(true);
-			updateMediaModalPlayingAudio(false);
+
 			drawCanvas();
 		}
 		if (
@@ -543,6 +543,7 @@ const init = () => {
 
 						if (event.data === 1) {
 							video.value.paused = false;
+							updateMediaModalPlayingAudio(true);
 							let youtubeDuration =
 								video.value.player.getDuration();
 							const newYoutubeVideoDuration =
@@ -603,7 +604,7 @@ const init = () => {
 							if (song.value.duration > youtubeDuration + 1) {
 								stopVideo();
 								pauseVideo(true);
-								updateMediaModalPlayingAudio(false);
+
 								return new Toast(
 									"Video can't play. Specified duration is bigger than the YouTube song duration."
 								);
@@ -611,7 +612,7 @@ const init = () => {
 							if (song.value.duration <= 0) {
 								stopVideo();
 								pauseVideo(true);
-								updateMediaModalPlayingAudio(false);
+
 								return new Toast(
 									"Video can't play. Specified duration has to be more than 0 seconds."
 								);
@@ -627,6 +628,7 @@ const init = () => {
 							setPlaybackRate(null);
 						} else if (event.data === 2) {
 							video.value.paused = true;
+							updateMediaModalPlayingAudio(false);
 						}
 
 						return false;
@@ -956,20 +958,20 @@ const settings = type => {
 		case "stop":
 			stopVideo();
 			pauseVideo(true);
-			updateMediaModalPlayingAudio(false);
+
 			break;
 		case "hardStop":
 			hardStopVideo();
 			pauseVideo(true);
-			updateMediaModalPlayingAudio(false);
+
 			break;
 		case "pause":
 			pauseVideo(true);
-			updateMediaModalPlayingAudio(false);
+
 			break;
 		case "play":
 			pauseVideo(false);
-			updateMediaModalPlayingAudio(true);
+
 			break;
 		case "skipToLast10Secs":
 			seekTo(song.value.duration - 10 + song.value.skipDuration);

+ 2 - 8
frontend/src/components/modals/ViewYoutubeVideo.vue

@@ -78,7 +78,6 @@ const confirmAction = ({ message, action }) => {
 
 const seekTo = position => {
 	pauseVideo(false);
-	updateMediaModalPlayingAudio(true);
 	player.value.player.seekTo(position);
 };
 
@@ -87,15 +86,12 @@ const settings = type => {
 		case "stop":
 			stopVideo();
 			pauseVideo(true);
-			updateMediaModalPlayingAudio(false);
 			break;
 		case "pause":
 			pauseVideo(true);
-			updateMediaModalPlayingAudio(false);
 			break;
 		case "play":
 			pauseVideo(false);
-			updateMediaModalPlayingAudio(true);
 			break;
 		case "skipToLast10Secs":
 			seekTo(Number(player.value.duration) - 10);
@@ -242,7 +238,6 @@ const init = () => {
 					) {
 						stopVideo();
 						pauseVideo(true);
-						updateMediaModalPlayingAudio(false);
 						drawCanvas();
 					}
 					if (
@@ -331,6 +326,7 @@ const init = () => {
 
 									if (event.data === 1) {
 										player.value.paused = false;
+										updateMediaModalPlayingAudio(true);
 										const youtubeDuration =
 											player.value.player.getDuration();
 										const newYoutubeVideoDuration =
@@ -396,7 +392,6 @@ const init = () => {
 										) {
 											stopVideo();
 											pauseVideo(true);
-											updateMediaModalPlayingAudio(false);
 											return new Toast(
 												"Video can't play. Specified duration is bigger than the YouTube song duration."
 											);
@@ -404,7 +399,6 @@ const init = () => {
 										if (video.value.duration <= 0) {
 											stopVideo();
 											pauseVideo(true);
-											updateMediaModalPlayingAudio(false);
 											return new Toast(
 												"Video can't play. Specified duration has to be more than 0 seconds."
 											);
@@ -413,6 +407,7 @@ const init = () => {
 										setPlaybackRate(null);
 									} else if (event.data === 2) {
 										player.value.paused = true;
+										updateMediaModalPlayingAudio(false);
 									}
 
 									return false;
@@ -463,7 +458,6 @@ onMounted(() => {
 onBeforeUnmount(() => {
 	stopVideo();
 	pauseVideo(true);
-	updateMediaModalPlayingAudio(false);
 	player.value.duration = "0.000";
 	player.value.currentTime = 0;
 	player.value.playerReady = false;