aboutsummaryrefslogtreecommitdiffstats
path: root/res/client.js
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2021-08-01 14:33:27 +0300
committerRblSb <msrblsb@gmail.com>2021-08-01 14:33:27 +0300
commitb8827aa6df5c58fb5655c8519477ea93694617f3 (patch)
treecf67b50990a2864dd8ffe9b094b24241aae48ef3 /res/client.js
parent530bee28a0baa653e2be73cba525bd38d5e04b5e (diff)
Way to change video src on client
see #27
Diffstat (limited to 'res/client.js')
-rw-r--r--res/client.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/res/client.js b/res/client.js
index a11e3a6..cd1c21e 100644
--- a/res/client.js
+++ b/res/client.js
@@ -744,6 +744,19 @@ client_Buttons.initTextButtons = function(main) {
return removeBtn.innerText = Lang.get("addVideo");
}
};
+ window.document.querySelector("#setVideoUrlBtn").onclick = function(e) {
+ var src = window.prompt(Lang.get("setVideoUrlPrompt"));
+ if(StringTools.trim(src) == "") {
+ main.refreshPlayer();
+ return;
+ }
+ client_JsApi.setVideoSrc(src);
+ };
+ window.document.querySelector("#selectLocalVideoBtn").onclick = function(e) {
+ client_Utils.browseFileUrl(function(url,name) {
+ client_JsApi.setVideoSrc(url);
+ });
+ };
};
client_Buttons.initHotkeys = function(main,player) {
window.document.querySelector("#mediarefresh").title += " (Alt-R)";
@@ -2454,6 +2467,33 @@ client_Utils.copyToClipboard = function(text) {
window.document.body.removeChild(textarea);
}
};
+client_Utils.browseFileUrl = function(onFileLoad,isBinary,revoke) {
+ if(revoke == null) {
+ revoke = false;
+ }
+ if(isBinary == null) {
+ isBinary = true;
+ }
+ var input = window.document.createElement("input");
+ input.style.visibility = "hidden";
+ input.setAttribute("type","file");
+ input.id = "browse";
+ input.onclick = function(e) {
+ e.cancelBubble = true;
+ e.stopPropagation();
+ };
+ input.onchange = function() {
+ var file = input.files[0];
+ var url = URL.createObjectURL(file);
+ onFileLoad(url,file.name);
+ window.document.body.removeChild(input);
+ if(revoke) {
+ URL.revokeObjectURL(url);
+ }
+ };
+ window.document.body.appendChild(input);
+ input.click();
+};
var client_players_Iframe = function(main,player) {
this.playerEl = window.document.querySelector("#ytapiplayer");
this.main = main;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage