Compare commits
2 Commits
8366fed1be
...
453fe87bf9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
453fe87bf9 | ||
|
|
b10e729627 |
18
app/music.py
18
app/music.py
@ -30,7 +30,7 @@ class Music:
|
|||||||
to hold up the UI during the fade.
|
to hold up the UI during the fade.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DEBUG("fade()")
|
DEBUG("music.fade()")
|
||||||
|
|
||||||
if not self.playing():
|
if not self.playing():
|
||||||
return None
|
return None
|
||||||
@ -45,7 +45,7 @@ class Music:
|
|||||||
Implementation of fading the current track in a separate thread.
|
Implementation of fading the current track in a separate thread.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DEBUG("_fade()")
|
DEBUG("music._fade()")
|
||||||
|
|
||||||
fade_time = Config.FADE_TIME / 1000
|
fade_time = Config.FADE_TIME / 1000
|
||||||
steps = Config.FADE_STEPS
|
steps = Config.FADE_STEPS
|
||||||
@ -75,11 +75,16 @@ class Music:
|
|||||||
def get_playtime(self):
|
def get_playtime(self):
|
||||||
"Return elapsed play time"
|
"Return elapsed play time"
|
||||||
|
|
||||||
|
if not self.player:
|
||||||
|
return None
|
||||||
|
|
||||||
return self.player.get_time()
|
return self.player.get_time()
|
||||||
|
|
||||||
def get_position(self):
|
def get_position(self):
|
||||||
"Return current position"
|
"Return current position"
|
||||||
|
|
||||||
|
DEBUG("music.get_position")
|
||||||
|
|
||||||
return self.player.get_position()
|
return self.player.get_position()
|
||||||
|
|
||||||
def play(self, path):
|
def play(self, path):
|
||||||
@ -89,7 +94,7 @@ class Music:
|
|||||||
Log and return if path not found.
|
Log and return if path not found.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
DEBUG(f"play({path})")
|
DEBUG(f"music.play({path})")
|
||||||
|
|
||||||
if not os.access(path, os.R_OK):
|
if not os.access(path, os.R_OK):
|
||||||
ERROR(f"play({path}): path not found")
|
ERROR(f"play({path}): path not found")
|
||||||
@ -135,8 +140,15 @@ class Music:
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
"Immediately stop playing"
|
"Immediately stop playing"
|
||||||
|
|
||||||
|
DEBUG("music.stop()")
|
||||||
|
|
||||||
|
if not self.player:
|
||||||
|
return None
|
||||||
|
|
||||||
position = self.player.get_position()
|
position = self.player.get_position()
|
||||||
self.player.stop()
|
self.player.stop()
|
||||||
self.player.release()
|
self.player.release()
|
||||||
|
# Ensure we don't reference player after release
|
||||||
|
self.player = None
|
||||||
|
|
||||||
return position
|
return position
|
||||||
|
|||||||
@ -264,7 +264,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
the database object, get it populated and then add tab.
|
the database object, get it populated and then add tab.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
playlist_table = Playlist()
|
playlist_table = Playlist(self)
|
||||||
playlist_table.db = playlist_db
|
playlist_table.db = playlist_db
|
||||||
playlist_table.populate()
|
playlist_table.populate()
|
||||||
idx = self.tabPlaylist.addTab(playlist_table, playlist_db.name)
|
idx = self.tabPlaylist.addTab(playlist_table, playlist_db.name)
|
||||||
@ -389,9 +389,10 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
playlist = Playlists.open(dlg.plid)
|
playlist = Playlists.open(dlg.plid)
|
||||||
self.load_playlist(playlist)
|
self.load_playlist(playlist)
|
||||||
|
|
||||||
def set_next_track(self):
|
def set_next_track(self, next_track_id=None):
|
||||||
"Set selected track as next"
|
"Set selected track as next"
|
||||||
|
|
||||||
|
if not next_track_id:
|
||||||
next_track_id = self.visible_playlist().set_selected_as_next()
|
next_track_id = self.visible_playlist().set_selected_as_next()
|
||||||
if next_track_id:
|
if next_track_id:
|
||||||
if self.next_track_playlist != self.visible_playlist():
|
if self.next_track_playlist != self.visible_playlist():
|
||||||
|
|||||||
@ -37,6 +37,7 @@ class Playlist(QTableWidget):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.master_process = self.parent()
|
||||||
self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
||||||
self.setAlternatingRowColors(True)
|
self.setAlternatingRowColors(True)
|
||||||
self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||||
@ -642,12 +643,11 @@ class Playlist(QTableWidget):
|
|||||||
if row in self._meta_get_notes():
|
if row in self._meta_get_notes():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self.item(row, self.COL_INDEX):
|
track_id = self._get_row_id(row)
|
||||||
self._meta_set_next(row)
|
if track_id:
|
||||||
|
self._meta_set_next(self.currentRow())
|
||||||
self._repaint(save_playlist=False)
|
self._repaint(save_playlist=False)
|
||||||
return self._get_row_id(row)
|
self.master_process.set_next_track(track_id)
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _repaint(self, clear_selection=True, save_playlist=True):
|
def _repaint(self, clear_selection=True, save_playlist=True):
|
||||||
"Set row colours, fonts, etc, and save playlist"
|
"Set row colours, fonts, etc, and save playlist"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user