Fix inability to play tracks with colon in path

Fixes #103
This commit is contained in:
Keith Edmunds 2022-12-17 19:47:17 +00:00
parent 30bd23c088
commit d9851adf65
3 changed files with 8 additions and 9 deletions

View File

@ -12,6 +12,7 @@ class Config(object):
CART_DIRECTORY = "/home/kae/radio/CartTracks" CART_DIRECTORY = "/home/kae/radio/CartTracks"
CARTS_COUNT = 10 CARTS_COUNT = 10
CARTS_HIDE = True CARTS_HIDE = True
COLON_IN_PATH_FIX = True
COLOUR_BITRATE_LOW = "#ffcdd2" COLOUR_BITRATE_LOW = "#ffcdd2"
COLOUR_BITRATE_MEDIUM = "#ffeb6f" COLOUR_BITRATE_MEDIUM = "#ffeb6f"
COLOUR_BITRATE_OK = "#dcedc8" COLOUR_BITRATE_OK = "#dcedc8"

View File

@ -56,20 +56,14 @@ def fade_point(
return int(trim_ms) return int(trim_ms)
def file_is_readable(path: str, check_colon: bool = True) -> bool: def file_is_readable(path: str) -> bool:
""" """
Returns True if passed path is readable, else False Returns True if passed path is readable, else False
vlc cannot read files with a colon in the path vlc cannot read files with a colon in the path
""" """
if os.access(path, os.R_OK): return os.access(path, os.R_OK)
if check_colon:
return ':' not in path
else:
return True
return False
def get_audio_segment(path: str) -> Optional[AudioSegment]: def get_audio_segment(path: str) -> Optional[AudioSegment]:

View File

@ -111,6 +111,10 @@ class Music:
status = -1 status = -1
self.track_path = path self.track_path = path
if Config.COLON_IN_PATH_FIX:
media = self.VLC.media_new_path(path)
self.player = media.player_new_from_media()
else:
self.player = self.VLC.media_player_new(path) self.player = self.VLC.media_player_new(path)
if self.player: if self.player:
self.player.audio_set_volume(self.max_volume) self.player.audio_set_volume(self.max_volume)