blob: 6614f9db4a81c4c166c120baad27e9918db8be0a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package client.players;
import Types.PlayerType;
import Types.VideoData;
import Types.VideoDataRequest;
import Types.VideoItem;
import client.Main.ge;
import js.Browser.document;
import js.html.Element;
class Iframe implements IPlayer {
final main:Main;
final player:Player;
final playerEl:Element = ge("#ytapiplayer");
var video:Element;
public function new(main:Main, player:Player) {
this.main = main;
this.player = player;
}
public function getPlayerType():PlayerType {
return IframeType;
}
public function isSupportedLink(url:String):Bool {
return true;
}
public function getVideoData(data:VideoDataRequest, callback:(data:VideoData) -> Void):Void {
final iframe = document.createDivElement();
iframe.innerHTML = data.url.trim();
if (isValidIframe(iframe)) {
callback({duration: 99 * 60 * 60});
} else {
callback({duration: 0});
}
}
function isValidIframe(iframe:Element):Bool {
if (iframe.children.length != 1) return false;
return (iframe.firstChild.nodeName == "IFRAME"
|| iframe.firstChild.nodeName == "OBJECT");
}
public function loadVideo(item:VideoItem):Void {
removeVideo();
video = document.createDivElement();
video.innerHTML = item.url; // actually data
if (!isValidIframe(video)) {
video = null;
return;
}
if (video.firstChild.nodeName == "IFRAME") {
video.setAttribute("sandbox", "allow-scripts");
}
video.firstElementChild.id = "videoplayer";
playerEl.appendChild(video);
}
public function removeVideo():Void {
if (video == null) return;
playerEl.removeChild(video);
video = null;
}
public function isVideoLoaded():Bool {
return video != null;
}
public function play():Void {}
public function pause():Void {}
public function isPaused():Bool {
return false;
}
public function getTime():Float {
return 0;
}
public function setTime(time:Float):Void {}
public function getPlaybackRate():Float {
return 1;
}
public function setPlaybackRate(rate:Float):Void {}
public function getVolume():Float {
return 1;
}
public function setVolume(volume:Float) {}
public function unmute():Void {}
}
|