diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/JsApi.hx | 26 | ||||
| -rw-r--r-- | src/client/Player.hx | 2 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/client/JsApi.hx b/src/client/JsApi.hx index 810e2f2..2df9c57 100644 --- a/src/client/JsApi.hx +++ b/src/client/JsApi.hx @@ -5,18 +5,18 @@ import js.Browser.document; private typedef VideoChangeFunc = (item:VideoItem)->Void; - class JsApi { static final videoChange:Array<VideoChangeFunc> = []; + static final videoRemove:Array<VideoChangeFunc> = []; @:expose - public static function addPlugin(id:String, ?onLoaded:()->Void):Void { + static function addPlugin(id:String, ?onLoaded:()->Void):Void { addScriptToHead('/plugins/$id/index.js', onLoaded); } @:expose - public static function addScriptToHead(url:String, ?onLoaded:()->Void):Void { + static function addScriptToHead(url:String, ?onLoaded:()->Void):Void { var script = document.createScriptElement(); script.type = "text/javascript"; script.onload = onLoaded; @@ -25,7 +25,7 @@ class JsApi { } @:expose - public static function hasScriptInHead(url:String):Bool { + static function hasScriptInHead(url:String):Bool { for (child in document.getElementsByTagName("head")[0].children) { if ((child : Dynamic).src == url) return true; } @@ -33,12 +33,12 @@ class JsApi { } @:expose - public static function notifyOnVideoChange(func:VideoChangeFunc):Void { + static function notifyOnVideoChange(func:VideoChangeFunc):Void { videoChange.push(func); } @:expose - public static function removeFromVideoChange(func:VideoChangeFunc):Void { + static function removeFromVideoChange(func:VideoChangeFunc):Void { videoChange.remove(func); } @@ -46,4 +46,18 @@ class JsApi { for (func in videoChange) func(item); } + @:expose + static function notifyOnVideoRemove(func:VideoChangeFunc):Void { + videoRemove.push(func); + } + + @:expose + static function removeFromVideoRemove(func:VideoChangeFunc):Void { + videoRemove.remove(func); + } + + public static function fireVideoRemoveEvents(item:VideoItem):Void { + for (func in videoRemove) func(item); + } + } diff --git a/src/client/Player.hx b/src/client/Player.hx index 780f8cc..d4ed854 100644 --- a/src/client/Player.hx +++ b/src/client/Player.hx @@ -90,6 +90,7 @@ class Player { function setPlayer(newPlayer:IPlayer):Void { if (player != null && player != newPlayer) { + JsApi.fireVideoRemoveEvents(items[itemPos]); player.removeVideo(); // playerEl.textContent = ""; } @@ -125,6 +126,7 @@ class Player { } public function removeVideo():Void { + JsApi.fireVideoRemoveEvents(items[itemPos]); currentSrc = ""; player.removeVideo(); ge("#currenttitle").textContent = Lang.get("nothingPlaying"); |
