aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/client.js40
-rw-r--r--res/css/des.css6
-rw-r--r--src/client/Player.hx16
-rw-r--r--src/client/players/Iframe.hx23
4 files changed, 72 insertions, 13 deletions
diff --git a/res/client.js b/res/client.js
index cdfee99..27b5f95 100644
--- a/res/client.js
+++ b/res/client.js
@@ -3021,6 +3021,9 @@ client_Player.prototype = {
if(!this.isLoaded) {
return;
}
+ if(!this.isSyncActive()) {
+ return;
+ }
if(this.videoList.items.length == 0) {
return;
}
@@ -3057,6 +3060,9 @@ client_Player.prototype = {
if(!this.isLoaded) {
return;
}
+ if(!this.isSyncActive()) {
+ return;
+ }
var _this = this.videoList;
var tmp = _this.items[_this.pos];
if(tmp == null) {
@@ -3316,8 +3322,19 @@ client_Player.prototype = {
}
return this.player.isVideoLoaded();
}
- ,play: function() {
+ ,isSyncActive: function() {
if(!this.main.isSyncActive) {
+ return false;
+ }
+ var _this = this.videoList;
+ var tmp = _this.items[_this.pos];
+ if(tmp == null) {
+ return false;
+ }
+ return tmp.playerType != "IframeType";
+ }
+ ,play: function() {
+ if(!this.isSyncActive()) {
return;
}
if(this.player == null) {
@@ -3339,7 +3356,7 @@ client_Player.prototype = {
}
}
,pause: function() {
- if(!this.main.isSyncActive) {
+ if(!this.isSyncActive()) {
return;
}
if(this.player == null) {
@@ -3367,7 +3384,7 @@ client_Player.prototype = {
if(isLocal == null) {
isLocal = true;
}
- if(!this.main.isSyncActive) {
+ if(!this.isSyncActive()) {
return;
}
if(this.player == null) {
@@ -3395,7 +3412,7 @@ client_Player.prototype = {
if(isLocal == null) {
isLocal = true;
}
- if(!this.main.isSyncActive) {
+ if(!this.isSyncActive()) {
return;
}
if(this.player == null) {
@@ -3445,7 +3462,7 @@ client_Player.prototype = {
}
};
http.onError = function(msg) {
- haxe_Log.trace(msg,{ fileName : "src/client/Player.hx", lineNumber : 666, className : "client.Player", methodName : "skipAd"});
+ haxe_Log.trace(msg,{ fileName : "src/client/Player.hx", lineNumber : 674, className : "client.Player", methodName : "skipAd"});
};
http.request();
}
@@ -3765,7 +3782,7 @@ client_players_Iframe.prototype = {
var iframe = window.document.createElement("div");
iframe.innerHTML = StringTools.trim(data.url);
if(this.isValidIframe(iframe)) {
- callback({ duration : 356400});
+ callback({ duration : 356400, title : "Iframe media"});
} else {
callback({ duration : 0});
}
@@ -3783,13 +3800,22 @@ client_players_Iframe.prototype = {
,loadVideo: function(item) {
this.removeVideo();
this.video = window.document.createElement("div");
- this.video.innerHTML = item.url;
+ var data = item.url;
+ if(data.indexOf("player.twitch.tv") != -1) {
+ var hostname = $global.location.hostname;
+ data = StringTools.replace(data,"parent=www.example.com","parent=" + hostname);
+ if(!new EReg("[A-z]","").match(hostname)) {
+ client_Main.instance.serverMessage("Twitch player blocks access from ips, please use SyncTube from any domain for it.\nYou can register some on <a href=\"https://nya.pub\" target=\"_blank\">nya.pub</a>.",false);
+ }
+ }
+ this.video.innerHTML = data;
if(!this.isValidIframe(this.video)) {
this.video = null;
return;
}
if(this.video.firstChild.nodeName == "IFRAME") {
this.video.setAttribute("sandbox","allow-scripts");
+ this.video.classList.add("videoplayerIframeParent");
}
this.video.firstElementChild.id = "videoplayer";
this.playerEl.appendChild(this.video);
diff --git a/res/css/des.css b/res/css/des.css
index fa9a50b..850b53c 100644
--- a/res/css/des.css
+++ b/res/css/des.css
@@ -456,10 +456,16 @@ header h4 {
max-height: 80vh;
}
+.videoplayerIframeParent {
+ width: 100%;
+ height: 100%;
+}
+
iframe#videoplayer {
width: 100%;
height: 100%;
aspect-ratio: 16 / 9;
+ position: unset !important;
}
@media only screen and (orientation: portrait) {
diff --git a/src/client/Player.hx b/src/client/Player.hx
index 9b22748..cafb572 100644
--- a/src/client/Player.hx
+++ b/src/client/Player.hx
@@ -278,6 +278,7 @@ class Player {
public function onPlay():Void {
audioTrack?.play();
if (!isLoaded) return;
+ if (!isSyncActive()) return;
if (videoList.length == 0) return;
final hasAutoPause = main.hasLeaderOnPauseRequest();
@@ -317,6 +318,7 @@ class Player {
audioTrack?.pause();
if (!isLoaded) return;
+ if (!isSyncActive()) return;
final item = videoList.currentItem ?? return;
// do not send pause if video is ended
if (getTime() >= item.duration - 0.01) return;
@@ -579,8 +581,14 @@ class Player {
return player.isVideoLoaded();
}
+ function isSyncActive():Bool {
+ if (!main.isSyncActive) return false;
+ final item = videoList.currentItem ?? return false;
+ return item.playerType != IframeType;
+ }
+
public function play():Void {
- if (!main.isSyncActive) return;
+ if (!isSyncActive()) return;
if (player == null) return;
if (!player.isVideoLoaded()) return;
player.play();
@@ -593,7 +601,7 @@ class Player {
}
public function pause():Void {
- if (!main.isSyncActive) return;
+ if (!isSyncActive()) return;
if (player == null) return;
if (!player.isVideoLoaded()) return;
player.pause();
@@ -608,7 +616,7 @@ class Player {
}
public function setTime(time:Float, isLocal = true):Void {
- if (!main.isSyncActive) return;
+ if (!isSyncActive()) return;
if (player == null) return;
if (!player.isVideoLoaded()) return;
skipSetTime = isLocal;
@@ -624,7 +632,7 @@ class Player {
}
public function setPlaybackRate(rate:Float, isLocal = true):Void {
- if (!main.isSyncActive) return;
+ if (!isSyncActive()) return;
if (player == null) return;
if (!player.isVideoLoaded()) return;
skipSetRate = isLocal;
diff --git a/src/client/players/Iframe.hx b/src/client/players/Iframe.hx
index 000bf8a..9c24aed 100644
--- a/src/client/players/Iframe.hx
+++ b/src/client/players/Iframe.hx
@@ -6,6 +6,7 @@ import Types.VideoDataRequest;
import Types.VideoItem;
import client.Main.getEl;
import js.Browser.document;
+import js.Browser;
import js.html.Element;
class Iframe implements IPlayer {
@@ -31,7 +32,10 @@ class Iframe implements IPlayer {
final iframe = document.createDivElement();
iframe.innerHTML = data.url.trim();
if (isValidIframe(iframe)) {
- callback({duration: 99 * 60 * 60});
+ callback({
+ duration: 99 * 60 * 60,
+ title: "Iframe media",
+ });
} else {
callback({duration: 0});
}
@@ -46,13 +50,28 @@ class Iframe implements IPlayer {
public function loadVideo(item:VideoItem):Void {
removeVideo();
video = document.createDivElement();
- video.innerHTML = item.url; // actually data
+ var data = item.url;
+
+ if (data.contains("player.twitch.tv")) {
+ final hostname = Browser.location.hostname;
+ data = data.replace("parent=www.example.com", 'parent=$hostname');
+ if (!~/[A-z]/.match(hostname)) {
+ Main.instance.serverMessage(
+ 'Twitch player blocks access from ips, please use SyncTube from any domain for it.
+You can register some on <a href="https://nya.pub" target="_blank">nya.pub</a>.',
+ false
+ );
+ }
+ }
+
+ video.innerHTML = data;
if (!isValidIframe(video)) {
video = null;
return;
}
if (video.firstChild.nodeName == "IFRAME") {
video.setAttribute("sandbox", "allow-scripts");
+ video.classList.add("videoplayerIframeParent");
}
video.firstElementChild.id = "videoplayer";
playerEl.appendChild(video);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage