http streaming to my hifi

Cool stuff you can do with MPD. A place for you to put your hacks and patches, or be inspired by others'.
Post Reply
leLama
Posts: 2
Joined: December 4th, 2020, 1:01 pm

http streaming to my hifi

Post by leLama »

Hi all, thanks for this lightweight and efficient player :)

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()
leLama
Posts: 2
Joined: December 4th, 2020, 1:01 pm

Re: http streaming to my hifi

Post by leLama »

I converted my .wav file to .ogg ( and .flac) and this works now. Thus it means that it is not possible to send plain .wav file over http to mpd if I understand well.
max
Forum team
Posts: 1245
Joined: January 15th, 2013, 3:43 pm

Re: http streaming to my hifi

Post by max »

Post Reply