Added a "track_info"-toolbar which shows an image found in the current audio file's metadata (usually the front-cover) and information about the currently playing track such as title and artist name.
This commit is contained in:
parent
ccda6b30c8
commit
39bd7e3167
5 changed files with 101 additions and 5 deletions
|
@ -15,6 +15,7 @@ class GUI:
|
||||||
self.settings = self.window.settings
|
self.settings = self.window.settings
|
||||||
self.track_control = self.window.track_control
|
self.track_control = self.window.track_control
|
||||||
self.process_dock = self.window.process_dock
|
self.process_dock = self.window.process_dock
|
||||||
|
self.track_info = self.window.track_info
|
||||||
|
|
||||||
self.window.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, self.app.library.main_library_dock)
|
self.window.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, self.app.library.main_library_dock)
|
||||||
|
|
||||||
|
@ -62,3 +63,7 @@ class GUI:
|
||||||
def on_background_job_stop(self, job_name: str):
|
def on_background_job_stop(self, job_name: str):
|
||||||
self.process_dock.job_finished_signal.emit(job_name)
|
self.process_dock.job_finished_signal.emit(job_name)
|
||||||
|
|
||||||
|
def on_playstate_update(self):
|
||||||
|
self.track_control.on_playstate_update()
|
||||||
|
self.track_info.update_info()
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Player:
|
||||||
self.playing = True
|
self.playing = True
|
||||||
self.paused = False
|
self.paused = False
|
||||||
|
|
||||||
self.app.gui.track_control.on_playstate_update()
|
self.app.gui.on_playstate_update()
|
||||||
|
|
||||||
# cache next track so it immediately starts when the current track finishes
|
# cache next track so it immediately starts when the current track finishes
|
||||||
self.cache_next_track()
|
self.cache_next_track()
|
||||||
|
@ -68,7 +68,7 @@ class Player:
|
||||||
|
|
||||||
self.app.gui.on_track_change(self.history.h_last_track(), self.current_playlist.current_track)
|
self.app.gui.on_track_change(self.history.h_last_track(), self.current_playlist.current_track)
|
||||||
|
|
||||||
self.app.gui.track_control.on_playstate_update()
|
self.app.gui.on_playstate_update()
|
||||||
|
|
||||||
def play_track_in_playlist(self, track_index):
|
def play_track_in_playlist(self, track_index):
|
||||||
self.stop()
|
self.stop()
|
||||||
|
@ -99,7 +99,7 @@ class Player:
|
||||||
self.track_progress.pause()
|
self.track_progress.pause()
|
||||||
self.paused = True
|
self.paused = True
|
||||||
|
|
||||||
self.app.gui.track_control.on_playstate_update()
|
self.app.gui.on_playstate_update()
|
||||||
|
|
||||||
def unpause(self):
|
def unpause(self):
|
||||||
self.music_channel.unpause()
|
self.music_channel.unpause()
|
||||||
|
@ -108,7 +108,7 @@ class Player:
|
||||||
self.playing = True
|
self.playing = True
|
||||||
self.paused = False
|
self.paused = False
|
||||||
|
|
||||||
self.app.gui.track_control.on_playstate_update()
|
self.app.gui.on_playstate_update()
|
||||||
|
|
||||||
def next_track(self):
|
def next_track(self):
|
||||||
if not self.current_playlist.on_last_track():
|
if not self.current_playlist.on_last_track():
|
||||||
|
@ -141,7 +141,7 @@ class Player:
|
||||||
self.playing = False
|
self.playing = False
|
||||||
self.paused = False
|
self.paused = False
|
||||||
|
|
||||||
self.app.gui.track_control.on_playstate_update()
|
self.app.gui.on_playstate_update()
|
||||||
|
|
||||||
def seek(self, position: int):
|
def seek(self, position: int):
|
||||||
self.music_channel.stop()
|
self.music_channel.stop()
|
||||||
|
|
|
@ -67,6 +67,8 @@ class Track:
|
||||||
|
|
||||||
self.duration = len(self.audio) # track duration in milliseconds
|
self.duration = len(self.audio) # track duration in milliseconds
|
||||||
|
|
||||||
|
self.tags = TinyTag.get(self.path, ignore_errors=True, duration=False, image=True) # metadata with images
|
||||||
|
|
||||||
self.cached = True
|
self.cached = True
|
||||||
|
|
||||||
def clear_cache(self):
|
def clear_cache(self):
|
||||||
|
@ -76,6 +78,8 @@ class Track:
|
||||||
self.sound = None
|
self.sound = None
|
||||||
self.duration = 0
|
self.duration = 0
|
||||||
|
|
||||||
|
self.tags = TinyTag.get(self.path, ignore_errors=True, duration=False) # metadata without images
|
||||||
|
|
||||||
def load_audio(self):
|
def load_audio(self):
|
||||||
#file_type = self.path.split(".")[-1]
|
#file_type = self.path.split(".")[-1]
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ from PyQt6.QtWidgets import QMainWindow, QMenu
|
||||||
from .track_control import TrackControl
|
from .track_control import TrackControl
|
||||||
from .settings import Settings
|
from .settings import Settings
|
||||||
from .process.process_dock import ProcessDock
|
from .process.process_dock import ProcessDock
|
||||||
|
from .track_info import TrackInfo
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
|
@ -45,6 +46,9 @@ class MainWindow(QMainWindow):
|
||||||
self.process_dock.hide()
|
self.process_dock.hide()
|
||||||
self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.process_dock)
|
self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.process_dock)
|
||||||
|
|
||||||
|
self.track_info = TrackInfo(app)
|
||||||
|
self.addToolBar(Qt.ToolBarArea.BottomToolBarArea, self.track_info)
|
||||||
|
|
||||||
self.settings_action.triggered.connect(self.settings.show)
|
self.settings_action.triggered.connect(self.settings.show)
|
||||||
self.processes_action.triggered.connect(self.process_dock.show)
|
self.processes_action.triggered.connect(self.process_dock.show)
|
||||||
|
|
||||||
|
|
83
wobuzz/ui/track_info.py
Normal file
83
wobuzz/ui/track_info.py
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from PyQt6.QtGui import QPixmap, QFont
|
||||||
|
from PyQt6.QtWidgets import QToolBar, QWidget, QLabel, QSizePolicy, QVBoxLayout
|
||||||
|
|
||||||
|
|
||||||
|
class TrackInfo(QToolBar):
|
||||||
|
title_font = QFont()
|
||||||
|
title_font.setPointSize(16)
|
||||||
|
title_font.setBold(True)
|
||||||
|
|
||||||
|
artist_font = QFont()
|
||||||
|
title_font.setPointSize(12)
|
||||||
|
|
||||||
|
album_font = QFont()
|
||||||
|
album_font.setPointSize(8)
|
||||||
|
|
||||||
|
def __init__(self, app, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||||
|
|
||||||
|
self.wobuzz_logo = QPixmap(f"{self.app.utils.wobuzz_location}/icon.svg")
|
||||||
|
|
||||||
|
self.track_cover = QLabel(self)
|
||||||
|
self.track_cover.setFixedSize(64, 64)
|
||||||
|
self.track_cover.setScaledContents(True)
|
||||||
|
self.track_cover.setPixmap(self.wobuzz_logo)
|
||||||
|
self.addWidget(self.track_cover)
|
||||||
|
|
||||||
|
self.info_container = QWidget(self)
|
||||||
|
info_container_layout = QVBoxLayout(self.info_container)
|
||||||
|
self.info_container.setLayout(info_container_layout)
|
||||||
|
self.addWidget(self.info_container)
|
||||||
|
|
||||||
|
self.title = QLabel("Title", self.info_container)
|
||||||
|
self.title.setFont(self.title_font)
|
||||||
|
info_container_layout.addWidget(self.title)
|
||||||
|
|
||||||
|
self.artist = QLabel("Artist", self.info_container)
|
||||||
|
self.artist.setFont(self.artist_font)
|
||||||
|
info_container_layout.addWidget(self.artist)
|
||||||
|
|
||||||
|
self.album = QLabel("Album", self.info_container)
|
||||||
|
self.album.setFont(self.album_font)
|
||||||
|
info_container_layout.addWidget(self.album)
|
||||||
|
|
||||||
|
def update_info(self):
|
||||||
|
current_playlist = self.app.player.current_playlist
|
||||||
|
|
||||||
|
if current_playlist is not None:
|
||||||
|
current_track = current_playlist.current_track
|
||||||
|
title = current_track.tags.title
|
||||||
|
artist = current_track.tags.artist
|
||||||
|
album = current_track.tags.album
|
||||||
|
cover_data = current_track.tags.images.any.data
|
||||||
|
|
||||||
|
self.title.setText(title)
|
||||||
|
|
||||||
|
if artist is not None and not artist == "":
|
||||||
|
self.artist.setText(f"By {current_track.tags.artist}")
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.artist.setText("No Artist")
|
||||||
|
|
||||||
|
if album is not None and not album == "":
|
||||||
|
self.album.setText(f"In {current_track.tags.album}")
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.album.setText("No Album")
|
||||||
|
|
||||||
|
if isinstance(cover_data, bytes):
|
||||||
|
cover_pixmap = QPixmap()
|
||||||
|
cover_pixmap.loadFromData(cover_data)
|
||||||
|
|
||||||
|
self.track_cover.setPixmap(cover_pixmap)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.track_cover.setPixmap(self.wobuzz_logo)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue