mirror of
https://github.com/SrIzan10/lofi.git
synced 2026-06-06 00:56:53 +00:00
fix: playing and pausing going back to initial state
This commit is contained in:
@@ -11,20 +11,17 @@
|
||||
if (!audioElement) return;
|
||||
|
||||
if (play && state.hasInteracted) {
|
||||
audioElement.currentTime = state.currentTime;
|
||||
audioElement.play().catch(() => {
|
||||
state.error = 'Audio playback failed. Please interact with the page first.';
|
||||
state.isPlaying = false;
|
||||
});
|
||||
audioElement.currentTime = state.currentTime;
|
||||
} else {
|
||||
state.currentTime = audioElement.currentTime;
|
||||
audioElement.pause();
|
||||
}
|
||||
}
|
||||
|
||||
function playAudio() {
|
||||
togglePlayback(true);
|
||||
}
|
||||
|
||||
state.togglePlay = () => {
|
||||
state.isPlaying = !state.isPlaying;
|
||||
togglePlayback(state.isPlaying);
|
||||
@@ -115,7 +112,7 @@
|
||||
class="flex flex-col h-screen w-full items-center justify-center space-y-2 cursor-pointer"
|
||||
onclick={() => {
|
||||
state.hasInteracted = true;
|
||||
playAudio()
|
||||
togglePlayback(true);
|
||||
}}
|
||||
>
|
||||
<p>Click anywhere on the screen</p>
|
||||
|
||||
Reference in New Issue
Block a user