mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-19 00:46:35 +02:00
fix mpv playback resume on queue end / stop
This commit is contained in:
@@ -278,7 +278,9 @@ export const MpvPlayerEngine = (props: MpvPlayerEngineProps) => {
|
|||||||
|
|
||||||
const handleTrackEnded = () => {
|
const handleTrackEnded = () => {
|
||||||
const { player } = usePlayerStore.getState();
|
const { player } = usePlayerStore.getState();
|
||||||
if (player.status !== PlayerStatus.PLAYING) {
|
// mpv often emits `stopped` before this event, which already set STOPPED
|
||||||
|
// via mediaStop. Still run mediaAutoNext so end-of-queue seek/reset runs.
|
||||||
|
if (player.status !== PlayerStatus.PLAYING && player.status !== PlayerStatus.STOPPED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1299,6 +1299,11 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
mediaTogglePlayPause: () => {
|
mediaTogglePlayPause: () => {
|
||||||
|
// Restarting from STOPPED (e.g. end of queue) needs a full play
|
||||||
|
// event so engines like mpv can reload the current track — play()
|
||||||
|
// alone is a no-op when mpv's playlist-pos is -1.
|
||||||
|
const wasStopped = get().player.status === PlayerStatus.STOPPED;
|
||||||
|
|
||||||
set((state) => {
|
set((state) => {
|
||||||
if (state.player.status === PlayerStatus.PLAYING) {
|
if (state.player.status === PlayerStatus.PLAYING) {
|
||||||
state.player.status = PlayerStatus.PAUSED;
|
state.player.status = PlayerStatus.PAUSED;
|
||||||
@@ -1306,6 +1311,10 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
|
|||||||
state.player.status = PlayerStatus.PLAYING;
|
state.player.status = PlayerStatus.PLAYING;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (wasStopped) {
|
||||||
|
emitPlayerPlayEvent(undefined, set, get);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
moveSelectedTo: (items: QueueSong[], uniqueId: string, edge: 'bottom' | 'top') => {
|
moveSelectedTo: (items: QueueSong[], uniqueId: string, edge: 'bottom' | 'top') => {
|
||||||
const itemUniqueIds = items.map((item) => item._uniqueId);
|
const itemUniqueIds = items.map((item) => item._uniqueId);
|
||||||
|
|||||||
Reference in New Issue
Block a user