@@ -30,6 +30,52 @@ def __init__(self, lnxlink):
3030 if self .audio_system is None :
3131 self .mediavolume = "ON"
3232 self .media_player = self .dbus_mediaplayer .DBusMediaPlayers (self .media_callback )
33+ self .local_players = {
34+ "gst-play-1.0" : {
35+ "supported_media" : ["audio" , "video" , "image" ],
36+ "opt_static" : "--wait-on-eos" ,
37+ "opt_foreground" : "" ,
38+ "opt_background" : "" ,
39+ },
40+ "ffplay" : {
41+ "supported_media" : ["audio" , "video" , "image" ],
42+ "opt_static" : "" ,
43+ "opt_foreground" : "-autoexit" ,
44+ "opt_background" : "-nodisp -autoexit" ,
45+ },
46+ "mpv" : {
47+ "supported_media" : ["audio" , "video" , "image" , "playlist" , "other" ],
48+ "opt_static" : "--pause" ,
49+ "opt_foreground" : "--force-window" ,
50+ "opt_background" : "" ,
51+ },
52+ "cvlc" : {
53+ "supported_media" : ["audio" ],
54+ "opt_static" : "--play-and-exit" ,
55+ "opt_foreground" : "--play-and-exit" ,
56+ "opt_background" : "--play-and-exit" ,
57+ },
58+ "vlc" : {
59+ "supported_media" : ["audio" , "video" , "playlist" , "other" ],
60+ "opt_static" : "--play-and-exit" ,
61+ "opt_foreground" : "--play-and-exit" ,
62+ "opt_background" : "--play-and-exit" ,
63+ },
64+ }
65+ self .lnxlink .add_settings (
66+ "media" ,
67+ {
68+ "order" : list (self .local_players .keys ()),
69+ },
70+ )
71+ order = self .lnxlink .config ["settings" ]["media" ]["order" ]
72+ self .local_players = dict (
73+ sorted (
74+ self .local_players .items (),
75+ key = lambda x : order .index (x [0 ]) if x [0 ] in order else len (order ),
76+ )
77+ )
78+ print (self .local_players .keys ())
3379
3480 def _requirements (self ):
3581 self .dbus_mediaplayer = import_install_package (
@@ -206,44 +252,14 @@ def stop_playmedia(self):
206252 def play_media (self , data ):
207253 """Finds an plays media using one of the supported players"""
208254 self .stop_playmedia ()
209- players = {
210- "gst-play-1.0" : {
211- "supported_media" : ["audio" , "video" , "image" ],
212- "opt_static" : "--wait-on-eos" ,
213- "opt_foreground" : "" ,
214- "opt_background" : "" ,
215- },
216- "ffplay" : {
217- "supported_media" : ["audio" , "video" , "image" ],
218- "opt_static" : "" ,
219- "opt_foreground" : "-autoexit" ,
220- "opt_background" : "-nodisp -autoexit" ,
221- },
222- "mpv" : {
223- "supported_media" : ["audio" , "video" , "image" , "playlist" , "other" ],
224- "opt_static" : "--pause" ,
225- "opt_foreground" : "--force-window" ,
226- "opt_background" : "" ,
227- },
228- "cvlc" : {
229- "supported_media" : ["audio" ],
230- "opt_static" : "--play-and-exit" ,
231- "opt_foreground" : "--play-and-exit" ,
232- "opt_background" : "--play-and-exit" ,
233- },
234- "vlc" : {
235- "supported_media" : ["audio" , "video" , "playlist" , "other" ],
236- "opt_static" : "--play-and-exit" ,
237- "opt_foreground" : "--play-and-exit" ,
238- "opt_background" : "--play-and-exit" ,
239- },
240- }
241255 audio_extentions = [".mp3" , ".wav" , ".ogg" , ".wma" , ".aac" ]
242256 video_extentions = [".mp4" , ".avi" , ".mov" , ".mkv" , ".mpg" , ".mpeg" ]
243257 image_extentions = [".jpg" , ".jpeg" , ".png" , ".gif" , ".ico" ]
244258 url = data ["media_id" ]
245259 media_type = "other"
246- if ".m3u" in url :
260+ if ".mpegurl" in data ["media_type" ]:
261+ media_type = "video"
262+ elif ".m3u" in url :
247263 media_type = "playlist"
248264 elif any (ext in url for ext in audio_extentions ):
249265 media_type = "audio"
@@ -260,7 +276,7 @@ def play_media(self, data):
260276 elif "image" in data ["media_type" ]:
261277 media_type = "image"
262278
263- for player , options in players .items ():
279+ for player , options in self . local_players .items ():
264280 if which (player ) is not None :
265281 if media_type not in options ["supported_media" ]:
266282 continue
@@ -272,7 +288,8 @@ def play_media(self, data):
272288 self .playmedia_thread .start ()
273289 return
274290 logger .error (
275- "You don't have any player installed on your system: %s" , players .keys ()
291+ "You don't have any player installed on your system: %s" ,
292+ self .local_players .keys (),
276293 )
277294
278295 def run_playmedia_thread (self , player , options , url , media_type ):
0 commit comments