Browse Source

Added ability to change video's id while editing in EditSong modal

Kristian Vos 3 years ago
parent
commit
03cfdc55e9
1 changed files with 19 additions and 5 deletions
  1. 19 5
      frontend/src/components/modals/EditSong.vue

+ 19 - 5
frontend/src/components/modals/EditSong.vue

@@ -15,8 +15,8 @@
 								<div class="player-footer-left">
 									<i
 										class="material-icons player-play-pause"
-										@click="settings('play')"
-										@keyup.enter="settings('play')"
+										@click="play()"
+										@keyup.enter="play()"
 										tabindex="0"
 										v-if="video.paused"
 										>play_arrow</i
@@ -650,10 +650,10 @@ export default {
 	},
 	watch: {
 		/* eslint-disable */
-		"song.duration": function () {
+		"song.duration": function() {
 			this.drawCanvas();
 		},
-		"song.skipDuration": function () {
+		"song.skipDuration": function() {
 			this.drawCanvas();
 		}
 		/* eslint-enable */
@@ -839,7 +839,7 @@ export default {
 			keyCode: 101,
 			preventDefault: true,
 			handler: () => {
-				if (this.video.paused) this.settings("play");
+				if (this.video.paused) this.play();
 				else this.settings("pause");
 			}
 		});
@@ -1033,6 +1033,11 @@ export default {
 			let saveButtonRef = this.$refs.saveButton;
 			if (close) saveButtonRef = this.$refs.saveAndCloseButton;
 
+			if (this.youtubeVideoDuration === "0.000") {
+				saveButtonRef.handleFailedSave();
+				return new Toast("The video appears to not be working.");
+			}
+
 			if (!song.title) {
 				saveButtonRef.handleFailedSave();
 				return new Toast("Please fill in all fields");
@@ -1370,6 +1375,15 @@ export default {
 					break;
 			}
 		},
+		play() {
+			if (
+				this.video.player.getVideoData().video_id !==
+				this.song.youtubeId
+			) {
+				this.loadVideoById(this.song.youtubeId, this.song.skipDuration);
+			}
+			this.settings("play");
+		},
 		changeVolume() {
 			const volume = this.volumeSliderValue;
 			localStorage.setItem("volume", volume / 100);