mirror of
https://github.com/janishutz/MusicPlayer.git
synced 2026-09-10 14:25:24 +02:00
feat: loading local songs, basic association
association used to load existing playlists with local files
This commit is contained in:
@@ -15,16 +15,9 @@ import type {
|
||||
Song
|
||||
} from '@/ts/dtype/playlist';
|
||||
|
||||
export const addSongList = ( songs: Song[], first: boolean = false ) => {
|
||||
if ( first ) {
|
||||
// FIXME: Needs to insert at current index in queue, but where for rawQueue?
|
||||
// Probably at end if shuffled, else insert into queue, then copy
|
||||
rawQueue.value = songs.concat( rawQueue.value );
|
||||
queue.value = songs.concat( queue.value );
|
||||
} else {
|
||||
rawQueue.value = rawQueue.value.concat( songs );
|
||||
queue.value = queue.value.concat( songs );
|
||||
}
|
||||
export const addSongList = ( songs: Song[] ) => {
|
||||
rawQueue.value = rawQueue.value.concat( songs );
|
||||
queue.value = queue.value.concat( songs );
|
||||
};
|
||||
|
||||
export const clearQueue = () => {
|
||||
|
||||
@@ -1,2 +1,47 @@
|
||||
// TODO: If local files contained, prompt user to select files, then associate based on file names
|
||||
export const load = () => {};
|
||||
import {
|
||||
queue,
|
||||
rawQueue,
|
||||
sources
|
||||
} from '../state';
|
||||
import type {
|
||||
AssociationResult
|
||||
} from '../plugins/interface';
|
||||
import type {
|
||||
Playlist
|
||||
} from '@/ts/dtype/playlist';
|
||||
import {
|
||||
openAssociationManager
|
||||
} from '@/composables/associationManager';
|
||||
|
||||
export const load = ( playlist: Playlist ) => {
|
||||
queue.value = playlist;
|
||||
rawQueue.value = playlist;
|
||||
|
||||
let needToLoadLocalSongs = false;
|
||||
|
||||
for ( const song of playlist ) {
|
||||
if ( song['additional-identifier'] ) {
|
||||
needToLoadLocalSongs = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const fileLoader = async ( files: FileList ) => {
|
||||
const associationResults: AssociationResult[] = [];
|
||||
|
||||
for ( const song of playlist ) {
|
||||
const source = sources[song.source]!;
|
||||
|
||||
if ( source.loading.requiresLocalFiles === true ) {
|
||||
associationResults.push( await source.loading.association( files as FileList, song ) );
|
||||
}
|
||||
}
|
||||
|
||||
return associationResults.filter( val => val.match !== 'exact' );
|
||||
};
|
||||
|
||||
if ( needToLoadLocalSongs ) {
|
||||
// FIXME: Combine mime types
|
||||
openAssociationManager( fileLoader, '' );
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user