setPlaybackContent and network audio

251 Views Asked by At

ref: https://developer.sony.com/develop/audio-control-api/api-references/api-overview-2#_setplaycontent_v1_2

Is it possible to play an mp3 stored on a webserver, e.g. http://example.com/myfile.mp3? Or even better, a Shoutcast mp3 stream URL?

The API docs do not really give many examples of the URI parameter for the setPlayContent function. Just a single DLNA mp3 example. And the Device URI page is very vague: https://developer.sony.com/develop/audio-control-api/api-references/device-uri

Thanks in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

It is not possible to play streaming audio from the internet (e.g. Shoutcast, etc) on the Sony STR-DN1080 using the Sony Audio Control API. However, it can be done using the built-in Chromecast Audio device, as per this answer on another question. For example, one can use the Google Cast SDK or an alternative such as Chromecast Java API v2.

I cannot speak of the Google Cast SDK, but I managed to get Shoutcast streams to play on the Sony STR-DN1080 using Chromecast Java API v2. In some cases one may need to append ;stream.mp3 to the Shoutcast stream URL, e.g. http://s2.onweb.gr:8604/ becomes http://s2.onweb.gr:8604/;stream.mp3.

I have had success playing MP3, AAC, Opus, FLAC, and Ogg streams. I hope that this helps someone.

4
On

Yes and No, you can't do it via the setplaycontent, you have to use the DLNA protocol instead. To do this use the "SetAVTransportURI" message to select the music file to play set CurrentURI=http://example.com/myfile.mp3 and add some dummy data if you can't get it automatically for the rest, the device is cutie picky so you might have to experiment to get the correct format of the message. I have also had some problem in the past then using "example.com" the DNS lookup have not always worked for me so use ip number instead is safer. There is no support for Shoutcast, some streaming mp3 files works but not all.

Have a look at https://github.com/sonydevworld/audio_control_api_examples/blob/master/DLNA/AVTransport/play_file.adoc for more detailed information.