fix: stream information update on frameset view

This commit is contained in:
Luis Pereira 2025-11-03 10:44:00 +00:00 committed by Brian O'Reilly
parent aa9a2cf225
commit 4404b416eb
1 changed files with 16 additions and 13 deletions

View File

@ -33,15 +33,8 @@ function changeStreamQuality() {
// Save preference // Save preference
localStorage.setItem('stream-quality', selector.value); localStorage.setItem('stream-quality', selector.value);
// Update UI elements // Update stream information with new selection
document.getElementById('stream-url').textContent = config.url; updateStreamInformation()
document.getElementById('stream-format').textContent = config.format;
// Update Station Status stream quality display
const statusQuality = document.querySelector('[data-text="stream-quality"]');
if (statusQuality) {
statusQuality.textContent = config.format;
}
// Update audio player // Update audio player
const audioElement = document.getElementById('live-audio'); const audioElement = document.getElementById('live-audio');
@ -77,8 +70,8 @@ async function updateNowPlaying() {
} }
} }
// Initialize stream quality display on page load // Update stream information
window.addEventListener('DOMContentLoaded', function() { function updateStreamInformation() {
// Set initial quality display to match the selected stream // Set initial quality display to match the selected stream
const selector = document.getElementById('stream-quality'); const selector = document.getElementById('stream-quality');
const streamBaseUrl = document.getElementById('stream-base-url'); const streamBaseUrl = document.getElementById('stream-base-url');
@ -87,8 +80,8 @@ window.addEventListener('DOMContentLoaded', function() {
selector.value = streamQuality; selector.value = streamQuality;
selector.dispatchEvent(new Event('change')); selector.dispatchEvent(new Event('change'));
} }
if (streamBaseUrl && selector) { if (streamBaseUrl) {
const config = getStreamConfig(streamBaseUrl.value, selector.value); const config = getStreamConfig(streamBaseUrl.value, streamQuality);
document.getElementById('stream-url').textContent = config.url; document.getElementById('stream-url').textContent = config.url;
document.getElementById('stream-format').textContent = config.format; document.getElementById('stream-format').textContent = config.format;
const statusQuality = document.querySelector('[data-text="stream-quality"]'); const statusQuality = document.querySelector('[data-text="stream-quality"]');
@ -96,6 +89,16 @@ window.addEventListener('DOMContentLoaded', function() {
statusQuality.textContent = config.format; statusQuality.textContent = config.format;
} }
} }
}
// Initialize stream quality display on page load
window.addEventListener('DOMContentLoaded', function() {
// Set initial quality display to match the selected stream
updateStreamInformation()
// Periodicaly updates stream information if on frameset.
// This handles changes from the player frame
const isFramesetPage = window.parent !== window.self;
if (isFramesetPage) setInterval(updateStreamInformation, 1000);
// Update playing information right after load // Update playing information right after load
updateNowPlaying(); updateNowPlaying();