I have a project with Django. I am working on where I want to transfer some mp3 files.
I have the same problem: Streaming mp3 files with django read from a page with <audio>
Let me explain: I want an ogg stream with Django and with the <audio> in my html page
I have a url like domain.tld/song/show/X/ , where X is the identifier of my song. I can broadcast from VLC (directly with the file path), I can broadcast during the test (I write what I get and read it using VLC).
But when I open the browser and load my domain.tld homepage, where I have and <\audio\> balise with url domain.tld/song/show/1/ , I get a big broken channel, as if my client closed the connection .
I read on other posts that some problems were resolved when they put the server into production. So I push my application on the server, using apache, with django.wgsi , as on djangoproject.com.
I am running python 2.7.3 on Debian 7 with Django version 1.5. there is my code:
Song / views.py
def playAudioFile(request, pk): f = get_stream_song(pk)
In my HTML, I just have this:
<audio controls height="100" width="100" preload="auto"> <source src="/.../song/show/1/" type="audio/ogg"> <embed height="50" width="100" src="/.../song/show/1/"> </audio>
The error looks like this:
Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run self.finish_response() File "/usr/lib/python2.7/wsgiref/handlers.py", line 127, in finish_response self.write(data) File "/usr/lib/python2.7/wsgiref/handlers.py", line 215, in write self._write(data) File "/usr/lib/python2.7/socket.py", line 324, in write self.flush() File "/usr/lib/python2.7/socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 104] Connection reset by peer ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 46392) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/home/lumy/SPhoque/SonoPhoque/SoPhoque/local/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 150, in __init__ super(WSGIRequestHandler, self).__init__(*args, **kwargs) File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__ self.finish() File "/usr/lib/python2.7/SocketServer.py", line 704, in finish self.wfile.flush() File "/usr/lib/python2.7/socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 32] Broken pipe
I get this twice every time I try to stream.
Edit 15 hours 29/05:
I did what Rahan suggested: Looking at Firebug and the Firefox debugger:
The client performs:
GET 1 200 OK localhost:8000 537.1KB 4.71s Headers Response Headersview source Date Wed, 29 May 2013 13:08:54 GMT Server WSGIServer/0.1 Python/2.7.3 Content-Type audio/ogg Request Headersview source Host localhost:8000 User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20100101 Firefox/10.0.12 Iceweasel/10.0.12 Accept audio/webm,audio/ogg,audio/wav,audio*;q=0.5 Accept-Language en-us,en;q=0.5 Connection keep-alive Range bytes=0- Referer http:
and the details say that the total size for all documents is 1 MB (526 KB from the cache)