diff options
| author | RblSb <msrblsb@gmail.com> | 2021-08-01 14:33:27 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2021-08-01 14:33:27 +0300 |
| commit | b8827aa6df5c58fb5655c8519477ea93694617f3 (patch) | |
| tree | cf67b50990a2864dd8ffe9b094b24241aae48ef3 /res | |
| parent | 530bee28a0baa653e2be73cba525bd38d5e04b5e (diff) | |
Way to change video src on client
see #27
Diffstat (limited to 'res')
| -rw-r--r-- | res/client.js | 40 | ||||
| -rw-r--r-- | res/index.html | 2 | ||||
| -rw-r--r-- | res/langs/en.json | 3 | ||||
| -rw-r--r-- | res/langs/ru.json | 3 |
4 files changed, 48 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; diff --git a/res/index.html b/res/index.html index f070816..92b4f69 100644 --- a/res/index.html +++ b/res/index.html @@ -164,6 +164,8 @@ <div> <h4>${video}</h4> <li><button id="synchThresholdBtn"><span>${synchThreshold}</span></button></li> + <li><button id="setVideoUrlBtn"><span>${setVideoUrl}</span></button></li> + <li><button id="selectLocalVideoBtn"><span>${selectLocalVideo}</span></button></li> <li><button id="removeVideoBtn"><span>${removeVideo}</span></button></li> </div> <div id="adminMenu" style="display: none;"> diff --git a/res/langs/en.json b/res/langs/en.json index e8a9680..a38355a 100644 --- a/res/langs/en.json +++ b/res/langs/en.json @@ -34,6 +34,9 @@ "layout": "Layout", "swapLayout": "Swap Layout", "chatOnly": "Chat Only", + "setVideoUrl": "Set Video URL", + "setVideoUrlPrompt": "New video URL:\n(Does not affect other users)", + "selectLocalVideo": "Select Local Video", "removeVideo": "Remove Video", "addVideo": "Add Video", "toggleUserList": "Show/Hide Userlist", diff --git a/res/langs/ru.json b/res/langs/ru.json index 24f5d34..8228eeb 100644 --- a/res/langs/ru.json +++ b/res/langs/ru.json @@ -34,6 +34,9 @@ "layout": "Разметка", "swapLayout": "Сменить разметку", "chatOnly": "Только чат", + "setVideoUrl": "Задать ссылку на видео", + "setVideoUrlPrompt": "Новая ссылка на видео:\n(Не влияет на других пользователей)", + "selectLocalVideo": "Выбрать локальный видеофайл", "removeVideo": "Удалить видео", "addVideo": "Добавить видео", "toggleUserList": "Показать/Скрыть список юзеров", |
