From 5c24cde637e31f6c257079c21c9a92ae5254f46a Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sun, 20 Oct 2024 13:26:36 +0200 Subject: [PATCH] fix end of stream lol --- src/playbin.vala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/playbin.vala b/src/playbin.vala index 54a2310..95f2790 100644 --- a/src/playbin.vala +++ b/src/playbin.vala @@ -148,6 +148,11 @@ public class Playbin : GLib.Object { } else { this.inc_position = true; } + + // estimate duration from api data + // while mpv doesn't know it + this.duration = ((Subsonic.Song) this._play_queue.get_item (this.play_queue_position)).duration; + this.new_track (); break; @@ -158,10 +163,9 @@ public class Playbin : GLib.Object { warning ("playback of track aborted: %s", data.error.to_string ()); } - if (this.inc_position) { - // reached the end + if (this.inc_position && this.play_queue_position+1 == this._play_queue.get_n_items ()) { + // reached the end (?) this.play_queue_position += 1; - assert (this.play_queue_position == this._play_queue.get_n_items ()); this.state = PlaybinState.STOPPED; this.stopped (); }