Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/lib/player_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ def _on_track_start(self, bus: Any, message: Any):
self.seek(self.seek_after_sink_reload)
self.seek_after_sink_reload = None

self.can_go_prev = len(self.played_songs) > 0
# Only notify to deactivate
if not self.can_go_prev:
self.notify("can-go-prev")
GLib.timeout_add(2000, self.previous_timer_callback)

def play_this(
self, thing: Union[Mix, Album, Playlist, List[Track], Track], index: int = 0
) -> None:
Expand Down Expand Up @@ -594,6 +600,11 @@ def play_previous(self):
# if not in the first 2 seconds of the track restart song
if self.query_position() > 2 * Gst.SECOND:
self.seek(0)
self.can_go_prev = len(self.played_songs) > 0
# only notify when can't go to previous
if not self.can_go_prev:
self.notify("can-go-prev")
GLib.timeout_add(2000, self.previous_timer_callback)
return

if not self.played_songs:
Expand All @@ -605,6 +616,11 @@ def play_previous(self):
self._tracks_to_play.insert(0, self.playing_track)
self.play_track(track)

def previous_timer_callback(self):
"""Send a notify Event after 2s of the song playing"""
self.can_go_prev = True
self.notify("can-go-prev")

def _update_shuffle_queue(self):
if self.shuffle:
self._shuffled_tracks_to_play = self._tracks_to_play.copy()
Expand Down