mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
pikvm/pikvm#1498: refactoring
This commit is contained in:
parent
fe1f821715
commit
a5e226e168
@ -108,13 +108,27 @@ export function Streamer() {
|
||||
tools.el.setOnClick($("stream-screenshot-button"), __clickScreenshotButton);
|
||||
tools.el.setOnClick($("stream-reset-button"), __clickResetButton);
|
||||
|
||||
$("stream-window").show_hook = () => __applyState(__state);
|
||||
$("stream-window").close_hook = () => __applyState(null);
|
||||
$("stream-window").show_hook = __visibilityHook;
|
||||
$("stream-window").close_hook = __visibilityHook;
|
||||
$("stream-window").organize_hook = __organizeHook;
|
||||
};
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
var __isStreamRequired = function() {
|
||||
return wm.isWindowVisible($("stream-window"));
|
||||
};
|
||||
|
||||
var __visibilityHook = function() {
|
||||
let req = __isStreamRequired();
|
||||
__applyState(req ? __state : null);
|
||||
}
|
||||
|
||||
var __organizeHook = function() {
|
||||
let geo = self.getGeometry();
|
||||
wm.setAspectRatio($("stream-window"), geo.width, geo.height);
|
||||
};
|
||||
|
||||
self.ensureDeps = function(callback) {
|
||||
JanusStreamer.ensure_janus(function(avail) {
|
||||
__janus_imported = avail;
|
||||
@ -161,8 +175,7 @@ export function Streamer() {
|
||||
__state = null;
|
||||
__setControlsEnabled(false);
|
||||
}
|
||||
let visible = wm.isWindowVisible($("stream-window"));
|
||||
__applyState((visible && __state && __state.features) ? state : null);
|
||||
__applyState((__isStreamRequired() && __state && __state.features) ? state : null);
|
||||
};
|
||||
|
||||
var __applyState = function(state) {
|
||||
@ -295,11 +308,6 @@ export function Streamer() {
|
||||
el_grab.innerText = el_info.innerText = title;
|
||||
};
|
||||
|
||||
var __organizeHook = function() {
|
||||
let geo = self.getGeometry();
|
||||
wm.setAspectRatio($("stream-window"), geo.width, geo.height);
|
||||
};
|
||||
|
||||
var __resetStream = function(mode=null) {
|
||||
if (mode === null) {
|
||||
mode = __streamer.getMode();
|
||||
@ -324,7 +332,7 @@ export function Streamer() {
|
||||
tools.feature.setEnabled($("stream-audio"), false); // Enabling in stream_janus.js
|
||||
tools.feature.setEnabled($("stream-mic"), false); // Ditto
|
||||
}
|
||||
if (wm.isWindowVisible($("stream-window"))) {
|
||||
if (__isStreamRequired()) {
|
||||
__streamer.ensureStream((__state && __state.streamer !== undefined) ? __state.streamer : null);
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user