aboutsummaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Player.hx16
-rw-r--r--src/client/players/Iframe.hx23
2 files changed, 33 insertions, 6 deletions
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