Play selected track on Return
This commit is contained in:
parent
f5e066c210
commit
bf990f7486
9
app.py
9
app.py
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import vlc
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
@ -88,7 +89,13 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
def play_selected(self):
|
def play_selected(self):
|
||||||
if self.playlist.selectionModel().hasSelection():
|
if self.playlist.selectionModel().hasSelection():
|
||||||
row = self.playlist.currentRow()
|
row = self.playlist.currentRow()
|
||||||
print(f"Play id={self.playlist.item(row, 0).text()}")
|
track_id = int(self.playlist.item(row, 0).text())
|
||||||
|
# TODO: get_path may raise exception
|
||||||
|
track_path = Tracks.get_path(track_id)
|
||||||
|
if track_path:
|
||||||
|
player = vlc.MediaPlayer(track_path)
|
||||||
|
import ipdb; ipdb.set_trace()
|
||||||
|
player.play()
|
||||||
|
|
||||||
def selectFile(self):
|
def selectFile(self):
|
||||||
dlg = QFileDialog()
|
dlg = QFileDialog()
|
||||||
|
|||||||
11
model.py
11
model.py
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
import pytiger.logging.config
|
import pytiger.logging.config
|
||||||
@ -13,6 +14,7 @@ from sqlalchemy.orm import sessionmaker
|
|||||||
# "Constants"
|
# "Constants"
|
||||||
DISPLAY_SQL = False
|
DISPLAY_SQL = False
|
||||||
MYSQL_CONNECT = "mysql+mysqldb://songdb:songdb@localhost/songdb"
|
MYSQL_CONNECT = "mysql+mysqldb://songdb:songdb@localhost/songdb"
|
||||||
|
ROOT = "/home/kae/music"
|
||||||
|
|
||||||
# Instantiate logging
|
# Instantiate logging
|
||||||
pytiger.logging.config.basic_config(stderr=False, level=logging.INFO)
|
pytiger.logging.config.basic_config(stderr=False, level=logging.INFO)
|
||||||
@ -67,6 +69,15 @@ class Tracks(Base):
|
|||||||
session.add(track)
|
session.add(track)
|
||||||
return track
|
return track
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_path(id):
|
||||||
|
try:
|
||||||
|
path = session.query(Tracks.path).filter(Tracks.id == id).one()[0]
|
||||||
|
return os.path.join(ROOT, path)
|
||||||
|
except NoResultFound:
|
||||||
|
print(f"Can't find track id {id}")
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def search_titles(text):
|
def search_titles(text):
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user