You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The "Play Next" feature was not functioning - when clicking the "Play Next" button in the song menu, the selected song was not playing immediately. Instead, it was only being added to the queue without starting playback. Additionally, no toast notification was appearing, and in some cases, the application showed a "Failed to play next" error.
To Reproduce
Steps to reproduce the behavior:
Go to any page with songs (e.g., home page, album page, artist page)
Click on the three-dot menu (ellipsis icon) on any song
Select "Play next" from the menu
Observe that the song does not start playing immediately
Check that the toast message either doesn't appear or shows "Failed to play next" error
Expected behavior
When clicking "Play Next":
The currently playing song should be moved to the front of the queue
The selected song should start playing immediately
A success toast notification should appear saying "Playing Next!"
The player should update to show the new song as the current track
Root Cause
The addToQueueNext function in the Zustand store (zustand/store.js) was only modifying the queue array without:
Updating currentSong to the new song
Setting musicId to the new song's ID
Setting isPlaying: true to trigger playback
Properly handling null/undefined state values (queue, playedSongIds)
Solution Applied
Updated the addToQueueNext function to:
Check if a song is currently playing
If nothing is playing: set the new song as current and start playback
If something is playing: save the current song to the queue and immediately play the new song
Added proper error handling and null checks
Added validation for song object (must have valid id)
Desktop:
OS: Not specified
Browser: Chrome
Smartphone:
Device: Mobile device (tested with mobile drawer interface)
OS: Not specified
Browser: Chrome
Additional context
The issue affected both mobile (drawer) and desktop (menubar) interfaces
A Firebase connection warning was also present but was unrelated to this specific bug
The bug was present in both shuffle and normal playback modes
The fix maintains proper queue state for both shuffle and non-shuffle modes
Added comprehensive error logging for easier future debugging
Related Files Modified:
zustand/store.js - Updated addToQueueNext function
components/Menu.jsx - Added error handling to handleAddToNext (optional)
Bug_issue_music_app_play_next.mp4
App Name:
web(Music Player Frontend)Describe the bug
The "Play Next" feature was not functioning - when clicking the "Play Next" button in the song menu, the selected song was not playing immediately. Instead, it was only being added to the queue without starting playback. Additionally, no toast notification was appearing, and in some cases, the application showed a "Failed to play next" error.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
When clicking "Play Next":
Root Cause
The
addToQueueNextfunction in the Zustand store (zustand/store.js) was only modifying the queue array without:currentSongto the new songmusicIdto the new song's IDisPlaying: trueto trigger playbackSolution Applied
Updated the
addToQueueNextfunction to:id)Desktop:
Smartphone:
Additional context
Related Files Modified:
zustand/store.js- UpdatedaddToQueueNextfunctioncomponents/Menu.jsx- Added error handling tohandleAddToNext(optional)Status: Resolved