feat: basic player commands

This commit is contained in:
2026-08-30 19:58:08 +02:00
parent ce35371c06
commit 5b223875bd
11 changed files with 196 additions and 2 deletions
+14
View File
@@ -0,0 +1,14 @@
import type {
Song
} from '@/ts/dtype/playlist';
import {
queue
} from '../state';
export const addSongList = ( songs: Song[] ) => {
for ( const song of songs ) {
queue.value.push( song );
}
};
export const shuffleList = () => {};
+36
View File
@@ -0,0 +1,36 @@
import {
currentSource,
queue,
queueIdx,
repeat,
sources
} from '../state';
import {
startTracking,
stopTracking
} from '../status-tracking';
/**
* Play a song at the given index of the queue. Wraps to 0 and end if index below 0 or above end
* @param idx - The index in the queue to play at
*/
export const playIndex = async ( idx: number ) => {
if ( idx >= queue.value.length ) {
idx = repeat.value === 'all' ? 0 : -1;
} else if ( idx < 0 ) {
idx = repeat.value === 'all' ? queue.value.length - 1 : -1;
}
if ( idx < 0 ) return false;
sources[currentSource.value]?.stop();
stopTracking();
const nextSong = queue.value[ idx ]!;
queueIdx.value = idx;
currentSource.value = nextSong.source;
sources[currentSource.value]?.playSong( nextSong.identifier );
startTracking();
};
+2
View File
@@ -0,0 +1,2 @@
// TODO: If local files contained, prompt user to select files, then associate based on file names
export const load = () => {};