mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-18 00:16:40 +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 { 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1299,6 +1299,11 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
|
||||
});
|
||||
},
|
||||
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) => {
|
||||
if (state.player.status === PlayerStatus.PLAYING) {
|
||||
state.player.status = PlayerStatus.PAUSED;
|
||||
@@ -1306,6 +1311,10 @@ export const usePlayerStoreBase = createWithEqualityFn<PlayerState>()(
|
||||
state.player.status = PlayerStatus.PLAYING;
|
||||
}
|
||||
});
|
||||
|
||||
if (wasStopped) {
|
||||
emitPlayerPlayEvent(undefined, set, get);
|
||||
}
|
||||
},
|
||||
moveSelectedTo: (items: QueueSong[], uniqueId: string, edge: 'bottom' | 'top') => {
|
||||
const itemUniqueIds = items.map((item) => item._uniqueId);
|
||||
|
||||
Reference in New Issue
Block a user