From 5975bccc39f941044649d0ba72f43e5340396c66 Mon Sep 17 00:00:00 2001 From: RblSb Date: Mon, 2 Mar 2020 20:17:31 +0300 Subject: Fix youtube player control --- res/client.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'res/client.js') diff --git a/res/client.js b/res/client.js index c197ff2..224cb9e 100644 --- a/res/client.js +++ b/res/client.js @@ -1891,10 +1891,11 @@ client_players_Youtube.prototype = { this.video = window.document.createElement("div"); this.video.id = "videoplayer"; this.playerEl.appendChild(this.video); - this.youtube = new YT.Player(this.video.id,{ videoId : client_players_Youtube.extractVideoId(item.url), playerVars : { autoplay : 1, modestbranding : 1, rel : 0, showinfo : 0}, events : { onStateChange : function(e) { - switch(e.data) { + this.youtube = new YT.Player(this.video.id,{ videoId : client_players_Youtube.extractVideoId(item.url), playerVars : { autoplay : 1, modestbranding : 1, rel : 0, showinfo : 0, start : 0}, events : { onReady : function(e) { + return _gthis.isLoaded = true; + }, onStateChange : function(e1) { + switch(e1.data) { case -1: - _gthis.isLoaded = true; _gthis.player.onCanBePlayed(); break; case 0: @@ -1918,7 +1919,9 @@ client_players_Youtube.prototype = { if(this.video == null) { return; } - this.playerEl.removeChild(this.video); + if(this.playerEl.contains(this.video)) { + this.playerEl.removeChild(this.video); + } this.video = null; } ,play: function() { -- cgit v1.2.3