first step
This commit is contained in:
@@ -7,7 +7,8 @@ let currentIndex = 0;
|
||||
let isPlaying = false;
|
||||
let currentMode = 'local'; // 'local' | 'cast'
|
||||
let currentCastDevice = null;
|
||||
const audio = new Audio();
|
||||
|
||||
// Local playback is handled natively by the Tauri backend (player_* commands).
|
||||
|
||||
// UI Elements
|
||||
const stationNameEl = document.getElementById('station-name');
|
||||
@@ -146,10 +147,10 @@ async function play() {
|
||||
statusDotEl.style.backgroundColor = 'var(--text-muted)'; // Grey/Yellow while loading
|
||||
|
||||
if (currentMode === 'local') {
|
||||
audio.src = station.url;
|
||||
audio.volume = volumeSlider.value / 100;
|
||||
try {
|
||||
await audio.play();
|
||||
const vol = volumeSlider.value / 100;
|
||||
await invoke('player_set_volume', { volume: vol }).catch(() => {});
|
||||
await invoke('player_play', { url: station.url });
|
||||
isPlaying = true;
|
||||
updateUI();
|
||||
} catch (e) {
|
||||
@@ -176,8 +177,11 @@ async function play() {
|
||||
|
||||
async function stop() {
|
||||
if (currentMode === 'local') {
|
||||
audio.pause();
|
||||
audio.src = '';
|
||||
try {
|
||||
await invoke('player_stop');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
} else if (currentMode === 'cast' && currentCastDevice) {
|
||||
try {
|
||||
await invoke('cast_stop', { deviceName: currentCastDevice });
|
||||
@@ -243,7 +247,7 @@ function handleVolumeInput() {
|
||||
const decimals = val / 100;
|
||||
|
||||
if (currentMode === 'local') {
|
||||
audio.volume = decimals;
|
||||
invoke('player_set_volume', { volume: decimals }).catch(() => {});
|
||||
} else if (currentMode === 'cast' && currentCastDevice) {
|
||||
invoke('cast_set_volume', { deviceName: currentCastDevice, volume: decimals });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user