mirror of
https://github.com/janishutz/MusicPlayer.git
synced 2026-09-10 14:25:24 +02:00
feat: redesign main page, get player working (mostly) with Apple Music source
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
import {
|
||||
currentSource,
|
||||
isPlaying,
|
||||
queue,
|
||||
queueIdx,
|
||||
rawQueue,
|
||||
shuffle
|
||||
shuffle,
|
||||
sources
|
||||
} from '../state';
|
||||
import {
|
||||
duration,
|
||||
playbackPercentage
|
||||
} from '../status-tracking';
|
||||
import type {
|
||||
Song
|
||||
} from '@/ts/dtype/playlist';
|
||||
@@ -23,6 +30,10 @@ export const addSongList = ( songs: Song[], first: boolean = false ) => {
|
||||
export const clearQueue = () => {
|
||||
queue.value = [];
|
||||
rawQueue.value = [];
|
||||
sources[currentSource.value]?.stop();
|
||||
duration.value = -1;
|
||||
playbackPercentage.value = 1;
|
||||
isPlaying.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
currentSource,
|
||||
isPlaying,
|
||||
queue,
|
||||
queueIdx,
|
||||
repeat,
|
||||
@@ -21,9 +22,15 @@ export const playIndex = async ( idx: number ) => {
|
||||
idx = repeat.value === 'all' ? queue.value.length - 1 : -1;
|
||||
}
|
||||
|
||||
if ( idx < 0 ) return false;
|
||||
|
||||
sources[currentSource.value]?.stop();
|
||||
|
||||
if ( idx < 0 ) {
|
||||
isPlaying.value = false;
|
||||
currentSource.value = '';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
stopTracking();
|
||||
|
||||
const nextSong = queue.value[ idx ]!;
|
||||
@@ -33,4 +40,6 @@ export const playIndex = async ( idx: number ) => {
|
||||
sources[currentSource.value]?.playSong( nextSong.identifier );
|
||||
|
||||
startTracking();
|
||||
|
||||
isPlaying.value = true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user