From dd2887c2db888065f11534b2fe180d1ca7deb191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 27 Jul 2016 15:50:33 +0200 Subject: Fix absolute path when using music_path --- helpers/music_file.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/helpers/music_file.py b/helpers/music_file.py index 916b955..2d3ba72 100644 --- a/helpers/music_file.py +++ b/helpers/music_file.py @@ -101,10 +101,15 @@ class MusicFile: def reload_music_file(self): with file_lock: try: + if self.filename.startswith("/"): + filename = self.filename + else: + filename = Config.music_path + self.filename + debug_print("Reloading « {} »".format(self.name)) initial_db_gain = gain(self.initial_volume_factor * 100) self.audio_segment = pydub.AudioSegment \ - .from_file(Config.music_path + self.filename) \ + .from_file(filename) \ .set_frame_rate(Config.frame_rate) \ .set_channels(Config.channels) \ .set_sample_width(Config.sample_width) \ @@ -121,11 +126,16 @@ class MusicFile: def on_enter_loading(self): with file_lock: try: + if self.filename.startswith("/"): + filename = self.filename + else: + filename = Config.music_path + self.filename + debug_print("Loading « {} »".format(self.name)) self.mixer = self.mapping.mixer or Mixer() initial_db_gain = gain(self.initial_volume_factor * 100) self.audio_segment = pydub.AudioSegment \ - .from_file(Config.music_path + self.filename) \ + .from_file(filename) \ .set_frame_rate(Config.frame_rate) \ .set_channels(Config.channels) \ .set_sample_width(Config.sample_width) \ -- cgit v1.2.3