aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/players/Raw.hx
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-02-28 19:55:32 +0300
committerRblSb <msrblsb@gmail.com>2020-02-28 19:55:32 +0300
commitec7e4b5ad120828f1464cf4186287d4928b462a8 (patch)
tree6ea0accbe62983f3f174df9bf9ebc89bec17977a /src/client/players/Raw.hx
parentc5903d5670dad72c840c30a302f8238c8cff9f8a (diff)
Youtube player support
Diffstat (limited to 'src/client/players/Raw.hx')
-rw-r--r--src/client/players/Raw.hx17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/client/players/Raw.hx b/src/client/players/Raw.hx
index 41b421c..1e5d245 100644
--- a/src/client/players/Raw.hx
+++ b/src/client/players/Raw.hx
@@ -11,14 +11,29 @@ class Raw implements IPlayer {
final main:Main;
final player:Player;
- var video:VideoElement;
final playerEl:Element = ge("#ytapiplayer");
+ var video:VideoElement;
public function new(main:Main, player:Player) {
this.main = main;
this.player = player;
}
+ public function getRemoteDuration(src:String, callback:(duration:Float)->Void):Void {
+ final video = document.createVideoElement();
+ video.src = src;
+ // TODO catch errors on AddVideo and getRemoteVideoDuration
+ video.onerror = e -> {
+ if (playerEl.contains(video)) playerEl.removeChild(video);
+ callback(0);
+ }
+ video.onloadedmetadata = () -> {
+ if (playerEl.contains(video)) playerEl.removeChild(video);
+ callback(video.duration);
+ }
+ Utils.prepend(playerEl, video);
+ }
+
public function loadVideo(item:VideoItem):Void {
video = document.createVideoElement();
video.id = "videoplayer";
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage