Skip to content

Commit

Permalink
Merge pull request #6 from DanielPower/fix-file-paths
Browse files Browse the repository at this point in the history
Fix file paths on non-Windows systems
  • Loading branch information
CaptSiro authored Sep 30, 2024
2 parents c053821 + 3795888 commit 1e889fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
24 changes: 11 additions & 13 deletions src/renderer/src/lib/Music.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const player = new Audio();



const [media, setMedia] = createSignal<URL>();
const [media, setMedia] = createSignal<string>();



Expand Down Expand Up @@ -86,7 +86,7 @@ export { isPlaying }



async function getCurrent(): Promise<{ song: Song, media: URL } | undefined> {
async function getCurrent(): Promise<{ song: Song, media: string } | undefined> {
const song = await window.api.request("queue::current");

if (song.isNone) {
Expand All @@ -99,11 +99,9 @@ async function getCurrent(): Promise<{ song: Song, media: URL } | undefined> {
return;
}

const media = new URL(resource.value);

return {
song: song.value,
media
media: resource.value
};
}

Expand All @@ -122,8 +120,8 @@ export async function play(): Promise<void> {

const m = media();

if (m !== undefined && player.src !== m.href) {
player.src = m.href;
if (m !== undefined && player.src !== m) {
player.src = m;
}

player.volume = calculateVolume();
Expand All @@ -148,7 +146,7 @@ export async function next() {
return;
}

player.src = current.media.href;
player.src = current.media;
setMedia(current.media);

if (isPlaying() === true) {
Expand All @@ -167,7 +165,7 @@ export async function previous() {
return;
}

player.src = current.media.href;
player.src = current.media;
setMedia(current.media);

if (isPlaying() === true) {
Expand Down Expand Up @@ -229,7 +227,7 @@ createEffect(() => {



const [writeVolume, ] = delay(async (volume: number) => {
const [writeVolume,] = delay(async (volume: number) => {
await window.api.request("settings::write", "volume", volume);
}, 200);
createEffect(async () => {
Expand Down Expand Up @@ -264,15 +262,15 @@ window.api.listen("queue::songChanged", async (s) => {
return;
}

setMedia(new URL(resource.value));
setMedia(resource.value);
setSong(s);
await play();
});



player.addEventListener("ended", async () => {
await next();
await next();
});

const OFFSET = 0;
Expand Down Expand Up @@ -307,5 +305,5 @@ function currentBPM(offset: number, changes: number[][]): Optional<number> {
}
}

return some(msToBPM(changes[changes.length - 1][BPM]));
return some(msToBPM(changes[changes.length - 1][BPM]));
}
2 changes: 1 addition & 1 deletion src/renderer/src/lib/tungsten/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getResourcePath(id: ResourceID | undefined): Promise<strin
return "";
}

return new URL(result.value).href;
return result.value
}


Expand Down

0 comments on commit 1e889fc

Please sign in to comment.