postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
841 stars 91 forks source link

How can I stream audio to multiple devices at once? #2088

Closed msalmonw closed 12 months ago

msalmonw commented 1 year ago

What do you need help with?

How can I stream audio to multiple devices at once? I want to stream audio to multiple speakers/devices at once, is there any way to achieve this?

postlund commented 1 year ago

Unfortunately I don't have added support for grouping devices yet, so it's not really possible (other than streaming the same audio in parallel, which wouldn't be synchronized).

msalmonw commented 12 months ago

Is there any workaround for this? If you have anything in your mind that could take me in the right direction, please let me know

postlund commented 12 months ago

Not using pyatv (I would have to implement support for that), but you can use other software that supports it, like owntone.

msalmonw commented 12 months ago

Is that something I could do myself? I'm developing an application in Python, so i'm stuck with pyatv

postlund commented 12 months ago

Sure! You'd have to start by figuring out the protocol changes needed for this and then add support for it in pyatv. I have not looked into this, so I have no idea how it works. I however suspect protocol changes needs per se are pretty minor. The hard part is to figure out a good API and internally synchronize sending of audio frames. My assumption is that you'd have to connect to all receivers with one pyatv.connect call per receiver and then group them together (with the newly added API) before streaming.

postlund commented 12 months ago

Owntone has an HTTP based API (REST I guess), so you could also run that separately and control it from python. Assuming that setup would be ok.

msalmonw commented 12 months ago

Yes, Owntone seems very promising now that I've studied it a little. Let's see if I can integrate it properly with my own application. Thanks a lot for your help!

postlund commented 12 months ago

Yeah, that's what I would recommend to use for now. Good luck! 👍