My plan to forward sound : laptop-> Hifi
is the following:
- use python/alsa to intercept the stream played on my laptop soundcard
- forward the stream to mpd running on a remote raspberry
The problem I have is that the remote mpd does not recognise the http stream that I send. I receive the following error :
ERROR: Failed to decode http://192.168.1.64:8000
I simply send a binary .wav file. There are some things that are checked to be OK:
- I can get the .wav file with wget, so that the server is OK
- the remote mpd can play a http stream if the stream is produced by a local mpd and an output plugin rather than by my python server.
This suggests that I am supposed to send something else than a simple .wav file.
Thanks for any help. Below, the probably problematic python code used to send the .wav file upon http.
Code: Select all
from http.server import HTTPServer, BaseHTTPRequestHandler class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.end_headers() with open("./test.wav", mode='rb') as file: # b is important -> binary fileContent = file.read() while fileContent: self.wfile.write(fileContent) fileContent = file.read() httpd = HTTPServer(('192.168.1.64', 8000), SimpleHTTPRequestHandler) httpd.serve_forever()