mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
dynamic stream resolution
This commit is contained in:
parent
796d35ed3b
commit
9c44852aa1
@ -6,8 +6,8 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
.stream-box .stream-image {
|
.stream-box .stream-image {
|
||||||
width: 720px;
|
width: 640px;
|
||||||
height: 576px;
|
height: 480px;
|
||||||
border: 1px solid grey;
|
border: 1px solid grey;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="stream-box">
|
<div id="stream-box" class="stream-box">
|
||||||
<img src="/streamer/?action=stream" id="stream-image" class="stream-image" alt="" />
|
<img src="/streamer/?action=stream" id="stream-image" class="stream-image" alt="" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -11,8 +11,9 @@ function runKvmdSession() {
|
|||||||
event = JSON.parse(event.data);
|
event = JSON.parse(event.data);
|
||||||
if (event.msg_type == "event") {
|
if (event.msg_type == "event") {
|
||||||
if (event.msg.event == "atx_state") {
|
if (event.msg.event == "atx_state") {
|
||||||
document.getElementById("power-led").className = "power-led-" + (event.msg.event_attrs.leds.power ? "on" : "off");
|
leds = event.msg.event_attrs.leds;
|
||||||
document.getElementById("hdd-led").className = "hdd-led-" + (event.msg.event_attrs.leds.hdd ? "on" : "off");
|
document.getElementById("power-led").className = "power-led-" + (leds.power ? "on" : "off");
|
||||||
|
document.getElementById("hdd-led").className = "hdd-led-" + (leds.hdd ? "on" : "off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -97,15 +98,36 @@ function pollStreamer() {
|
|||||||
http.open("GET", "/streamer/?action=snapshot", true);
|
http.open("GET", "/streamer/?action=snapshot", true);
|
||||||
http.onreadystatechange = function() {
|
http.onreadystatechange = function() {
|
||||||
if (http.readyState == 2) {
|
if (http.readyState == 2) {
|
||||||
|
var status = http.status;
|
||||||
http.abort();
|
http.abort();
|
||||||
if (http.status != 200) {
|
if (status != 200) {
|
||||||
document.getElementById("stream-image").src = "/streamer/?action=stream&time=" + new Date().getTime();
|
console.log("Refreshing streamer ...");
|
||||||
|
pollStreamer.last = false;
|
||||||
|
} else if (!pollStreamer.last) {
|
||||||
|
__refreshStremaer();
|
||||||
|
pollStreamer.last = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
http.send();
|
http.send();
|
||||||
setTimeout(pollStreamer, 2000);
|
setTimeout(pollStreamer, 2000);
|
||||||
}
|
}
|
||||||
|
pollStreamer.last = false;
|
||||||
|
|
||||||
|
function __refreshStremaer() {
|
||||||
|
var http = new XMLHttpRequest();
|
||||||
|
http.open("GET", "/kvmd/streamer", true);
|
||||||
|
http.onreadystatechange = function() {
|
||||||
|
if (http.readyState == 4 && http.status == 200) {
|
||||||
|
size = JSON.parse(http.responseText).result.size;
|
||||||
|
el_stream_box = document.getElementById("stream-image");
|
||||||
|
el_stream_box.style.width = size.width + "px";
|
||||||
|
el_stream_box.style.height = size.height + "px";
|
||||||
|
document.getElementById("stream-image").src = "/streamer/?action=stream&time=" + new Date().getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
http.send();
|
||||||
|
}
|
||||||
|
|
||||||
function resetStreamer() {
|
function resetStreamer() {
|
||||||
var http = new XMLHttpRequest();
|
var http = new XMLHttpRequest();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user