You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I follow the example "examples/server/server.py" and try to use audio streaming capability of the MediaPlayer. It works when I use third-party URL (https://radio.liferadiolive.com:1580/stream) but never starts a URL from the same web application as the example. My IP Address is 192.168.0.100, the code is here:
async def offer(request):
...
player = MediaPlayer('https://192.168.0.100:8000/stream') # blocks execution forever
# player = MediaPlayer("https://radio.liferadiolive.com:1580/stream") # works perfectly
# player = MediaPlayer(os.path.join(ROOT, "demo-instruct.wav")) # works perfectly
I try to feed the media player with stream data from the same host and I implemented the function:
async def handle_stream(request):
response = web.StreamResponse()
response.headers['Content-Type'] = 'audio/pcm' # Modify content type as per your audio format
await response.prepare(request)
while True:
try:
# Read data from the queue and write it to the response stream
data = await queue.get()
await response.write(data)
except asyncio.CancelledError:
break
return response
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I follow the example "examples/server/server.py" and try to use audio streaming capability of the MediaPlayer. It works when I use third-party URL (https://radio.liferadiolive.com:1580/stream) but never starts a URL from the same web application as the example. My IP Address is 192.168.0.100, the code is here:
I try to feed the media player with stream data from the same host and I implemented the function:
and added the URL here:
My problem is that "handle_stream" never calls. Is this disabled by design or am I doing something wrong?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions