@@ -51,7 +51,7 @@ def play_audio_with_retry(file_path, duration=None, gain=0, system_volume=None,
5151
5252def get_player_priority (file_path ):
5353 """Get the preferred player."""
54- if sys .platform == "win32" :
54+ if sys .platform in ( "win32" , "darwin" ) :
5555 return ["vlc" ]
5656 return ["mpv" ]
5757
@@ -65,7 +65,7 @@ def execute_media(file_path, config=None):
6565
6666 success = False
6767 try :
68- if sys .platform == "win32" :
68+ if sys .platform in ( "win32" , "darwin" ) :
6969 success = play_video_vlc (file_path , config )
7070 player_name = "vlc"
7171 else :
@@ -86,24 +86,29 @@ def execute_media(file_path, config=None):
8686execute_video = execute_media
8787
8888def get_vlc_path ():
89- """Find the VLC executable natively on Windows."""
89+ """Find the VLC executable on Windows or macOS ."""
9090 vlc_path = shutil .which ("vlc" )
9191 if vlc_path :
9292 return vlc_path
93-
93+
9494 if sys .platform == "win32" :
9595 program_files = os .environ .get ("ProgramFiles" , "C:\\ Program Files" )
9696 program_files_x86 = os .environ .get ("ProgramFiles(x86)" , "C:\\ Program Files (x86)" )
97-
97+
9898 fallbacks = [
9999 os .path .join (program_files , "VideoLAN" , "VLC" , "vlc.exe" ),
100100 os .path .join (program_files_x86 , "VideoLAN" , "VLC" , "vlc.exe" )
101101 ]
102-
102+
103103 for path in fallbacks :
104104 if path and os .path .isfile (path ) and os .access (path , os .X_OK ):
105105 return path
106-
106+
107+ elif sys .platform == "darwin" :
108+ mac_vlc = "/Applications/VLC.app/Contents/MacOS/VLC"
109+ if os .path .isfile (mac_vlc ) and os .access (mac_vlc , os .X_OK ):
110+ return mac_vlc
111+
107112 return None
108113
109114def get_mpv_path ():
@@ -112,24 +117,24 @@ def get_mpv_path():
112117
113118def check_media_player_installed ():
114119 """Verify strictly if the native media player is installed."""
115- if sys .platform == "win32" :
120+ if sys .platform in ( "win32" , "darwin" ) :
116121 return get_vlc_path () is not None
117122 return get_mpv_path () is not None
118123
119124def detect_available_players ():
120125 """
121126 Detect which video players are installed on the system.
122- Returns: ['vlc'] on Windows, ['mpv'] on Linux.
127+ Returns: ['vlc'] on Windows/macOS , ['mpv'] on Linux.
123128 """
124129 available = []
125-
126- if sys .platform == "win32" :
130+
131+ if sys .platform in ( "win32" , "darwin" ) :
127132 if get_vlc_path ():
128133 available .append ("vlc" )
129134 else :
130135 if get_mpv_path ():
131136 available .append ("mpv" )
132-
137+
133138 return available
134139
135140def play_video_vlc (file_path , config = None ):
0 commit comments