Skip to content

Commit

Permalink
Merge pull request #724 from Nyabsi/feat/folder-import
Browse files Browse the repository at this point in the history
implement openAudioFoldersAndAddToQueue
  • Loading branch information
Geoxor authored Oct 8, 2024
2 parents c78a488 + debd9a1 commit 2caebab
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/renderer/amethyst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,24 @@ class AmethystBackend {
};

public openAudioFoldersAndAddToQueue = async () => {
// amethyst.showOpenFolderDialog().then(result => {
// !result.canceled && amethyst.player.queue.add(flattenArray(result.filePaths));
// }).catch(error => console.error(error));
amethyst.showOpenFolderDialog().then(async (result) => {
if (!result.canceled) {
let files = await window.fs.readdir(result.filePaths[0]);
for (let idx in files) {
let found = false;
for (let extension of ALLOWED_AUDIO_EXTENSIONS) {
if (files[idx].endsWith(extension)) {
found = true;
files[idx] = window.path.join(result.filePaths[0], files[idx]);
}
}
if (!found) {
files.splice(parseInt(idx), 1);
}
}
amethyst.player.queue.add(files);
}
}).catch(error => console.error(error));
};
}

Expand Down

0 comments on commit 2caebab

Please sign in to comment.