You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-27 06:23:53 +01:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
const DefaultVolume = 0.5;
|
|
let Stream;
|
|
|
|
function Init(_ev) {
|
|
try {
|
|
const settings = new _3LAS_Settings();
|
|
Stream = new _3LAS(null, settings);
|
|
} catch (error) {
|
|
console.log(error);
|
|
return;
|
|
}
|
|
|
|
Stream.ConnectivityCallback = OnConnectivityCallback;
|
|
$(".playbutton").on('click', OnPlayButtonClick);
|
|
$("#volumeSlider").on("input", updateVolume);
|
|
}
|
|
|
|
function OnConnectivityCallback(isConnected) {
|
|
Stream.Volume = isConnected ? 1.0 : DefaultVolume;
|
|
}
|
|
|
|
function OnPlayButtonClick(_ev) {
|
|
const $playbutton = $('.playbutton');
|
|
$playbutton.find('.fa-solid').toggleClass('fa-play fa-stop');
|
|
try {
|
|
if (Stream.ConnectivityFlag) {
|
|
Stream.Stop();
|
|
} else {
|
|
Stream.Start();
|
|
$playbutton.addClass('bg-gray').prop('disabled', true);
|
|
setTimeout(() => {
|
|
$playbutton.removeClass('bg-gray').prop('disabled', false);
|
|
}, 3000);
|
|
}
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
}
|
|
|
|
function updateVolume() {
|
|
Stream.Volume = $(this).val();
|
|
}
|