Skip to content

Commit

Permalink
Added the ability to increase the volume up to 200%
Browse files Browse the repository at this point in the history
  • Loading branch information
Communist02 committed Sep 6, 2023
1 parent 34b7d7b commit 65fabac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
6 changes: 4 additions & 2 deletions localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
'Paste': 'Paste',
'Screenshot': 'Screenshot',
'Take a screenshot': 'Take a screenshot',
'Enter folder path for screenshots': 'Enter folder path for screenshots'
'Enter folder path for screenshots': 'Enter folder path for screenshots',
'Increase maximum volume up to 200%': 'Increase maximum volume up to 200%'
}

ru = {
Expand Down Expand Up @@ -115,7 +116,8 @@
'Paste': 'Вставить',
'Screenshot': 'Cкриншот',
'Take a screenshot': 'Сделать скриншот',
'Enter folder path for screenshots': 'Введите путь до папки для скриншотов'
'Enter folder path for screenshots': 'Введите путь до папки для скриншотов',
'Increase maximum volume up to 200%': 'Увеличить максимальную громкость до 200%'
}

match locale.getlocale()[0]:
Expand Down
28 changes: 21 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
import icons
import fonts

name_program = 'Anime Player'
version = '1.0 Release Candidate 2'
loc = localization.strings
formats = ('mp4', 'mkv', 'webm', 'avi', 'mov', 'wmv', '3gp', 'm4a', 'mp3', 'flac', 'ogg', 'aac', 'opus', 'wav')


def make_window(title: str = 'Anime Player', is_pause: bool = True, files_list: list = None, filenum: int = 0, volume: int = 100, is_files_list_visible: bool = False):
if files_list is None:
Expand Down Expand Up @@ -46,6 +51,7 @@ def make_window(title: str = 'Anime Player', is_pause: bool = True, files_list:
sg.theme('dark')
else:
sg.theme('light')
volume_plus = sg.user_settings_get_entry('volumePlus', False)
localization.set_locale(sg.user_settings_get_entry('language'))
tabs = []
for quality in anime4k.qualities:
Expand Down Expand Up @@ -117,7 +123,8 @@ def make_window(title: str = 'Anime Player', is_pause: bool = True, files_list:
sg.Button(key='-PLAY-', image_data=icons.play if is_pause else icons.pause, button_color=sg.theme_background_color(), border_width=0, tooltip=loc['Play']),
sg.Button(key='-NEXT-', image_source=icons.next, button_color=sg.theme_background_color(), border_width=0, tooltip=loc['Next file']),
sg.Button(key='-MENU-', image_source=icons.menu, button_color=sg.theme_background_color(), border_width=0, tooltip=loc['Menu']),
sg.Slider(orientation='h', key='-VOLUME-', default_value=volume, enable_events=True, range=(0, 100), size=(12, 16), pad=((5, 5), (0, 8)), tooltip=loc['Sound level'])
sg.Slider(orientation='h', key='-VOLUME-', default_value=volume, enable_events=True, range=(0, 100 if not volume_plus else 200), size=(12, 16), pad=((5, 5), (0, 8)),
tooltip=loc['Sound level'])
]
], expand_x=True, pad=(0, 0)),
]
Expand Down Expand Up @@ -156,11 +163,6 @@ def make_window(title: str = 'Anime Player', is_pause: bool = True, files_list:
return main_window


formats = ('mp4', 'mkv', 'webm', 'avi', 'mov', 'wmv', '3gp', 'm4a', 'mp3', 'flac', 'ogg', 'aac', 'opus', 'wav')
name_program = 'Anime Player'
version = '1.0 Release Candidate 1'
loc = localization.strings

window: sg.Window = make_window()
player: MPV = MPV(wid=window['-VID_OUT-'].Widget.winfo_id(), keep_open=True, profile='gpu-hq', hwdec='auto')

Expand Down Expand Up @@ -614,8 +616,10 @@ def main():
else:
player.time_pos = 0
case 'Up:38':
if player.volume > 95:
if player.volume > 95 and window['-VOLUME-'].Range[1] == 100:
player.volume = 100
elif player.volume > 195 and window['-VOLUME-'].Range[1] == 200:
player.volume = 200
else:
player.volume += 5
window['-VOLUME-'].update(value=player.volume)
Expand Down Expand Up @@ -768,6 +772,9 @@ def main():
[
sg.Checkbox(loc['Set the position of the last opened file'], key='-POS_LAST_FILE-', default=sg.user_settings_get_entry('onPosLastFile', True))
],
[
sg.Checkbox(loc['Increase maximum volume up to 200%'], key='-VOLUME_PLUS-', default=sg.user_settings_get_entry('volumePlus', False))
],
[
sg.Checkbox(loc['Activate SVP'], key='-SVP-', default=sg.user_settings_get_entry('SVP', False))
],
Expand All @@ -789,6 +796,13 @@ def main():
sg.user_settings_set_entry('onPosLastFile', values['-POS_LAST_FILE-'])
sg.user_settings_set_entry('SVP', values['-SVP-'])

if sg.user_settings_get_entry('volumePlus', lang) != values['-VOLUME_PLUS-']:
if not values['-VOLUME_PLUS-'] and player.volume > 100:
player.volume = 100
window['-VOLUME-'].update(value=100)
window['-VOLUME-'].update(range=(0, 100 if not values['-VOLUME_PLUS-'] else 200))
sg.user_settings_set_entry('volumePlus', values['-VOLUME_PLUS-'])

if sg.user_settings_get_entry('language', lang) != values['-LANGUAGE-'] or sg.user_settings_get_entry('darkTheme', False) != values['-DARK_THEME-']:
sg.user_settings_set_entry('language', values['-LANGUAGE-'])
sg.user_settings_set_entry('darkTheme', values['-DARK_THEME-'])
Expand Down

0 comments on commit 65fabac

Please sign in to comment.