Skip to content

Commit 4b6c9d9

Browse files
committed
fixing: MPV Volume resets to 0% when trying to increase beyond maximum #251
1 parent c92afac commit 4b6c9d9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pyradio/player.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,6 +2464,8 @@ class MpvPlayer(Player):
24642464
if os.path.exists(mpvsocket):
24652465
os.system('rm ' + mpvsocket + ' 2>/dev/null');
24662466

2467+
max_vol = 130
2468+
24672469
commands = {
24682470
'volume_up': b'{ "command": ["cycle", "volume", "up"], "request_id": 1000 }\n',
24692471
'volume_down': b'{ "command": ["cycle", "volume", "down"], "request_id": 1001 }\n',
@@ -2714,15 +2716,17 @@ def _stop(self):
27142716

27152717
def _volume_up(self):
27162718
''' increase mpv's volume '''
2717-
self._send_mpv_command('volume_up')
2719+
self.get_volume()
2720+
if self.volume < self.max_vol:
2721+
self._send_mpv_command('volume_up')
27182722
self._display_mpv_volume_value()
27192723

27202724
def _volume_down(self):
27212725
''' decrease mpv's volume '''
27222726
self.get_volume()
27232727
if self.volume > 0:
27242728
self._send_mpv_command('volume_down')
2725-
self._display_mpv_volume_value()
2729+
self._display_mpv_volume_value()
27262730

27272731
def _format_title_string(self, title_string):
27282732
''' format mpv's title '''

0 commit comments

Comments
 (0)