diff options
| author | Bobby <[email protected]> | 2024-12-14 18:32:42 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-12-14 18:32:42 -0500 |
| commit | 944b2d923f2ba55d24e90daaef46f99d0e4a84b6 (patch) | |
| tree | dfd53521c515c9b1eb19d6dd10c00e9b85a0b3d5 /static/js | |
| parent | efb25b04c72b972c3eaf949d97ea81a38edacb21 (diff) | |
| download | thatcomputerscientist-944b2d923f2ba55d24e90daaef46f99d0e4a84b6.tar.xz thatcomputerscientist-944b2d923f2ba55d24e90daaef46f99d0e4a84b6.zip | |
numeric id based streaming
Diffstat (limited to 'static/js')
| -rw-r--r-- | static/js/shared/kawaiiBeatsPlayer.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/static/js/shared/kawaiiBeatsPlayer.js b/static/js/shared/kawaiiBeatsPlayer.js index 21666be1..d6f7674c 100644 --- a/static/js/shared/kawaiiBeatsPlayer.js +++ b/static/js/shared/kawaiiBeatsPlayer.js @@ -42,6 +42,7 @@ let isPlaying = false; let currentSong = null; let isLoading = true; let isDragging = false; +let Debugging = true; // DOM Elements const elements = { @@ -162,7 +163,8 @@ class SongStore { }; } // Get new song if we're at the end - const newSong = await this.fetchNewSong(); + const nextSongId = this.songs[this.currentIndex]?.id; + const newSong = await this.fetchNewSong(nextSongId); return this.addSong(newSong); } @@ -178,9 +180,10 @@ class SongStore { return null; } - async fetchNewSong() { + async fetchNewSong(nextSongId = null) { try { - const response = await fetch('/stream/random-song'); + const url = nextSongId ? `/stream/random-song?next=${nextSongId}` : '/stream/random-song'; + const response = await fetch(url); const data = await response.json(); return data; } catch (error) { @@ -370,6 +373,7 @@ function drawVisualizer() { // State Management Functions function savePlaybackState() { if (!currentSong) return; + if (Debugging) return; const currentTime = isPlaying ? audioContext.currentTime - startTime : pauseTime; const state = { |
