You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-26 21:53:54 +01:00
procman play set in and out fades. (i plan to turn the fade in and out bools into floats)
This commit is contained in:
@@ -23,7 +23,7 @@ class Process:
|
|||||||
class Skeleton_ProcessManager:
|
class Skeleton_ProcessManager:
|
||||||
processes: list[Process]
|
processes: list[Process]
|
||||||
def _get_audio_duration(self, file_path): ...
|
def _get_audio_duration(self, file_path): ...
|
||||||
def play(self, track: Track, fade_time: int=5) -> Process: ...
|
def play(self, track: Track, fade_in_time: int=0, fade_out_time: int=0) -> Process: ...
|
||||||
def anything_playing(self) -> bool: ...
|
def anything_playing(self) -> bool: ...
|
||||||
def stop_all(self, timeout: float | None = None) -> None: ...
|
def stop_all(self, timeout: float | None = None) -> None: ...
|
||||||
def wait_all(self, timeout: float | None = None) -> None: ...
|
def wait_all(self, timeout: float | None = None) -> None: ...
|
||||||
@@ -65,7 +65,7 @@ class ProcmanCommunicator(BaseIMCModule):
|
|||||||
elif int(op) == 4:
|
elif int(op) == 4:
|
||||||
return {"op": 4, "arg": self.procman.anything_playing()}
|
return {"op": 4, "arg": self.procman.anything_playing()}
|
||||||
elif int(op) == 5:
|
elif int(op) == 5:
|
||||||
if arg := data.get("arg"): return {"op": 5, "arg": self.procman.play(arg, data.get("fade_time", 5))}
|
if arg := data.get("arg"): return {"op": 5, "arg": self.procman.play(arg, data.get("fade_in_time", data.get("fade_time", 5)), data.get("fade_out_time", data.get("fade_time", 5)))}
|
||||||
else: return
|
else: return
|
||||||
|
|
||||||
class PlayerModule(BaseIMCModule):
|
class PlayerModule(BaseIMCModule):
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ProcessManager(Skeleton_ProcessManager):
|
|||||||
result = float(result.stdout.strip())
|
result = float(result.stdout.strip())
|
||||||
self.duration_cache.saveElement(file_path.as_posix(), result, (60*60*2), False, True)
|
self.duration_cache.saveElement(file_path.as_posix(), result, (60*60*2), False, True)
|
||||||
return result
|
return result
|
||||||
def play(self, track: Track, fade_time: int=5) -> Process:
|
def play(self, track: Track, fade_in_time: int=0, fade_out_time: int=0) -> Process:
|
||||||
assert track.path.exists()
|
assert track.path.exists()
|
||||||
cmd = ['ffplay', '-nodisp', '-hide_banner', '-autoexit', '-loglevel', 'quiet']
|
cmd = ['ffplay', '-nodisp', '-hide_banner', '-autoexit', '-loglevel', 'quiet']
|
||||||
|
|
||||||
@@ -38,8 +38,8 @@ class ProcessManager(Skeleton_ProcessManager):
|
|||||||
if track.offset > 0: cmd.extend(['-ss', str(track.offset)])
|
if track.offset > 0: cmd.extend(['-ss', str(track.offset)])
|
||||||
|
|
||||||
filters = []
|
filters = []
|
||||||
if track.fade_in and fade_time != 0: filters.append(f"afade=t=in:st=0:d={fade_time}")
|
if track.fade_in and fade_in_time != 0: filters.append(f"afade=t=in:st=0:d={fade_in_time}")
|
||||||
if track.fade_out and fade_time != 0: filters.append(f"afade=t=out:st={duration - fade_time - track.offset}:d={fade_time}")
|
if track.fade_out and fade_out_time != 0: filters.append(f"afade=t=out:st={duration - fade_out_time}:d={fade_out_time}")
|
||||||
if filters: cmd.extend(['-af', ",".join(filters)])
|
if filters: cmd.extend(['-af', ",".join(filters)])
|
||||||
cmd.append(str(track.path.absolute()))
|
cmd.append(str(track.path.absolute()))
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ class RadioPlayer:
|
|||||||
self.logger.info(f"Now playing: {track.path.name}")
|
self.logger.info(f"Now playing: {track.path.name}")
|
||||||
prefetch(track.path)
|
prefetch(track.path)
|
||||||
|
|
||||||
pr = self.procman.play(track, cross_fade)
|
pr = self.procman.play(track, cross_fade, cross_fade)
|
||||||
[module.on_new_track(song_i, pr.track, next_track) for module in self.simple_modules if module]
|
[module.on_new_track(song_i, pr.track, next_track) for module in self.simple_modules if module]
|
||||||
|
|
||||||
end_time = pr.started_at + pr.duration
|
end_time = pr.started_at + pr.duration
|
||||||
|
|||||||
Reference in New Issue
Block a user