forked from Wobbl/Wobuzz
Implemented seeking.
This commit is contained in:
parent
dd44f10832
commit
24d589b172
4 changed files with 51 additions and 10 deletions
|
@ -20,6 +20,7 @@ class Player:
|
|||
|
||||
self.playing = False
|
||||
self.paused = False
|
||||
self.searched = False
|
||||
|
||||
if not file_paths:
|
||||
pass
|
||||
|
@ -31,10 +32,14 @@ class Player:
|
|||
if self.current_playlist:
|
||||
self.playing_track = self.current_playlist[0]
|
||||
self.current_playlist_index = 0
|
||||
self.playing_segment = self.playing_track.sound
|
||||
self.playing_segment_duration = self.playing_track.duration
|
||||
|
||||
else:
|
||||
self.playing_track = None
|
||||
self.current_playlist_index = 0
|
||||
self.playing_segment = None
|
||||
self.playing_segment_duration = 0
|
||||
|
||||
def load_tracks(self, track_paths: list[str]):
|
||||
"""
|
||||
|
@ -52,6 +57,8 @@ class Player:
|
|||
def track_finished(self):
|
||||
self.current_playlist_index += 1
|
||||
self.playing_track = self.current_playlist[self.current_playlist_index]
|
||||
self.playing_segment = self.playing_track.sound
|
||||
self.playing_segment_duration = self.playing_track.duration
|
||||
|
||||
self.music_channel.play(self.playing_track.sound)
|
||||
self.track_progress.start()
|
||||
|
@ -86,6 +93,9 @@ class Player:
|
|||
self.playing_track = self.current_playlist[self.current_playlist_index]
|
||||
self.track_progress.stop()
|
||||
|
||||
self.playing_segment = self.playing_track.sound
|
||||
self.playing_segment_duration = self.playing_track.duration
|
||||
|
||||
self.music_channel.play(self.playing_track.sound)
|
||||
self.track_progress.start()
|
||||
self.app.gui_communication.on_track_start()
|
||||
|
@ -105,3 +115,11 @@ class Player:
|
|||
self.track_progress.stop()
|
||||
self.playing = False
|
||||
|
||||
def seek(self, position: int):
|
||||
self.searched = True
|
||||
self.music_channel.stop()
|
||||
self.track_progress.stop()
|
||||
(self.playing_segment, self.playing_segment_duration) = self.playing_track.remaining(position)
|
||||
self.music_channel.play(self.playing_segment)
|
||||
self.track_progress.start()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue