mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
pikvm/pikvm#1498: Option to suspend stream on inactive tab
This commit is contained in:
parent
a5e226e168
commit
0e3c821863
@ -426,6 +426,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Suspend stream when tab is not active:
|
||||||
|
</td>
|
||||||
|
<td align="right">
|
||||||
|
<div class="switch-box">
|
||||||
|
<input type="checkbox" id="stream-suspend-switch">
|
||||||
|
<label for="stream-suspend-switch"><span class="switch-inner"></span><span class="switch"></span></label>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
@ -112,6 +112,8 @@ li.right#system-dropdown
|
|||||||
+menu_switch_td2("page-close-ask-switch", true, true) Ask page close confirmation:
|
+menu_switch_td2("page-close-ask-switch", true, true) Ask page close confirmation:
|
||||||
tr
|
tr
|
||||||
+menu_switch_td2("page-full-tab-stream-switch", true, false) Expand for the entire tab by default:
|
+menu_switch_td2("page-full-tab-stream-switch", true, false) Expand for the entire tab by default:
|
||||||
|
tr
|
||||||
|
+menu_switch_td2("stream-suspend-switch", true, false) Suspend stream when tab is not active:
|
||||||
|
|
||||||
table.kv
|
table.kv
|
||||||
tr
|
tr
|
||||||
|
|||||||
@ -108,21 +108,31 @@ export function Streamer() {
|
|||||||
tools.el.setOnClick($("stream-screenshot-button"), __clickScreenshotButton);
|
tools.el.setOnClick($("stream-screenshot-button"), __clickScreenshotButton);
|
||||||
tools.el.setOnClick($("stream-reset-button"), __clickResetButton);
|
tools.el.setOnClick($("stream-reset-button"), __clickResetButton);
|
||||||
|
|
||||||
|
tools.storage.bindSimpleSwitch($("stream-suspend-switch"), "stream.suspend", false, __visibilityHook);
|
||||||
|
|
||||||
$("stream-window").show_hook = __visibilityHook;
|
$("stream-window").show_hook = __visibilityHook;
|
||||||
$("stream-window").close_hook = __visibilityHook;
|
$("stream-window").close_hook = __visibilityHook;
|
||||||
$("stream-window").organize_hook = __organizeHook;
|
$("stream-window").organize_hook = __organizeHook;
|
||||||
|
|
||||||
|
document.addEventListener("visibilitychange", __visibilityHook);
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
var __isStreamRequired = function() {
|
var __isStreamRequired = function() {
|
||||||
return wm.isWindowVisible($("stream-window"));
|
return (
|
||||||
|
wm.isWindowVisible($("stream-window"))
|
||||||
|
&& (
|
||||||
|
!$("stream-suspend-switch").checked
|
||||||
|
|| (document.visibilityState === "visible")
|
||||||
|
)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
var __visibilityHook = function() {
|
var __visibilityHook = function() {
|
||||||
let req = __isStreamRequired();
|
let req = __isStreamRequired();
|
||||||
__applyState(req ? __state : null);
|
__applyState(req ? __state : null);
|
||||||
}
|
};
|
||||||
|
|
||||||
var __organizeHook = function() {
|
var __organizeHook = function() {
|
||||||
let geo = self.getGeometry();
|
let geo = self.getGeometry();
|
||||||
@ -180,7 +190,8 @@ export function Streamer() {
|
|||||||
|
|
||||||
var __applyState = function(state) {
|
var __applyState = function(state) {
|
||||||
if (__janus_imported === null) {
|
if (__janus_imported === null) {
|
||||||
alert("__janus_imported is null, please report");
|
// XXX: This warning is triggered by visibilitychange event via the __visibilityHook()
|
||||||
|
// alert("__janus_imported is null, please report");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user