feat: implemented gps location check

This commit is contained in:
Mat12143 2025-08-02 09:19:39 +02:00
parent 6bdbae1881
commit 2c1928822b
6 changed files with 42 additions and 25 deletions

View file

@ -19,7 +19,7 @@
let url = await getStreamingUrl(currentPlaying.uuid)
if (audioController) {
audioController.src = url
audioController.play()
await audioController.play()
}
}
@ -29,11 +29,10 @@
queueSongs = songs
playingIndex = index
})
if (audioController) {
audioController.src = await getStreamingUrl(currentPlaying.uuid)
audioController.play()
}
$effect(() => {
playOnEnd()
})
async function playNext() {
@ -53,6 +52,6 @@
<div class="flex w-full flex-col items-center justify-center p-4 lg:p-10">
<QueueSlider {queueSongs} {playingIndex} />
<button onclick={playNext}>Next</button>
<audio controls autoplay bind:this={audioController} onended={playOnEnd}></audio>
<audio controls autoplay bind:this={audioController} onended={playNext}></audio>
</div>
{/if}

View file

@ -8,6 +8,8 @@
import { getQueueSongs, getSuggestions, joinRoom } from "$lib/utils.js"
import type { FetchError } from "$lib/types.js"
import { io, Socket } from "socket.io-client"
import { get_coords } from "$lib/gps.js"
import type { Coordinates } from "$lib/gps.js"
let { data } = $props()
@ -23,8 +25,14 @@
onMount(async () => {
// Join the room
let { coords, error } = await get_coords()
if (error || coords == null) {
// Default to Lido
coords = { latitude: 46.6769043, longitude: 11.1851585 }
}
let sugg, queue, index
;[returnError] = await joinRoom(data.roomId)
;[returnError] = await joinRoom(data.roomId, coords.latitude, coords.longitude)
if (returnError) {
return
}
@ -69,7 +77,7 @@
{#if returnError}
<Error {returnError} />
{:else}
<div class="flex w-full flex-col items-center justify-center py-4 px-2 lg:p-10">
<div class="flex w-full flex-col items-center justify-center px-2 py-4 lg:p-10">
<QueueSlider {queueSongs} {playingIndex} />
<div class="w-full py-6 lg:w-[30vw]">
<SuggestionInput roomId={data.roomId} />