From fae19af8b4a2e83967cec67f24a414c9450abbd1 Mon Sep 17 00:00:00 2001 From: RemiSaurel Date: Mon, 29 Aug 2022 11:24:42 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8#8=20-=20Add=20Youtube=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/YtbPlayer.vue | 44 +++++++++++++++++++++++++++++------- src/data/lofi.json | 1 - 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/components/YtbPlayer.vue b/src/components/YtbPlayer.vue index c5256db..f0dd2e7 100644 --- a/src/components/YtbPlayer.vue +++ b/src/components/YtbPlayer.vue @@ -1,11 +1,6 @@ diff --git a/src/data/lofi.json b/src/data/lofi.json index 7585509..e3e531a 100644 --- a/src/data/lofi.json +++ b/src/data/lofi.json @@ -5,7 +5,6 @@ "7NOSDKb0HlU", "-5KAN9_CzSA", "jfKfPfyJRdk", - "GDQnA1LVCWA", "-pzxY5DtZIQ", "Mu3BfD6wmPg", From 3d142efc5445809cef6a5b563d96866a7cb8d8c2 Mon Sep 17 00:00:00 2001 From: RemiSaurel Date: Mon, 29 Aug 2022 11:52:43 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8#8=20-=20Play=20/=20Pause=20and=20?= =?UTF-8?q?Mute=20/=20Unmute=20buttons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/YtbPlayer.vue | 53 +++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/src/components/YtbPlayer.vue b/src/components/YtbPlayer.vue index f0dd2e7..08883db 100644 --- a/src/components/YtbPlayer.vue +++ b/src/components/YtbPlayer.vue @@ -2,8 +2,11 @@
- + + + +
@@ -26,35 +29,50 @@ export default { displayYoutube: true, livesId: [], easterEggs: [], - easterEggsSongsId:-1, - songId: 0 + easterEggsSongsId: -1, + songId: 0, + muted: true } }, methods: { - readFileAndStore() - { + readFileAndStore() { let lofi = require("../data/lofi.json"); this.livesId = lofi.id; this.easterEggs = lofi.easterEggs; }, - nextPlaylist() - { + nextPlaylist() { this.songId++ === this.livesId.length - 1 ? this.songId = 0 : this.songId; let id = this.livesId[this.songId]; - this.changeYtbSrc(id) + this.loadVideoFromApi(id) }, - prevPlaylist() - { - --this.songId === -1 ? this.songId = this.livesId.length - 1: this.songId; + prevPlaylist() { + --this.songId === -1 ? this.songId = this.livesId.length - 1 : this.songId; let id = this.livesId[this.songId]; - this.changeYtbSrc(id) + this.loadVideoFromApi(id) + }, + pausePlayPlaylist() { + if (player.getPlayerState() === 1) { + player.pauseVideo(); + } else { + player.playVideo(); + } }, easterEgg() { this.easterEggsSongsId++ === this.easterEggs.length - 1 ? this.easterEggsSongsId = 0 : this.easterEggsSongsId; let id = this.easterEggs[this.easterEggsSongsId]; - this.changeYtbSrc(id) + this.loadVideoFromApi(id) }, - changeYtbSrc(id) { + setMuteState() { + if (this.muted) { + player.unMute(); + player.setVolume(15); + } else { + player.mute(); + } + + this.muted = !this.muted; + }, + loadVideoFromApi(id) { player.loadVideoById(id); }, loadApi() { @@ -64,13 +82,16 @@ export default { videoId: "XDh0JcxrbPM", playerVars: { 'autoplay': 1, - 'mute': 1 + 'mute': 1, + 'rel': 0, + 'showInfo': 0 }, events: { onStateChange: window.onPlayerStateChange } }); - document.getElementById("player").style.width = "100%"; + let player_id = document.getElementById("player") + player_id.style.width = "100%"; }; window.onPlayerStateChange = (event) => {