Skip to content

Commit

Permalink
Add volume percentage to the volume label
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlie committed Oct 22, 2024
1 parent d2226ba commit 04079b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/musicPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,14 @@ def initUI(self):
self.progress_bar.setRange(0, 100)
self.sliders_layout.addWidget(self.progress_bar)

self.volume_label = QLabel("Volume:")
self.get_volume = self.config.get("volume_percantage", 100)
self.volume_label = QLabel(f"Volume: {self.get_volume}%")
self.sliders_layout.addWidget(self.volume_label)

self.volume_slider = QSlider(Qt.Horizontal)
self.volume_slider.setMinimum(0)
self.volume_slider.setMaximum(100)
self.get_volume = self.config.get("volume_percantage", 100)

self.volume_slider.setValue(self.get_volume)
self.volume_slider.setTickPosition(QSlider.TicksBelow)
self.volume_slider.setTickInterval(10)
Expand Down Expand Up @@ -508,6 +509,7 @@ def adjust_volume(self, value):
"""Adjusts the volume of the music player."""
volume = value / 100.0
mixer.music.set_volume(volume)
self.volume_label.setText(f"Volume: {value}%")
#logging.info(f"Volume set to: {volume}")

def keyPressEvent(self, event):
Expand Down

0 comments on commit 04079b0

Please sign in to comment.