feat: home hero+genres, fix Android queue desync via song ID verification
Home view: - Add hero card (random pick from recent+frequent combined pool) - Add genre browser chips (sorted by song count, tap = shuffle-play) Android sync fix: - Add currentId to getState() snapshot so JS can verify song identity - onReady: reset stale localStorage queue when native song ID mismatches - onTrackChanged: reject stale old-queue callbacks by ID verification - onPlaybackStateChanged safety net: ID-guard prevents wrong-queue index corruption - connectToService: call updateStateSnapshot() before onReady so getState() is never empty Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
377a6954e3
commit
d3a1bf6a82
5 files changed
+142
-20
No files matched your search
@@ -138,6 +138,7 @@ class MainActivity : AppCompatActivity(), MusicService.StateListener {
|
||||
mediaController = try { future.get() } catch (_: Exception) { null }
|
||||
if (mediaController != null) {
|
||||
lastOnReadyMs = System.currentTimeMillis()
|
||||
updateStateSnapshot() // ensure getState() is fresh when JS calls it in onReady
|
||||
callJs("onReady")
|
||||
}
|
||||
}, ContextCompat.getMainExecutor(this))
|
||||
@@ -246,6 +247,7 @@ class MainActivity : AppCompatActivity(), MusicService.StateListener {
|
||||
put("isPlaying", ctrl.isPlaying)
|
||||
put("isBuffering", ctrl.playbackState == Player.STATE_BUFFERING)
|
||||
put("currentIndex", ctrl.currentMediaItemIndex)
|
||||
put("currentId", ctrl.currentMediaItem?.mediaId ?: "")
|
||||
put("positionMs", ctrl.currentPosition)
|
||||
put("queueLength", ctrl.mediaItemCount)
|
||||
}.toString()
|
||||
|
||||
Reference in new issue
Block a user