Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix file paths on non-Windows systems" #8

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 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<string>();
const [media, setMedia] = createSignal<URL>();



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



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

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

const media = new URL(resource.value);

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

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

const m = media();

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

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

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

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

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

if (isPlaying() === true) {
Expand Down Expand Up @@ -227,7 +229,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 @@ -262,15 +264,15 @@ window.api.listen("queue::songChanged", async (s) => {
return;
}

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



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

const OFFSET = 0;
Expand Down Expand Up @@ -305,5 +307,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 result.value
return new URL(result.value).href;
}


Expand Down