aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/players
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-02-27 20:24:51 +0300
committerRblSb <msrblsb@gmail.com>2020-02-27 20:24:51 +0300
commit8c739fa43946ba8cc5bc6c6226032154b9481a40 (patch)
tree8e112fdf4fe4d9d2fbe851e4bbdce56ec8298d16 /src/client/players
parent2c7811e0c56d5c33ab0138b6dcd281f516bff809 (diff)
Permanent items and player abstraction
Diffstat (limited to 'src/client/players')
-rw-r--r--src/client/players/Raw.hx72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/client/players/Raw.hx b/src/client/players/Raw.hx
new file mode 100644
index 0000000..41b421c
--- /dev/null
+++ b/src/client/players/Raw.hx
@@ -0,0 +1,72 @@
+package client.players;
+
+import haxe.Timer;
+import js.html.Element;
+import js.html.VideoElement;
+import js.Browser.document;
+import client.Main.ge;
+import Types.VideoItem;
+
+class Raw implements IPlayer {
+
+ final main:Main;
+ final player:Player;
+ var video:VideoElement;
+ final playerEl:Element = ge("#ytapiplayer");
+
+ public function new(main:Main, player:Player) {
+ this.main = main;
+ this.player = player;
+ }
+
+ public function loadVideo(item:VideoItem):Void {
+ video = document.createVideoElement();
+ video.id = "videoplayer";
+ final url = main.tryLocalIp(item.url);
+ video.src = url;
+ video.controls = true;
+ final isTouch = untyped __js__("'ontouchstart' in window");
+ if (!isTouch) Timer.delay(() -> {
+ video.controls = false;
+ video.onmouseover = e -> {
+ video.controls = true;
+ video.onmouseover = null;
+ video.onmousemove = null;
+ }
+ video.onmousemove = video.onmouseover;
+ }, 3000);
+ video.oncanplaythrough = player.onCanBePlayed;
+ video.onseeking = player.onSetTime;
+ video.onplay = player.onPlay;
+ video.onpause = player.onPause;
+ playerEl.appendChild(video);
+ video.pause();
+ }
+
+ public function removeVideo():Void {
+ if (video == null) return;
+ playerEl.removeChild(video);
+ video = null;
+ }
+
+ public function play():Void {
+ if (video == null) return;
+ video.play();
+ }
+
+ public function pause():Void {
+ if (video == null) return;
+ video.pause();
+ }
+
+ public function getTime():Float {
+ if (video == null) return 0;
+ return video.currentTime;
+ }
+
+ public function setTime(time:Float):Void {
+ if (video == null) return;
+ video.currentTime = time;
+ }
+
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage