diff options
Diffstat (limited to 'src/client/players/Raw.hx')
| -rw-r--r-- | src/client/players/Raw.hx | 17 |
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"; |
