Fix (workaround) volume going to zero after track starts
This commit is contained in:
parent
8a6812e405
commit
4a927084c9
@ -130,7 +130,7 @@ class Music:
|
|||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def set_volume(self, volume, set_default=True):
|
def set_volume(self, volume=None, set_default=True):
|
||||||
"""Set maximum volume used for player"""
|
"""Set maximum volume used for player"""
|
||||||
|
|
||||||
if not self.player:
|
if not self.player:
|
||||||
@ -139,6 +139,9 @@ class Music:
|
|||||||
if set_default:
|
if set_default:
|
||||||
self.max_volume = volume
|
self.max_volume = volume
|
||||||
|
|
||||||
|
if volume is None:
|
||||||
|
volume = Config.VOLUME_VLC_DEFAULT
|
||||||
|
|
||||||
self.player.audio_set_volume(volume)
|
self.player.audio_set_volume(volume)
|
||||||
|
|
||||||
def stop(self) -> float:
|
def stop(self) -> float:
|
||||||
|
|||||||
@ -301,6 +301,29 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.timer.start(Config.TIMER_MS)
|
self.timer.start(Config.TIMER_MS)
|
||||||
self.connect_signals_slots()
|
self.connect_signals_slots()
|
||||||
|
|
||||||
|
def about(self) -> None:
|
||||||
|
"""Get git tag and database name"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
git_tag = str(
|
||||||
|
subprocess.check_output(
|
||||||
|
['git', 'describe'], stderr=subprocess.STDOUT
|
||||||
|
)
|
||||||
|
).strip('\'b\\n')
|
||||||
|
except subprocess.CalledProcessError as exc_info:
|
||||||
|
git_tag = str(exc_info.output)
|
||||||
|
|
||||||
|
with Session() as session:
|
||||||
|
if session.bind:
|
||||||
|
dbname = session.bind.engine.url.database
|
||||||
|
|
||||||
|
QMessageBox.information(
|
||||||
|
self,
|
||||||
|
"About",
|
||||||
|
f"MusicMuster {git_tag}\n\nDatabase: {dbname}",
|
||||||
|
QMessageBox.StandardButton.Ok
|
||||||
|
)
|
||||||
|
|
||||||
def cart_configure(self, cart: Carts, btn: CartButton) -> None:
|
def cart_configure(self, cart: Carts, btn: CartButton) -> None:
|
||||||
"""Configure button with cart data"""
|
"""Configure button with cart data"""
|
||||||
|
|
||||||
@ -821,29 +844,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
self.stop_playing(fade=True)
|
self.stop_playing(fade=True)
|
||||||
|
|
||||||
def about(self) -> None:
|
|
||||||
"""Get git tag and database name"""
|
|
||||||
|
|
||||||
try:
|
|
||||||
git_tag = str(
|
|
||||||
subprocess.check_output(
|
|
||||||
['git', 'describe'], stderr=subprocess.STDOUT
|
|
||||||
)
|
|
||||||
).strip('\'b\\n')
|
|
||||||
except subprocess.CalledProcessError as exc_info:
|
|
||||||
git_tag = str(exc_info.output)
|
|
||||||
|
|
||||||
with Session() as session:
|
|
||||||
if session.bind:
|
|
||||||
dbname = session.bind.engine.url.database
|
|
||||||
|
|
||||||
QMessageBox.information(
|
|
||||||
self,
|
|
||||||
"About",
|
|
||||||
f"MusicMuster {git_tag}\n\nDatabase: {dbname}",
|
|
||||||
QMessageBox.StandardButton.Ok
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_one_track(self, session: scoped_session) -> Optional[Tracks]:
|
def get_one_track(self, session: scoped_session) -> Optional[Tracks]:
|
||||||
"""Show dialog box to select one track and return it to caller"""
|
"""Show dialog box to select one track and return it to caller"""
|
||||||
|
|
||||||
@ -1234,6 +1234,18 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# Play (new) current track
|
# Play (new) current track
|
||||||
self.current_track.start()
|
self.current_track.start()
|
||||||
self.music.play(self.current_track.path, position)
|
self.music.play(self.current_track.path, position)
|
||||||
|
# For as-yet unknown reasons. sometimes the volume gets
|
||||||
|
# reset to zero within 200mS or so of starting play. This
|
||||||
|
# only happened since moving to Debian 12, which uses
|
||||||
|
# Pipewire for sound (which may be irrelevant).
|
||||||
|
for _ in range(3):
|
||||||
|
if self.music.player:
|
||||||
|
volume = self.music.player.audio_get_volume()
|
||||||
|
if volume < 10:
|
||||||
|
self.music.set_volume()
|
||||||
|
log.error(f"Reset from {volume=}")
|
||||||
|
break
|
||||||
|
sleep(0.1)
|
||||||
|
|
||||||
# Tell database to record it as played
|
# Tell database to record it as played
|
||||||
Playdates(session, self.current_track.track_id)
|
Playdates(session, self.current_track.track_id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user