stop playback immediately on window close

This commit is contained in:
Erica Z 2024-10-26 09:20:25 +02:00
parent d550d8f9b7
commit 36d6734e73
2 changed files with 15 additions and 0 deletions

View file

@ -362,6 +362,15 @@ public class Playbin : GLib.Object {
} }
} }
public void stop () {
debug ("stopping playback");
// don't clear the playlist, just in case (less state changes to sync)
assert(this.mpv.command({"stop", "keep-playlist"}) >= 0);
this.state = PlaybinState.STOPPED;
this.play_queue_position = this._play_queue.get_n_items ();
this.stopped ();
}
~Playbin () { ~Playbin () {
debug ("destroying playbin"); debug ("destroying playbin");
} }

View file

@ -116,6 +116,12 @@ class Ui.Window : Adw.ApplicationWindow {
return stack_child != "play-queue"; return stack_child != "play-queue";
} }
public override bool close_request () {
// stop playback on close
this.playbin.stop ();
return false;
}
~Window () { ~Window () {
debug ("destroying main window"); debug ("destroying main window");
} }