From 8d20c31849cc6a3e7829a1c2dc94151fed76bfa2 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 13 Jun 2024 08:53:55 +0200 Subject: [PATCH] Add settings option to disable gpu acceleration for video player FIXES: weird pink player bug (The user has to turn this option off, if they experience this problem) --- melon/models/__init__.py | 10 ++++++---- melon/player/__init__.py | 3 ++- melon/settings/__init__.py | 8 ++++++++ melon/widgets/player.py | 8 ++++---- po/de.po | 26 +++++++++++++++++--------- po/fa.po | 26 +++++++++++++++++--------- po/melon.pot | 26 +++++++++++++++++--------- po/nl.po | 26 +++++++++++++++++--------- 8 files changed, 88 insertions(+), 45 deletions(-) diff --git a/melon/models/__init__.py b/melon/models/__init__.py index 49aa058..b45b162 100644 --- a/melon/models/__init__.py +++ b/melon/models/__init__.py @@ -106,6 +106,9 @@ app_conf_template = { "nsfw_only_content": False, # do not include apps that require login by default "login_required": False, + # toggle opengl for video player + # turn this off if the video player is broken + "with_gl": True, } server_settings_template = { @@ -505,11 +508,10 @@ def set_app_setting(pref: str, value): execute_sql( conn, """ - UPDATE appconf - SET value = ? - WHERE key = ? + INSERT OR REPLACE INTO appconf + VALUES (?, ?) """, - (value, pref), + (pref, value), ) # notify channels and playlists, because available channels might be different conn.close() diff --git a/melon/player/__init__.py b/melon/player/__init__.py index f38ab79..242b5ce 100644 --- a/melon/player/__init__.py +++ b/melon/player/__init__.py @@ -63,7 +63,8 @@ class PlayerScreen(Adw.NavigationPage): def display_player(self): self.position = 0 self.duration = 0 - self.player = VideoPlayer(self.streams) + settings = get_app_settings() + self.player = VideoPlayer(self.streams, settings["with_gl"]) pos = get_video_playback_position(self.video.server, self.video.id) if not pos is None: self.position = pos diff --git a/melon/settings/__init__.py b/melon/settings/__init__.py index c24e817..27bf8d2 100644 --- a/melon/settings/__init__.py +++ b/melon/settings/__init__.py @@ -69,6 +69,14 @@ global_prefs = { True, True, ), + "with_gl": Preference( + "with_gl", + _("Use GPU acceleration for video player if available"), + _("Disable this if the video player doesn't work"), + PreferenceType.TOGGLE, + True, + True, + ), } diff --git a/melon/widgets/player.py b/melon/widgets/player.py index 1305336..cbb3000 100644 --- a/melon/widgets/player.py +++ b/melon/widgets/player.py @@ -115,7 +115,7 @@ class VideoPlayerBase(Gtk.Overlay): # inverse opacity of overlay brightness = 1.0 - def __init__(self, streams: list[Stream], *args, **kwargs): + def __init__(self, streams: list[Stream], with_gl=True, *args, **kwargs): super().__init__(*args, **kwargs) self.streams = streams self.stream = None @@ -145,7 +145,7 @@ class VideoPlayerBase(Gtk.Overlay): self.source = Gst.ElementFactory.make("playbin3") # Use GL if available - if paintable.props.gl_context: + if paintable.props.gl_context and with_gl: glsink = Gst.ElementFactory.make("glsinkbin", "sink") glsink.props.sink = gtksink sink = glsink @@ -632,10 +632,10 @@ class VideoPlayerBase(Gtk.Overlay): class VideoPlayer(Gtk.Stack): - def __init__(self, streams: list[Stream], *args, **kwargs): + def __init__(self, streams: list[Stream], with_gl=True, *args, **kwargs): super().__init__(*args, **kwargs) self.window = None - self.player = VideoPlayerBase(streams) + self.player = VideoPlayerBase(streams, with_gl) self.player.connect_toggle_fullscreen(self.toggle_fullscreen) self.player.connect_toggle_popout(self.toggle_popout) placeholder = Gtk.Label() diff --git a/po/de.po b/po/de.po index ed4e60d..f122046 100644 --- a/po/de.po +++ b/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Melon 0.1.2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-15 07:54+0200\n" +"POT-Creation-Date: 2024-07-15 07:56+0200\n" "PO-Revision-Date: 2024-04-20 14:18+0000\n" "Last-Translator: hurzelchen \n" @@ -90,7 +90,7 @@ msgstr "" #: ../melon/browse/server.py:115 ../melon/browse/server.py:143 #: ../melon/home/history.py:25 ../melon/home/new.py:36 #: ../melon/home/playlists.py:23 ../melon/home/subs.py:22 -#: ../melon/importer.py:63 ../melon/player/__init__.py:112 +#: ../melon/importer.py:63 ../melon/player/__init__.py:113 #: ../melon/player/playlist.py:164 ../melon/player/playlist.py:171 #: ../melon/playlist/__init__.py:77 msgid "*crickets chirping*" @@ -357,11 +357,11 @@ msgstr "Beschreibung" msgid "Add this video to a playlist" msgstr "Füge dieses Video einer Wiedergabeliste hinzu" -#: ../melon/player/__init__.py:113 +#: ../melon/player/__init__.py:114 msgid "Video could not be loaded" msgstr "Das Video konnte nicht geladen werden" -#: ../melon/player/__init__.py:151 ../melon/player/__init__.py:185 +#: ../melon/player/__init__.py:152 ../melon/player/__init__.py:186 #: ../melon/player/playlist.py:57 msgid "Loading..." msgstr "" @@ -730,23 +730,31 @@ msgid "" "function" msgstr "Zeige Dienste, für die du einen Account brauchst, beim Durchsuchen an" -#: ../melon/settings/__init__.py:78 +#: ../melon/settings/__init__.py:74 +msgid "Use GPU acceleration for video player if available" +msgstr "" + +#: ../melon/settings/__init__.py:75 +msgid "Disable this if the video player doesn't work" +msgstr "" + +#: ../melon/settings/__init__.py:86 msgid "Settings" msgstr "Einstellungen" -#: ../melon/settings/__init__.py:91 +#: ../melon/settings/__init__.py:99 msgid "General" msgstr "Allgemein" -#: ../melon/settings/__init__.py:92 +#: ../melon/settings/__init__.py:100 msgid "Global app settings" msgstr "Globale App Einstellungen" -#: ../melon/settings/__init__.py:116 +#: ../melon/settings/__init__.py:124 msgid "Enable Server" msgstr "Dienst aktivieren" -#: ../melon/settings/__init__.py:118 +#: ../melon/settings/__init__.py:126 msgid "" "Disabled servers won't show up in the browser or on the local/home screen" msgstr "" diff --git a/po/fa.po b/po/fa.po index 13e61ce..8b4b13e 100644 --- a/po/fa.po +++ b/po/fa.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Melon 0.1.2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-15 07:54+0200\n" +"POT-Creation-Date: 2024-07-15 07:56+0200\n" "PO-Revision-Date: 2024-05-30 09:18+0000\n" "Last-Translator: sohrabbehdani \n" @@ -96,7 +96,7 @@ msgstr "" #: ../melon/browse/server.py:115 ../melon/browse/server.py:143 #: ../melon/home/history.py:25 ../melon/home/new.py:36 #: ../melon/home/playlists.py:23 ../melon/home/subs.py:22 -#: ../melon/importer.py:63 ../melon/player/__init__.py:112 +#: ../melon/importer.py:63 ../melon/player/__init__.py:113 #: ../melon/player/playlist.py:164 ../melon/player/playlist.py:171 #: ../melon/playlist/__init__.py:77 #, fuzzy @@ -358,11 +358,11 @@ msgstr "توضیحات" msgid "Add this video to a playlist" msgstr "افزودن این ویدئو به لیست‌پخش" -#: ../melon/player/__init__.py:113 +#: ../melon/player/__init__.py:114 msgid "Video could not be loaded" msgstr "" -#: ../melon/player/__init__.py:151 ../melon/player/__init__.py:185 +#: ../melon/player/__init__.py:152 ../melon/player/__init__.py:186 #: ../melon/player/playlist.py:57 msgid "Loading..." msgstr "در حال بارکردن..." @@ -719,23 +719,31 @@ msgid "" "function" msgstr "" -#: ../melon/settings/__init__.py:78 +#: ../melon/settings/__init__.py:74 +msgid "Use GPU acceleration for video player if available" +msgstr "" + +#: ../melon/settings/__init__.py:75 +msgid "Disable this if the video player doesn't work" +msgstr "" + +#: ../melon/settings/__init__.py:86 msgid "Settings" msgstr "تنظیمات" -#: ../melon/settings/__init__.py:91 +#: ../melon/settings/__init__.py:99 msgid "General" msgstr "کلی" -#: ../melon/settings/__init__.py:92 +#: ../melon/settings/__init__.py:100 msgid "Global app settings" msgstr "تنظیمات کلی کاره" -#: ../melon/settings/__init__.py:116 +#: ../melon/settings/__init__.py:124 msgid "Enable Server" msgstr "فعال کردن کارساز" -#: ../melon/settings/__init__.py:118 +#: ../melon/settings/__init__.py:126 msgid "" "Disabled servers won't show up in the browser or on the local/home screen" msgstr "" diff --git a/po/melon.pot b/po/melon.pot index 534ae13..584ee33 100644 --- a/po/melon.pot +++ b/po/melon.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Melon 0.2.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-15 07:54+0200\n" +"POT-Creation-Date: 2024-07-15 07:56+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -83,7 +83,7 @@ msgstr "" #: ../melon/browse/server.py:115 ../melon/browse/server.py:143 #: ../melon/home/history.py:25 ../melon/home/new.py:36 #: ../melon/home/playlists.py:23 ../melon/home/subs.py:22 -#: ../melon/importer.py:63 ../melon/player/__init__.py:112 +#: ../melon/importer.py:63 ../melon/player/__init__.py:113 #: ../melon/player/playlist.py:164 ../melon/player/playlist.py:171 #: ../melon/playlist/__init__.py:77 msgid "*crickets chirping*" @@ -343,11 +343,11 @@ msgstr "" msgid "Add this video to a playlist" msgstr "" -#: ../melon/player/__init__.py:113 +#: ../melon/player/__init__.py:114 msgid "Video could not be loaded" msgstr "" -#: ../melon/player/__init__.py:151 ../melon/player/__init__.py:185 +#: ../melon/player/__init__.py:152 ../melon/player/__init__.py:186 #: ../melon/player/playlist.py:57 msgid "Loading..." msgstr "" @@ -692,23 +692,31 @@ msgid "" "function" msgstr "" -#: ../melon/settings/__init__.py:78 +#: ../melon/settings/__init__.py:74 +msgid "Use GPU acceleration for video player if available" +msgstr "" + +#: ../melon/settings/__init__.py:75 +msgid "Disable this if the video player doesn't work" +msgstr "" + +#: ../melon/settings/__init__.py:86 msgid "Settings" msgstr "" -#: ../melon/settings/__init__.py:91 +#: ../melon/settings/__init__.py:99 msgid "General" msgstr "" -#: ../melon/settings/__init__.py:92 +#: ../melon/settings/__init__.py:100 msgid "Global app settings" msgstr "" -#: ../melon/settings/__init__.py:116 +#: ../melon/settings/__init__.py:124 msgid "Enable Server" msgstr "" -#: ../melon/settings/__init__.py:118 +#: ../melon/settings/__init__.py:126 msgid "" "Disabled servers won't show up in the browser or on the local/home screen" msgstr "" diff --git a/po/nl.po b/po/nl.po index 0547674..c0b1877 100644 --- a/po/nl.po +++ b/po/nl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Melon 0.2.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-07-15 07:54+0200\n" +"POT-Creation-Date: 2024-07-15 07:56+0200\n" "PO-Revision-Date: 2024-04-23 12:18+0000\n" "Last-Translator: Vistaus \n" "Language-Team: Dutch