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