fix radio

This commit is contained in:
2025-11-26 01:08:45 +00:00
parent c5da808182
commit cb3487d370

View File

@@ -8,7 +8,8 @@
<script setup> <script setup>
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
const streamUrl = "/radio/stream"; const streamMount = ref("");
const streamUrl = ref("");
const streamLive = ref(false); const streamLive = ref(false);
const audio = ref(null); const audio = ref(null);
@@ -17,12 +18,16 @@ const checkStream = async () => {
const res = await fetch("/radio/status-json.xsl"); // Icecast JSON status const res = await fetch("/radio/status-json.xsl"); // Icecast JSON status
const data = await res.json(); const data = await res.json();
// Replace 'mounts' and '/stream' with your Icecast mountpoint // Replace 'mounts' and '/stream' with your Icecast mountpoint
streamLive.value = !!data.icestats.source.find((src) => streamMount.value = data.icestats.source[0].listenurl.split("/").pop();
src.listenurl.includes(streamUrl),
); if (streamMount.value) {
if (streamLive.value && audio.value) { streamLive.value = true;
streamUrl.value = "/radio/" + streamMount.value;
if (audio.value) {
audio.value.load(); // reload audio if it was offline before audio.value.load(); // reload audio if it was offline before
} }
}
} catch (err) { } catch (err) {
streamLive.value = false; streamLive.value = false;
} }