Check if player is actually playing before calling stop(for_replacement=True)
in MpvMediaPlayer.play(). When the player was already idle,
stop(for_replacement=True) would set _suppress_end_event=True with no
end-file event to consume it. The next track's end-file callback would
then be incorrectly suppressed, breaking the timer loop.
- Import PlayerState to check player state
- Only call stop(for_replacement=True) when player is not IDLE
Prevent IDLE state and done callback on track replacement
mpv emits an end-file event when playback is stopped. During track
replacement this caused the media player to transition to IDLE and
notify Home Assistant even though a new track was already playing.
Introduce a suppression flag to distinguish track replacement from
natural playback end and avoid incorrect state transitions.
Fixes#107
This fixes an issue where loading a new media URL while the player
was paused would keep playback paused, causing Music Assistant to
show the player as playing while no audio was audible.
The mpv pause state is now always set explicitly when starting playback,
ensuring deterministic behavior