SkyNX/SkyNX-Streamer/js/main.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-04-16 03:58:28 +00:00
ipcRenderer.on('close', function (event, data) {
$("#startBtn").addClass('btn-dark').removeClass('btn-danger');
$("#startBtn").html("Start Streamer");
running = false;
});
ipcRenderer.on('started', function (event, data) {
$('#startBtn').addClass('btn-danger').removeClass('btn-dark');
$("#startBtn").html("End Streamer");
running = true;
})
var running = false;
function connect() {
ipcRenderer.send('connect', { ip: clientSettings.ip, q: clientSettings.quality });
}
function disconnect() {
ipcRenderer.send('kill');
}
function restart() {
ipcRenderer.send('restart', { ip: clientSettings.ip, q: clientSettings.quality });
}
$('#startBtn').click(function () {
if (!running) {
connect();
} else {
disconnect();
}
});
var qualityChangeTimeout;
$(document).on('input', '#qualitySlider', function () {
$('#qualityLabel').html("Quality: " + $(this).val() + "Mbps");
2020-04-16 03:58:28 +00:00
clientSettings.quality = $(this).val();
saveClientSettings();
if (running) {
clearTimeout(qualityChangeTimeout);
qualityChangeTimeout = setTimeout(restart, 1000)
}
});
$(document).on('input', '#ipInput', function () {
clientSettings.ip = $(this).val();
saveClientSettings();
});