diff options
| author | RblSb <msrblsb@gmail.com> | 2020-06-05 16:39:39 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-06-05 16:39:39 +0300 |
| commit | 8506b4edcb0a9bb1973bb38fcca4bcdc21e397c1 (patch) | |
| tree | cbdc7d1d04807df61f15c6ef53b06b3616676f49 /res/client.js | |
| parent | 2c22d551877e262740f524da6e2704bec19b46e7 (diff) | |
More api methods
Diffstat (limited to 'res/client.js')
| -rw-r--r-- | res/client.js | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/res/client.js b/res/client.js index ab6760b..0525b15 100644 --- a/res/client.js +++ b/res/client.js @@ -814,10 +814,20 @@ client_InputWithHistory.prototype = { }; var client_JsApi = function() { }; client_JsApi.__name__ = true; -client_JsApi.addPlugin = $hx_exports["client"]["JsApi"]["addPlugin"] = function(id,onLoaded) { +client_JsApi.init = function(main,player) { + client_JsApi.main = main; + client_JsApi.player = player; client_JsApi.initPluginsSpace(); +}; +client_JsApi.initPluginsSpace = function() { + var w = window; + if(w.synctube == null) { + w.synctube = { }; + } +}; +client_JsApi.addPlugin = $hx_exports["client"]["JsApi"]["addPlugin"] = function(id,onLoaded) { client_JsApi.addScriptToHead("/plugins/" + id + "/index.js",function() { - var obj = { api : client_JsApi, id : id, path : "/plugins/" + id}; + var obj = { api : client.JsApi, id : id, path : "/plugins/" + id}; if(window.synctube[id] == null) { window.console.error("Plugin \"" + id + "\" not found"); } else { @@ -828,12 +838,6 @@ client_JsApi.addPlugin = $hx_exports["client"]["JsApi"]["addPlugin"] = function( } }); }; -client_JsApi.initPluginsSpace = function() { - var w = window; - if(w.synctube == null) { - w.synctube = { }; - } -}; client_JsApi.addScriptToHead = $hx_exports["client"]["JsApi"]["addScriptToHead"] = function(url,onLoaded) { var script = window.document.createElement("script"); script.type = "text/javascript"; @@ -849,6 +853,21 @@ client_JsApi.hasScriptInHead = $hx_exports["client"]["JsApi"]["hasScriptInHead"] } return false; }; +client_JsApi.getTime = $hx_exports["client"]["JsApi"]["getTime"] = function() { + return client_JsApi.player.getTime(); +}; +client_JsApi.setTime = $hx_exports["client"]["JsApi"]["setTime"] = function(time) { + client_JsApi.player.setTime(time); +}; +client_JsApi.isLeader = $hx_exports["client"]["JsApi"]["isLeader"] = function() { + return (client_JsApi.main.personal.group & 2) != 0; +}; +client_JsApi.forceSyncNextTick = $hx_exports["client"]["JsApi"]["forceSyncNextTick"] = function(flag) { + client_JsApi.main.forceSyncNextTick = flag; +}; +client_JsApi.setVideoSrc = $hx_exports["client"]["JsApi"]["setVideoSrc"] = function(src) { + client_JsApi.player.changeVideoSrc(src); +}; client_JsApi.notifyOnVideoChange = $hx_exports["client"]["JsApi"]["notifyOnVideoChange"] = function(func) { client_JsApi.videoChange.push(func); }; @@ -914,6 +933,7 @@ var client_Main = function(host,port) { client_Buttons.initHotkeys(_gthis,_gthis.player); _gthis.openWebSocket(host,port); }); + client_JsApi.init(this,this.player); }; client_Main.__name__ = true; client_Main.main = function() { @@ -1147,7 +1167,7 @@ client_Main.prototype = { var data = JSON.parse(e.data); if(this.config != null && this.config.isVerbose) { var t = data.type; - haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 325, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]}); + haxe_Log.trace("Event: " + data.type,{ fileName : "src/client/Main.hx", lineNumber : 326, className : "client.Main", methodName : "onMessage", customParams : [Reflect.field(data,t.charAt(0).toLowerCase() + HxOverrides.substr(t,1,null))]}); } switch(data.type) { case "AddVideo": @@ -1762,6 +1782,16 @@ client_Player.prototype = { client_JsApi.fireVideoChangeEvents(item); window.document.querySelector("#currenttitle").textContent = item.title; } + ,changeVideoSrc: function(src) { + if(this.player == null) { + return; + } + var item = this.items[this.itemPos]; + if(item == null) { + return; + } + this.player.loadVideo({ url : src, title : item.title, author : item.author, duration : item.duration, isTemp : item.isTemp, isIframe : item.isIframe}); + } ,removeVideo: function() { client_JsApi.fireVideoRemoveEvents(this.items[this.itemPos]); this.player.removeVideo(); |
