diff --git a/aeidon/enums.py b/aeidon/enums.py index 9ce9d8d8..03af8027 100644 --- a/aeidon/enums.py +++ b/aeidon/enums.py @@ -19,6 +19,7 @@ import aeidon import os +import shutil import sys from aeidon.i18n import _ @@ -159,6 +160,7 @@ class PlayerMPlayer(aeidon.EnumerationItem): # http://www.mplayerhq.hu/DOCS/HTML/en/faq.html#idm5930 command_utf_8 = "{} < /dev/null".format(command_utf_8) + found = shutil.which(_get_mplayer_executable()) is not None label = "MPlayer" class PlayerMPV(aeidon.EnumerationItem): @@ -179,6 +181,7 @@ class PlayerMPV(aeidon.EnumerationItem): "--sub-codepage=utf-8", "$VIDEOFILE",)) + found = shutil.which(_get_mpv_executable()) is not None label = "mpv" class PlayerVLC(aeidon.EnumerationItem): @@ -193,6 +196,7 @@ class PlayerVLC(aeidon.EnumerationItem): ":sub-file=$SUBFILE", ":subsdec-encoding=UTF-8",)) + found = shutil.which(_get_vlc_executable()) is not None label = "VLC" players = aeidon.Enumeration() diff --git a/gaupol/config.py b/gaupol/config.py index 240f6cda..fdf91380 100644 --- a/gaupol/config.py +++ b/gaupol/config.py @@ -143,10 +143,9 @@ "preview": { "custom_command": "", "force_utf_8": True, - "offset": (5.0 if sys.platform == "win32" else 1.0), - "player": (aeidon.players.VLC if sys.platform == "win32" - else aeidon.players.MPV), - + # mpv is the only player that supports precise seek, others need a longer offset. + "offset": 1.0 if gaupol.util.get_default_player() == aeidon.players.MPV else 5.0, + "player": gaupol.util.get_default_player(), "use_custom_command": False, }, "search": { diff --git a/gaupol/util.py b/gaupol/util.py index 7adea9a1..e6a94c5f 100644 --- a/gaupol/util.py +++ b/gaupol/util.py @@ -69,6 +69,12 @@ def get_content_size(widget, font=None): raise ValueError("Unsupported container type: {!r}" .format(type(widget))) +def get_default_player(): + """Return the default video player to use for preview.""" + players = [aeidon.players.MPV, aeidon.players.MPLAYER, aeidon.players.VLC] + players = [x for x in players if x.found] + return players[0] if players else aeidon.players.MPV + def get_font(): """Return custom font or blank string.""" return (gaupol.conf.editor.custom_font if