aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/players/Iframe.hx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/players/Iframe.hx')
-rw-r--r--src/client/players/Iframe.hx23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/client/players/Iframe.hx b/src/client/players/Iframe.hx
index 3268a61..2f875fb 100644
--- a/src/client/players/Iframe.hx
+++ b/src/client/players/Iframe.hx
@@ -24,11 +24,20 @@ class Iframe implements IPlayer {
return true;
}
- public function getVideoData(url:String, callback:(data:VideoData)->Void):Void {
- callback({
- duration: 99 * 60 * 60,
- title: "Custom Media"
- });
+ public function getVideoData(data:String, callback:(data:VideoData)->Void):Void {
+ final iframe = document.createDivElement();
+ iframe.innerHTML = data;
+ 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 {
@@ -36,9 +45,7 @@ class Iframe implements IPlayer {
video = document.createDivElement();
video.id = "videoplayer";
video.innerHTML = item.url; // actually data
- if (video.firstChild.nodeName != "IFRAME"
- && video.firstChild.nodeName != "OBJECT") {
- // TODO move to getVideoData too
+ if (!isValidIframe(video)) {
video = null;
return;
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage