This commit is contained in:
yumoqing 2024-09-11 14:59:09 +08:00
parent b74c2f9b2a
commit 0fdd1e0dae

View File

@ -1,7 +1,7 @@
import random import random
from traceback import print_exc from traceback import print_exc
from aiortc.contrib.media import MediaBlackhole, MediaPlayer, MediaRecorder, MediaRelay from aiortc.contrib.media import MediaBlackhole, MediaPlayer, MediaRecorder, MediaRelay
from aiortc import MediaStreamTrack, VideoStreamTrack, AudioStreamTrack from aiortc import MediaStreamTrack, VideoStreamTrack, AudioStreamTrack, MediaStreamError
class MyMediaPlayer(MediaPlayer): class MyMediaPlayer(MediaPlayer):
pass pass
@ -47,6 +47,7 @@ class MyAudioStreamTrack(AudioStreamTrack):
try: try:
return await self._recv() return await self._recv()
except MediaStreamError: except MediaStreamError:
print(f'{self.__class__.__name__} reach ended of the media ...')
self.source_reload() self.source_reload()
return await self._recv() return await self._recv()
except Exception as e: except Exception as e:
@ -84,6 +85,7 @@ class MyVideoStreamTrack(VideoStreamTrack):
try: try:
return await self._recv() return await self._recv()
except MediaStreamError: except MediaStreamError:
print(f'{self.__class__.__name__} reach ended of the media ...')
self.source_reload() self.source_reload()
return self._recv() return self._recv()
except Exception as e: except Exception as e: