Use Audacity and mplayer without session
This commit is contained in:
parent
019bc87eb0
commit
453e42172b
@ -905,7 +905,7 @@ class PlaylistTab(QTableWidget):
|
||||
# Play with mplayer
|
||||
if track_row and not current:
|
||||
self._add_context_menu("Play with mplayer",
|
||||
lambda: self._mplayer_play(track_id))
|
||||
lambda: self._mplayer_play(row_number))
|
||||
|
||||
# Paste
|
||||
self._add_context_menu("Paste",
|
||||
@ -915,7 +915,7 @@ class PlaylistTab(QTableWidget):
|
||||
# Open in Audacity
|
||||
if track_row and not current:
|
||||
self._add_context_menu("Open in Audacity",
|
||||
lambda: self._open_in_audacity(track_id)
|
||||
lambda: self._open_in_audacity(row_number)
|
||||
)
|
||||
|
||||
# Rescan
|
||||
@ -1384,42 +1384,35 @@ class PlaylistTab(QTableWidget):
|
||||
# updated
|
||||
QTimer.singleShot(0, self._update_start_end_times)
|
||||
|
||||
def _mplayer_play(self, track_id: int) -> None:
|
||||
def _mplayer_play(self, row_number: int) -> None:
|
||||
"""Play track with mplayer"""
|
||||
|
||||
with Session() as session:
|
||||
track = session.get(Tracks, track_id)
|
||||
if not track:
|
||||
log.error(
|
||||
f"playlists._mplayer_play({track_id=}): "
|
||||
"Track not found"
|
||||
)
|
||||
return
|
||||
track_path = self._get_row_track_path(row_number)
|
||||
if not track_path:
|
||||
log.error(
|
||||
f"{self.playlist_id=} playlists._mplayer_play({row_number=}): "
|
||||
"track_path not set"
|
||||
)
|
||||
return
|
||||
|
||||
cmd_list = ['gmplayer', '-vc', 'null', '-vo', 'null', track.path]
|
||||
cmd_list = ['gmplayer', '-vc', 'null', '-vo', 'null', track_path]
|
||||
thread = threading.Thread(
|
||||
target=self._run_subprocess, args=(cmd_list,))
|
||||
thread.start()
|
||||
|
||||
def _open_in_audacity(self, track_id: int) -> None:
|
||||
def _open_in_audacity(self, row_number: int) -> None:
|
||||
"""Open track in Audacity. Audacity must be already running"""
|
||||
|
||||
with Session() as session:
|
||||
track = session.get(Tracks, track_id)
|
||||
if not track:
|
||||
log.error(
|
||||
f"playlists._open_in_audacity({track_id=}): "
|
||||
"Track not found"
|
||||
)
|
||||
return
|
||||
track_path = self._get_row_track_path(row_number)
|
||||
if not track_path:
|
||||
log.error(
|
||||
f"{self.playlist_id=} "
|
||||
f"playlists._open_in_audactity({row_number=}): "
|
||||
"track_path not set"
|
||||
)
|
||||
return
|
||||
|
||||
if track.path is None:
|
||||
log.error(
|
||||
f"playlists._open_in_audacity({track_id=}): "
|
||||
"Track has no path"
|
||||
)
|
||||
else:
|
||||
open_in_audacity(track.path)
|
||||
open_in_audacity(track_path)
|
||||
|
||||
def _plrid_to_row_number(self, plrid: int) -> Optional[int]:
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user