feat(player): playNext for M7 #372 track-actions menu
Inserts at _queue[_index + 1] so the next-up slot is overwritten with the chosen track. Empty-queue seeding mirrors enqueueTrack's behavior. Clears _radioSeedId since user-driven enqueue invalidates the M4c auto-refresh trigger.
This commit is contained in:
@@ -211,6 +211,22 @@ export function enqueueTrack(t: TrackRef): void {
|
||||
if (_state === 'idle') _index = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* M7 #372: insert a track immediately after the currently-playing one
|
||||
* so it plays next. If the queue is empty, behaves like enqueueTrack
|
||||
* and starts the queue with this track at index 0.
|
||||
*/
|
||||
export function playNext(t: TrackRef): void {
|
||||
_radioSeedId = null; // M4c: any user-driven enqueue clears the radio refresh state
|
||||
if (_queue.length === 0) {
|
||||
_queue = [t];
|
||||
_index = 0;
|
||||
return;
|
||||
}
|
||||
const next = _index + 1;
|
||||
_queue = [..._queue.slice(0, next), t, ..._queue.slice(next)];
|
||||
}
|
||||
|
||||
export function enqueueTracks(ts: TrackRef[]): void {
|
||||
_radioSeedId = null; // M4c
|
||||
if (ts.length === 0) return;
|
||||
|
||||
Reference in New Issue
Block a user