def on_tick(self, data): position = self.player.streamer.position duration = self.player.streamer.duration fraction = position / duration if duration else 0 position_text = time_helper.seconds_to_string(position) duration_text = time_helper.seconds_to_string(duration) self.lbl_current_time.set_text(f'{position_text} / {duration_text}') self.prb_current_time.set_fraction(fraction) return True
def create_row(song): return [ song.Path, song.Title or 'Unknown', song.AlbumArtist or 'Unknown', song.Album or 'Unknown', time_helper.seconds_to_string(song.Length), song.Year or '0000', arrow.Arrow(song.Added.year, song.Added.month, song.Added.day).humanize(), song.Played, song.Genre, str(song.Tracknumber) ]
def test_seconds_to_string(self): self.assertEqual(time_helper.seconds_to_string(3), '00:03') self.assertEqual(time_helper.seconds_to_string(60), '01:00') self.assertEqual(time_helper.seconds_to_string(62), '01:02') self.assertEqual(time_helper.seconds_to_string(78), '01:18') self.assertEqual(time_helper.seconds_to_string(None), '00:00') self.assertEqual(time_helper.seconds_to_string(0), '00:00')
def load_text(self): self.set_text(self.txt_Path, lambda s: s.Path) self.set_text(self.txt_Bitrate, lambda s: s.Bitrate) self.set_text(self.txt_Channels, lambda s: s.Channels) self.set_text(self.txt_Length, lambda s: time_helper.seconds_to_string(s.Length)) self.set_text(self.txt_Title, lambda s: s.Title) self.set_text(self.txt_Artist, lambda s: s.Artist) self.set_text(self.txt_Album, lambda s: s.Album) self.set_text(self.txt_Genre, lambda s: s.Genre) self.set_text(self.txt_Year, lambda s: s.Year) self.set_text(self.txt_Comment, lambda s: s.Comment) self.set_text(self.txt_Added, lambda s: str(s.Added)) self.set_text(self.txt_ArtistAlbum, lambda s: s.AlbumArtist) self.set_text(self.txt_TrackNumber, lambda s: s.Tracknumber)
def create_row(song): return [ song.Path, str(song.Tracknumber) + ".", song.Title or 'Unknown', time_helper.seconds_to_string(song.Length) ]