bugfix
This commit is contained in:
parent
8f00665eb6
commit
35de168787
@ -8,33 +8,30 @@ class MyMediaPlayer(MediaPlayer):
|
||||
class MyTrackBase(MediaStreamTrack):
|
||||
def __init__(self, source=None):
|
||||
super().__init__()
|
||||
self.reloaded = False
|
||||
self.source = source
|
||||
self.set_track()
|
||||
self.set_source_track()
|
||||
print(f'{self.kind=}, {self.__class__.__name__}')
|
||||
|
||||
def set_track(self):
|
||||
def set_source_track(self):
|
||||
if self.kind == 'audio':
|
||||
self.track = self.source.audio
|
||||
else:
|
||||
self.track = self.source.video
|
||||
self.track.on('ended', self.reload)
|
||||
|
||||
def reload(self):
|
||||
def source_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
|
||||
self.set_track()
|
||||
self.set_source_track()
|
||||
|
||||
async def recv(self):
|
||||
print(f'{self.__class__.__name__}, {self.source.duration=}, {self.source.time=}')
|
||||
if self.source is None:
|
||||
return None
|
||||
if self.track.readyState != 'live':
|
||||
self.reload()
|
||||
self.source_reload()
|
||||
f = await self.track.recv()
|
||||
return f
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user