diff --git a/rtcllm/aav.py b/rtcllm/aav.py index 0e6ac1a..e069915 100644 --- a/rtcllm/aav.py +++ b/rtcllm/aav.py @@ -7,6 +7,7 @@ class MyMediaPlayer(MediaPlayer): class MyTrackBasea: def __init__(self, source=None): + self.reloaded = False self.source = source self.track = self.set_track() self.track.on('ended', self.reload) @@ -17,9 +18,10 @@ class MyTrackBasea: else: self.track = self.source.video - def self.reload(self): + def reload(self): print(f'reload the source----{self.source._file_path}') self.set_source(MyMediaPlayer(self.source._file_path)) + self.reloaded = True def set_source(self, source): self.source = source @@ -29,10 +31,10 @@ class MyTrackBasea: if self.source is None: return None f = await self.source.audio.recv() - while f is None: + while self.reloaded: print('MyAudioTrack::recv(): will reload source') - self.set_source(MyMediaPlayer(self.source._file_path)) f = await self.source.audio.recv() + self.reloaded = False return f