From ec7e4b5ad120828f1464cf4186287d4928b462a8 Mon Sep 17 00:00:00 2001 From: RblSb Date: Fri, 28 Feb 2020 19:55:32 +0300 Subject: Youtube player support --- src/client/Main.hx | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'src/client/Main.hx') diff --git a/src/client/Main.hx b/src/client/Main.hx index 1804ca1..d3271e9 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -161,7 +161,7 @@ class Main { if (matchName.match(name)) name = matchName.matched(1); else name = Lang.get("rawVideo"); - getRemoteVideoDuration(url, (duration:Float) -> { + player.getRemoteDuration(url, (duration:Float) -> { if (duration == 0) { serverMessage(4, Lang.get("addVideoError")); return; @@ -205,22 +205,6 @@ class Main { return url.replace(globalIp, host); } - function getRemoteVideoDuration(src:String, callback:(duration:Float)->Void):Void { - final player:Element = ge("#ytapiplayer"); - final video = document.createVideoElement(); - video.src = src; - // TODO catch errors on AddVideo and getRemoteVideoDuration - video.onerror = e -> { - if (player.contains(video)) player.removeChild(video); - callback(0); - } - video.onloadedmetadata = () -> { - if (player.contains(video)) player.removeChild(video); - callback(video.duration); - } - Utils.prepend(player, video); - } - function onMessage(e):Void { final data:WsEvent = Json.parse(e.data); final t:String = cast data.type; -- cgit v1.2.3