aboutsummaryrefslogtreecommitdiffstats
path: root/res/client.js
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-04-26 02:39:46 +0300
committerRblSb <msrblsb@gmail.com>2020-04-26 02:39:46 +0300
commit3c5fda212a8b895027c3853d9979b12a8f6c5798 (patch)
tree5a0fb8c332cc5f1eba3b54e65fbebf2242585a0a /res/client.js
parent40589f8e8ee75485ba241777f3b26cd35d8a05ea (diff)
Fix some issues with reused players
Diffstat (limited to 'res/client.js')
-rw-r--r--res/client.js127
1 files changed, 64 insertions, 63 deletions
diff --git a/res/client.js b/res/client.js
index 2f9b418..8161f26 100644
--- a/res/client.js
+++ b/res/client.js
@@ -730,8 +730,14 @@ client_Buttons.initNavBar = function(main) {
var swapLayoutBtn = window.document.querySelector("#swapLayoutBtn");
swapLayoutBtn.onclick = function(e5) {
var p = window.document.querySelector("#main");
- p.insertBefore(p.children[2],p.children[0]);
- p.insertBefore(p.children[2],p.children[1]);
+ if(window.document.querySelector("#main").firstElementChild == window.document.querySelector("#chatwrap")) {
+ p.appendChild(p.removeChild(p.children[1]));
+ p.appendChild(p.removeChild(p.children[0]));
+ p.appendChild(p.removeChild(p.children[1]));
+ } else {
+ p.insertBefore(p.children[2],p.children[0]);
+ p.insertBefore(p.children[2],p.children[1]);
+ }
var p1 = window.document.querySelector("#controlsrow");
p1.insertBefore(p1.children[1],p1.children[0]);
var p2 = window.document.querySelector("#playlistrow");
@@ -1647,7 +1653,6 @@ var client_Player = function(main) {
this.skipSetTime = false;
this.isLoaded = false;
this.itemPos = 0;
- this.currentSrc = "";
this.playerEl = window.document.querySelector("#ytapiplayer");
this.videoItemsEl = window.document.querySelector("#queue");
this.items = _$VideoList_VideoList_$Impl_$._new();
@@ -1727,7 +1732,6 @@ client_Player.prototype = {
}
this.itemPos = i;
childs[this.itemPos].classList.add("queue_active");
- this.currentSrc = item.url;
this.isLoaded = false;
this.player.loadVideo(item);
client_JsApi.fireVideoChangeEvents(item);
@@ -1735,7 +1739,6 @@ client_Player.prototype = {
}
,removeVideo: function() {
client_JsApi.fireVideoRemoveEvents(this.items[this.itemPos]);
- this.currentSrc = "";
this.player.removeVideo();
window.document.querySelector("#currenttitle").textContent = Lang.get("nothingPlaying");
}
@@ -1852,6 +1855,7 @@ client_Player.prototype = {
return this.items;
}
,setItems: function(list,pos) {
+ var currentUrl = this.itemPos >= this.items.length ? "" : this.items[this.itemPos].url;
this.clearItems();
if(pos != null) {
this.itemPos = pos;
@@ -1861,7 +1865,7 @@ client_Player.prototype = {
}
var _g = 0;
while(_g < list.length) this.addVideoItem(list[_g++],true);
- if(this.currentSrc != this.items[this.itemPos].url) {
+ if(currentUrl != this.items[this.itemPos].url) {
this.setVideo(this.itemPos);
} else {
this.videoItemsEl.children[this.itemPos].classList.add("queue_active");
@@ -1920,6 +1924,12 @@ client_Player.prototype = {
,hasVideo: function() {
return this.playerEl.children.length != 0;
}
+ ,getDuration: function() {
+ if(this.itemPos >= this.items.length) {
+ return 0;
+ }
+ return this.items[this.itemPos].duration;
+ }
,play: function() {
if(!this.main.isSyncActive) {
return;
@@ -1927,6 +1937,9 @@ client_Player.prototype = {
if(this.player == null) {
return;
}
+ if(!this.player.isVideoLoaded()) {
+ return;
+ }
this.player.play();
}
,pause: function() {
@@ -1936,18 +1949,18 @@ client_Player.prototype = {
if(this.player == null) {
return;
}
- this.player.pause();
- }
- ,getDuration: function() {
- if(this.itemPos >= this.items.length) {
- return 0;
+ if(!this.player.isVideoLoaded()) {
+ return;
}
- return this.items[this.itemPos].duration;
+ this.player.pause();
}
,getTime: function() {
if(this.player == null) {
return 0;
}
+ if(!this.player.isVideoLoaded()) {
+ return 0;
+ }
return this.player.getTime();
}
,setTime: function(time,isLocal) {
@@ -1960,6 +1973,9 @@ client_Player.prototype = {
if(this.player == null) {
return;
}
+ if(!this.player.isVideoLoaded()) {
+ return;
+ }
this.skipSetTime = isLocal;
this.player.setTime(time);
}
@@ -1967,6 +1983,9 @@ client_Player.prototype = {
if(this.player == null) {
return 1;
}
+ if(!this.player.isVideoLoaded()) {
+ return 1;
+ }
return this.player.getPlaybackRate();
}
,setPlaybackRate: function(rate,isLocal) {
@@ -1979,6 +1998,9 @@ client_Player.prototype = {
if(this.player == null) {
return;
}
+ if(!this.player.isVideoLoaded()) {
+ return;
+ }
this.skipSetRate = isLocal;
this.player.setPlaybackRate(rate);
}
@@ -2132,6 +2154,9 @@ client_players_Iframe.prototype = {
this.playerEl.removeChild(this.video);
this.video = null;
}
+ ,isVideoLoaded: function() {
+ return this.video != null;
+ }
,play: function() {
}
,pause: function() {
@@ -2190,20 +2215,36 @@ client_players_Raw.prototype = {
var url = this.main.tryLocalIp(item.url);
if(this.video != null) {
this.video.src = url;
+ this.restartControlsHider();
return;
}
this.video = window.document.createElement("video");
this.video.id = "videoplayer";
this.video.src = url;
+ this.restartControlsHider();
+ this.video.oncanplaythrough = ($_=this.player,$bind($_,$_.onCanBePlayed));
+ this.video.onseeking = ($_=this.player,$bind($_,$_.onSetTime));
+ this.video.onplay = function(e) {
+ _gthis.playAllowed = true;
+ _gthis.player.onPlay();
+ return;
+ };
+ this.video.onpause = ($_=this.player,$bind($_,$_.onPause));
+ this.video.onratechange = ($_=this.player,$bind($_,$_.onRateChange));
+ this.playerEl.appendChild(this.video);
+ }
+ ,restartControlsHider: function() {
+ var _gthis = this;
+ if(client_Utils.isTouch()) {
+ return;
+ }
this.video.controls = true;
if(this.controlsHider != null) {
this.controlsHider.stop();
}
- if(!client_Utils.isTouch()) {
- this.controlsHider = haxe_Timer.delay(function() {
- return _gthis.video.controls = false;
- },3000);
- }
+ this.controlsHider = haxe_Timer.delay(function() {
+ return _gthis.video.controls = false;
+ },3000);
this.video.onmousemove = function(e) {
if(_gthis.controlsHider != null) {
_gthis.controlsHider.stop();
@@ -2211,16 +2252,6 @@ client_players_Raw.prototype = {
_gthis.video.controls = true;
return _gthis.video.onmousemove = null;
};
- this.video.oncanplaythrough = ($_=this.player,$bind($_,$_.onCanBePlayed));
- this.video.onseeking = ($_=this.player,$bind($_,$_.onSetTime));
- this.video.onplay = function(e1) {
- _gthis.playAllowed = true;
- _gthis.player.onPlay();
- return;
- };
- this.video.onpause = ($_=this.player,$bind($_,$_.onPause));
- this.video.onratechange = ($_=this.player,$bind($_,$_.onRateChange));
- this.playerEl.appendChild(this.video);
}
,removeVideo: function() {
if(this.video == null) {
@@ -2229,11 +2260,11 @@ client_players_Raw.prototype = {
this.playerEl.removeChild(this.video);
this.video = null;
}
+ ,isVideoLoaded: function() {
+ return this.video != null;
+ }
,play: function() {
var _gthis = this;
- if(this.video == null) {
- return;
- }
if(!this.playAllowed) {
return;
}
@@ -2246,33 +2277,18 @@ client_players_Raw.prototype = {
});
}
,pause: function() {
- if(this.video == null) {
- return;
- }
this.video.pause();
}
,getTime: function() {
- if(this.video == null) {
- return 0;
- }
return this.video.currentTime;
}
,setTime: function(time) {
- if(this.video == null) {
- return;
- }
this.video.currentTime = time;
}
,getPlaybackRate: function() {
- if(this.video == null) {
- return 1;
- }
return this.video.playbackRate;
}
,setPlaybackRate: function(rate) {
- if(this.video == null) {
- return;
- }
this.video.playbackRate = rate;
}
};
@@ -2502,40 +2518,25 @@ client_players_Youtube.prototype = {
}
this.video = null;
}
+ ,isVideoLoaded: function() {
+ return this.isLoaded;
+ }
,play: function() {
- if(!this.isLoaded) {
- return;
- }
this.youtube.playVideo();
}
,pause: function() {
- if(!this.isLoaded) {
- return;
- }
this.youtube.pauseVideo();
}
,getTime: function() {
- if(!this.isLoaded) {
- return 0;
- }
return this.youtube.getCurrentTime();
}
,setTime: function(time) {
- if(!this.isLoaded) {
- return;
- }
this.youtube.seekTo(time,true);
}
,getPlaybackRate: function() {
- if(!this.isLoaded) {
- return 1;
- }
return this.youtube.getPlaybackRate();
}
,setPlaybackRate: function(rate) {
- if(!this.isLoaded) {
- return;
- }
this.youtube.setPlaybackRate(rate);
}
};
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage