fix radio
This commit is contained in:
@@ -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,11 +18,15 @@ 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;
|
||||||
audio.value.load(); // reload audio if it was offline before
|
streamUrl.value = "/radio/" + streamMount.value;
|
||||||
|
|
||||||
|
if (audio.value) {
|
||||||
|
audio.value.load(); // reload audio if it was offline before
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
streamLive.value = false;
|
streamLive.value = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user