mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-07-30 08:49:16 +02:00
audioonly
This commit is contained in:
+8
-4
@@ -91,6 +91,10 @@ router.get('/403', (req, res) => {
|
|||||||
res.render('403', { reason });
|
res.render('403', { reason });
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.get('/audioonly', (req, res) => {
|
||||||
|
res.render('audioonly');
|
||||||
|
})
|
||||||
|
|
||||||
router.get('/wizard', (req, res) => {
|
router.get('/wizard', (req, res) => {
|
||||||
let serialPorts;
|
let serialPorts;
|
||||||
|
|
||||||
@@ -382,13 +386,13 @@ function canLog(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
router.get('/log_fmlist', (req, res) => {
|
router.get('/log_fmlist', (req, res) => {
|
||||||
if (dataHandler.dataToSend.txInfo.tx.length === 0) {
|
if (serverConfig.extras.fmlistIntegration === false || (serverConfig.extras.fmlistAdminOnly && !req.session.isTuneAuthenticated)) {
|
||||||
res.status(500).send('No suitable transmitter to log.');
|
res.status(500).send('FMLIST Integration is not available.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverConfig.extras.fmlistIntegration === false || (serverConfig.extras.fmlistAdminOnly && !req.session.isTuneAuthenticated)) {
|
if (dataHandler.dataToSend.txInfo.tx.length === 0) {
|
||||||
res.status(500).send('FMLIST Integration is not available.');
|
res.status(500).send('No suitable transmitter to log.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -319,7 +319,7 @@ wss.on('connection', (ws, request) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clientIp !== '::ffff:127.0.0.1' ||
|
if (clientIp !== '127.0.0.1' ||
|
||||||
(request.socket && request.socket.remoteAddress && request.socket.remoteAddress !== '::ffff:127.0.0.1') ||
|
(request.socket && request.socket.remoteAddress && request.socket.remoteAddress !== '::ffff:127.0.0.1') ||
|
||||||
(request.headers && request.headers['origin'] && request.headers['origin'].trim() !== '')) {
|
(request.headers && request.headers['origin'] && request.headers['origin'].trim() !== '')) {
|
||||||
currentUsers++;
|
currentUsers++;
|
||||||
@@ -392,7 +392,6 @@ wss.on('connection', (ws, request) => {
|
|||||||
const isLocalIp = (
|
const isLocalIp = (
|
||||||
clientIp === '127.0.0.1' ||
|
clientIp === '127.0.0.1' ||
|
||||||
clientIp === '::1' ||
|
clientIp === '::1' ||
|
||||||
clientIp === '::ffff:127.0.0.1' ||
|
|
||||||
clientIp.startsWith('192.168.') ||
|
clientIp.startsWith('192.168.') ||
|
||||||
clientIp.startsWith('10.') ||
|
clientIp.startsWith('10.') ||
|
||||||
clientIp.startsWith('172.16.')
|
clientIp.startsWith('172.16.')
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FM-DX Webserver (Audio)</title>
|
||||||
|
<link rel="icon" type="image/svg+xml" href="favicon.svg" id="favicon" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<script src="js/audio.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<button class="playbutton">start</button>
|
||||||
|
<input type="range" id="volumeSlider" min="0" max="1" step="0.01" value="1">
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -539,9 +539,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-panel-footer flex-container flex-phone">
|
<div class="modal-panel-footer flex-container flex-phone">
|
||||||
<div class="modal-panel-sidebar" style="font-size: 22px;">
|
<div class="modal-panel-sidebar" style="font-size: 22px;">
|
||||||
<div class="flex-center" style="height: 50px">
|
|
||||||
<i class="fa-solid fa-hand-holding-medical"></i>
|
|
||||||
</div>
|
|
||||||
<div class="flex-center" style="height: 50px">
|
<div class="flex-center" style="height: 50px">
|
||||||
<i class="fa-brands fa-discord"></i>
|
<i class="fa-brands fa-discord"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+3
-4
@@ -77,8 +77,7 @@ function Init(_ev) {
|
|||||||
function createStream() {
|
function createStream() {
|
||||||
try {
|
try {
|
||||||
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
const audioUrl = `${wsProtocol}//${location.hostname}/audio`;
|
Stream = new WebSocketAudioPlayer(`${wsProtocol}//${location.hostname}/audio`);
|
||||||
Stream = new WebSocketAudioPlayer(audioUrl);
|
|
||||||
Stream.setVolume($('#volumeSlider').val());
|
Stream.setVolume($('#volumeSlider').val());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Initialization Error: ", error);
|
console.error("Initialization Error: ", error);
|
||||||
@@ -100,14 +99,14 @@ function OnPlayButtonClick(_ev) {
|
|||||||
console.log("Stopping stream...");
|
console.log("Stopping stream...");
|
||||||
shouldReconnect = false;
|
shouldReconnect = false;
|
||||||
destroyStream();
|
destroyStream();
|
||||||
$playbutton.find('.fa-solid').toggleClass('fa-stop fa-play');
|
$playbutton.find('.fa-solid')?.toggleClass('fa-stop fa-play');
|
||||||
if (isAppleiOS && 'audioSession' in navigator) navigator.audioSession.type = "none";
|
if (isAppleiOS && 'audioSession' in navigator) navigator.audioSession.type = "none";
|
||||||
} else {
|
} else {
|
||||||
console.log("Starting stream...");
|
console.log("Starting stream...");
|
||||||
shouldReconnect = true;
|
shouldReconnect = true;
|
||||||
createStream();
|
createStream();
|
||||||
Stream.start();
|
Stream.start();
|
||||||
$playbutton.find('.fa-solid').toggleClass('fa-play fa-stop');
|
$playbutton.find('.fa-solid')?.toggleClass('fa-play fa-stop');
|
||||||
if (isAppleiOS && 'audioSession' in navigator) navigator.audioSession.type = "playback";
|
if (isAppleiOS && 'audioSession' in navigator) navigator.audioSession.type = "playback";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user