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
from traceback import print_exc
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):
pass
@ -47,6 +47,7 @@ class MyAudioStreamTrack(AudioStreamTrack):
try:
return await self._recv()
except MediaStreamError:
print(f'{self.__class__.__name__} reach ended of the media ...')
self.source_reload()
return await self._recv()
except Exception as e:
@ -84,6 +85,7 @@ class MyVideoStreamTrack(VideoStreamTrack):
try:
return await self._recv()
except MediaStreamError:
print(f'{self.__class__.__name__} reach ended of the media ...')
self.source_reload()
return self._recv()
except Exception as e: