The Samsung speakers have a RESTful like application program interface (API) that allows to control the speakers over HTTP. There is no authentication or any security check to control the speakers over the network.
The base endpoint is: https://ip_address_speaker
Port number: 55001
Method: GET
Endpoints: /UIC (Unified Interface Client) & /CPM Control Program Monitor or Control Processor Module
Request Parameters (command): ?cmd=value in XML format
Response: XML
1.) Send PLAY command to a speaker on ip address 192.168.1.22
/CPM?cmd=<name>SetPlaybackControl</name><p type="str" name="playbackcontrol" val="play"/>
urldecoded the complete parameter string:
http://192.168.1.22:55001/CPM?cmd=%3Cname%3ESetPlaybackControl%3C/name%3E%3Cp%20type=%22str%22%20name=%22playbackcontrol%22%20val=%22play%22/%3E
2.) Set input to BLUETOOTH on speaker 192.168.1.22
/UIC?cmd=<name>SetFunc</name><p type="str" name="function" val="bt"/>
urldecoded:
http://192.168.1.22:55001/UIC?cmd=%3Cname%3ESetFunc%3C/name%3E%3Cp%20type=%22str%22%20name=%22function%22%20val=%22bt%22/%3E
3. ) Set input to WiFi on speaker 192.168.1.22
/UIC?cmd=<name>SetFunc</name><p type="str" name="function" val="wifi"/>
http://192.168.1.22:55001/UIC?cmd=%3Cname%3ESetFunc%3C/name%3E%3Cp%20type=%22str%22%20name=%22function%22%20val=%22wifi%22/%3E
Useful linksfor urldecode:
The command parameters in an URL Decoded string:
XML Command:
<name>
GetMusicInfo
</name>
XML Command URL Encoded:
%3Cname%3EGetMusicInfo%3C/name%3E
HTTP get request to IP address of the speaker
http://ip_speaker:55001/UIC?cmd=%3Cname%3EGetMusicInfo%3C/name%3E
HTTP response message:
<?xml version="1.0" encoding="UTF-8"?>
<UIC><method>MusicInfo</method>
<version>1.0</version>
<speakerip>ip_speaker</speakerip>
<user_identifier>public</user_identifier>
<response result="ok">
<device_udn>uuid:xxxxxxxx-xxxxx-xxxxe-xxxxx-xxxxxxxxx</device_udn>
<playertype>myphone</playertype>
<playbacktype>playlist</playbacktype>
<sourcename><![CDATA[phone]]></sourcename>
<parentid>1$4</parentid>
<parentid2></parentid2>
<playindex>0</playindex>
<objectid><![CDATA[1$4$0]]></objectid>
<title><![CDATA[music_name]]></title>
<artist><![CDATA[]]></artist>
<album><![CDATA[]]></album>
<thumbnail><![CDATA[music_cover.png]]></thumbnail>
<timelength>0:52:29.688</timelength>
<playtime>2170944</playtime>
<seek>enable</seek>
<pause>enable</pause>
</response>
</UIC>
On April 2018, David shared how he could play a URL on the speakers.
Playing a URL on the Speakers and Older (non SoundPlus) Soundbars. I finally found the grail here. This is used in playTrackAndResume, playTrackAndRestore, and playTrack in the SmartThings. It is a NEW command to the lexicon.
/UIC?cmd=<pwron>on</pwron><name>SetUrlPlayback</name>
<p type="cdata" name="url" val="empty"><![CDATA[${urlTrack}]]>
</p><p type="dec" name="buffersize" val="0"/>
<p type="dec" name="seektime" val="0"/>
<p type="dec" name="resume" val="${resume}"/>
example 1 from David
command:
UIC?cmd=<name>SetUrlPlayback</name><p type="cdata" name="url" val="empty"><![CDATA[http://newt.phys.unsw.edu.au/music/bellplates/sounds/bellplate-corner4.mp3]]></p><p type="dec" name="buffersize" val="0"/><p type="dec" name="seektime" val="0"/><p type="dec" name="resume" val="1"/>
http://192.168.1.41:55001/UIC?cmd=%3Cname%3ESetUrlPlayback%3C/name%3E%3Cp%20type=%22cdata%22%20name=%22url%22%20val=%22empty%22%3E%3C!%5bCDATA%5bhttp://s3.amazonaws.com/smartapp-media/sonos/dogs.mp3%5d%5d%3E%3C/p%3E%3Cp%20type=%22dec%22%20name=%22buffersize%22%20val=%220%22/%3E%3Cp%20type=%22dec%22%20name=%22seektime%22%20val=%220%22/%3E%3Cp%20type=%22dec%22%20name=%22resume%22%20val=%221%22/%3E
example 2 from David:
UIC?cmd=<name>SetUrlPlayback</name><p type="cdata" name="url" val="empty"><![CDATA[http://newt.phys.unsw.edu.au/music/bellplates/sounds/bellplate-corner4.mp3]]></p><p type="dec" name="buffersize" val="0"/><p type="dec" name="seektime" val="0"/><p type="dec" name="resume" val="1"/>
http://192.168.1.41:55001/UIC?cmd=%3Cname%3ESetUrlPlayback%3C/name%3E%3Cp%20type=%22cdata%22%20name=%22url%22%20val=%22empty%22%3E%3C![CDATA[http://newt.phys.unsw.edu.au/music/bellplates/sounds/bellplate-corner4.mp3]]%3E%3C/p%3E%3Cp%20type=%22dec%22%20name=%22buffersize%22%20val=%220%22/%3E%3Cp%20type=%22dec%22%20name=%22seektime%22%20val=%220%22/%3E%3Cp%20type=%22dec%22%20name=%22resume%22%20val=%221%22/%3E
Variables: ${urlTrack} is a text string, no quotes. Example: http://s3.amazonaws.com/smartapp-media/sonos/dogs.mp3
${resume} is 0 or 1 (with quotes). 0 is do not resume. 1 is resume playing.
Playing a URL on the SoundPlus (newer) Soundbars: Use the port 9797 DMR / AVTransport UPnP commands.
Samsung multiroom speakers support grouping and surround setting feature. Users can set multiple Samsung speakers into a single group and send the same music content to the group. Also, users can set up their own surround system with multiple speakers. (Grouping among TVs and speakers is not supported.) The grouped speakers will be discovered by the group name and will be shown as a single group. The grouping setting is only available on Samsung Multiroom app.
On Aug 2017, Kamil did some additional research on how the grouping of the speakers work and published his java code on github.
After figuring out what the Grouping calls looked like I wanted to create a service that let me control them programmatically. I created a Java Springboot service that took group and ungroup calls and sent the right commands to the speakers. I also found out that the speakers are Spotify Connect capable. This means they use a multi-cast DNS technology (interoperable with Apple's Bonjour) for discovery. I found the mDNS type which is _spotify-connect._tcp.local. The speakers then respond with their IP. I then call the speaker for more info with the given IP to get the Mac address. That is all the info that is needed to send group and ungroup calls to the speakers. The following link is to the GitHub repo of the service I created. The service will auto discover the speakers and provide an endpoint to issue group and ungroup calls to it.
https://github.com/saykalik/SamsungSpeakerController
I have also created an Alexa skill and Amazon Lambda function that takes the call from Alexa and calls my server at home but it has hardcoded urls right now and I don't want anyone messing with my home services. I will clean that up and put it on GitHub as well.
User feedback:
2019 07 Kamil, I notice your mac address uses "-" and not ":". Mine worked with ":"
Encrypted commands
April 2019 : Peter H. reported that latest client seem to send encrypted strings over the wire. Thanks Peter for reporting this !
I found that all the outgoing web commands from the App are now aes128(?) encrypted strings, not plain text any longer. The replies still seem to be plain text.
Example:
GET KiMX5exB9g4uIowPOOWboiuKocwp9dQvy2UzG0JwqoMkFlOoGQib7p4/lU8UG9CB53e5BkfTn7uBh8g/a2lf+kXciBuRymz7wEOGZOGLW/xjxAGY9nVR33++keC0TbNF6SfMqyru6ilxRbPypP1NPRY0ra6d/WRD5c2IOKWfxw5wPuGB3Epl3XFNu4bL1dJ7VVwk6UvjBhMhfhlVFA0ttW079UWsypFrN
/xIyJ3XfP4ZU5UTMBMV8OB01F1wPw2/ZBgJ7YyRgYsELy0hjVjvlw/nH9gfQAeafD29+XYPlJrp8ErSLFnTWbG82J+uyEIb HTTP/1.1
Connection:interactive
Accept-Encoding:aes128
mobileUUID:ec18b42a-2a30-4b53-9204-ef8f33744de8
mobileName:SM-G900I
mobileVersion:6.0.1
19:37:37.224516 IP (tos 0x0, ttl 64, id 4734, offset 0, flags [DF], proto TCP (6), length 598)
samsungWAM750.bfree.wafreenet.55001 > 10.60.2.65.37108: Flags [P.], cksum 0x9442 (correct), seq 7434:7980, ack 2852, win 660, options [nop,nop,TS val 1690997 ecr 70045797], length 546
E..V.~@.@..O
<..
<.A....}....H.^.....B.....
...u.,.e
HTTP/1.1 200 OK
Date: Thu, 01 Jan 1970 01:52:43 GMT
Server: Samsung/1.0
Content-Type: text/html
Encoding: aes128
Content-Length: 340
Connection: close
################################################
The WAM750 still accepts the manual curl http://x.x.x.x:55001/CPM?cmd=<name>GetCpPlayerPlayList</name> type requests, but it does mean we cant use tcpdump to capture new features as they add them.
jul 2019 by Kamil = I just tried the command:
http://192.168.10.137:55001/UIC?cmd=<pwron>on</pwron><name>SetMultispkGroup</name><p type="cdata" name="name" val="empty"><![CDATA[Kitchen + Livingroom]]></p><p type="dec" name="index" val="1"/><p type="str" name="type" val="main"/><p type="dec" name="spknum" val="2"/><p type="str" name="audiosourcemacaddr" val="f8:77:b8:c4:8f:a1"/><p type="cdata" name="audiosourcename" val="empty"><![CDATA[Kitchen]]></p><p type="str" name="audiosourcetype" val="speaker"/><p type="str" name="subspkip" val="192.168.10.178"/><p type="str" name="subspkmacaddr" val="f8:77:b8:c4:8f:ca"/>
On my speakers using Postman and it worked (unencrypted). It looks like you only have to send a single command to the master speaker and it groups (I saw the grouping happen in the Samsung app). I can then send the ungroup command to that master and it releases them.
I notice your mac address uses "-" and not ":". Mine worked with ":"
It definitely hates the "-". Just tried it and I got the spinning and the only way to get rid of it is to change the input on the speaker. I think the issue with your command is the "-"