Skip to content

Commit 689a783

Browse files
committed
fix: scrobbling looping tracks (#32)
fix: #30 Reviewed-on: https://codeberg.org/GeopJr/Turntable/pulls/32
1 parent dff5e82 commit 689a783

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Mpris/Entry.vala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Turntable.Mpris.Entry : GLib.Object {
1818
public string client_info_name { get { return this.client_info.identity; } }
1919
public string client_info_icon { get { return this.client_info.icon; } }
2020

21+
public bool looping { get; private set; default = false; }
2122
public bool can_go_next { get; private set; default = false; }
2223
public bool can_go_back { get; private set; default = false; }
2324
public bool can_control { get; private set; default = false; }
@@ -123,6 +124,7 @@ public class Turntable.Mpris.Entry : GLib.Object {
123124
update_position ();
124125
update_playback_status ();
125126
update_controls ();
127+
update_loop_status ();
126128

127129
GLib.Timeout.add (PROGRESS_UPDATE_TIME, update_position);
128130
} catch (Error e) {
@@ -150,6 +152,9 @@ public class Turntable.Mpris.Entry : GLib.Object {
150152
case "PlaybackStatus":
151153
update_playback_status ();
152154
break;
155+
case "LoopStatus":
156+
update_loop_status ();
157+
break;
153158
case "CanGoNext":
154159
case "CanGoPrevious":
155160
case "CanPlay":
@@ -163,6 +168,10 @@ public class Turntable.Mpris.Entry : GLib.Object {
163168
});
164169
}
165170

171+
private void update_loop_status () {
172+
this.looping = this.player.loop_status == "Track";
173+
}
174+
166175
private bool update_position () {
167176
if (this.props == null) return GLib.Source.REMOVE;
168177

@@ -247,6 +256,8 @@ public class Turntable.Mpris.Entry : GLib.Object {
247256
} else {
248257
this.length = variant_length.get_int64 ();
249258
}
259+
260+
this.notify_property ("length");
250261
}
251262
}
252263
}

src/Views/Window.vala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
217217
_position = 0;
218218
prog.progress = 0;
219219
} else {
220+
#if SCROBBLING
221+
if (value == 0 && this.player != null && this.player.looping && _position > 0) {
222+
this.length = this.length; // re-trigger it
223+
}
224+
#endif
220225
_position = value;
221226
prog.progress = (double)value / (double)this.length;
222227
}

0 commit comments

Comments
 (0)