Bitte entschuldigt den Saustall im Baustein, hab grad gesehen, dass viele nicht benutzte Funktionen enthalten sind... Vielleicht braucht die ja jemand...
Einen Teil der Funktionen hab ich aus dem alten Forum, weiß nicht mehr von wem. Vielen Dank dafür!

Status = -1 error, 0 - stopped, 1 - paused, 2 - playing
Quelle = 1=Playlist, 2=Radio, 3=Input, 4=Slave, 5=8Tracks, 6=Spotify, 7=TV (nur Playbar), 8=Apple Music
AQ1 = Player 1 Status
AQ2 = Player 1 Quelle
AQ3 = Player 2 Status
AQ4 = Player 2 Quelle
...
AQ9 = Player 5 Status
AQ10 = Player 5 Quelle
// Sonos Status char* SonosAddress; //Player Wohnzimmer char* SonosAddress1 = "/dev/tcp/10.0.1.21/1400"; // Player Bad char* SonosAddress2 = "/dev/tcp/10.0.1.23/1400"; // Player WC char* SonosAddress3 = "/dev/tcp/10.0.1.24/1400"; // Player Schlafzimmer char* SonosAddress4 = "/dev/tcp/10.0.1.25/1400"; // Player Küche char* SonosAddress5 = "/dev/tcp/10.0.1.22/1400"; #define BUFF_SIZE 40000 #define RD_BLOCK_SIZE 128 int nEvents, Event; int Running = 0; int curstate = -1; char* curinfo = "No info"; // Function to decode chars // char* DecodeText(char* Text) { char *ptr = strstr(Text, "&amp;"); if (ptr!=NULL) do { strcpy(Text+(strlen(Text)-strlen(ptr)), "&"); strcpy(Text+(strlen(Text)-strlen(ptr)+1),ptr+9); ptr = strstr(Text, "&amp;"); } while (ptr!=NULL); return Text; } // End Functon // Function witch returns the state off the player. -1 error, 0 - stopped, 1 - paused, 2 - playing int GetPlayerStatus(char* PlayerAddress) { int State = -1; char *pS; char* cstate; STREAM* pTcpStream = stream_create(PlayerAddress,0,0); char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 272\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetTransportInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetTransportInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetTransportInfo></s:Body></s:Envelope> "; stream_write(pTcpStream,Command,strlen(Command)); stream_flush(pTcpStream); char szBuffer[BUFF_SIZE]; char szTmpBuffer[RD_BLOCK_SIZE]; int nCnt; int i = 0; do { nCnt = stream_read(pTcpStream,szTmpBuffer,RD_BLOCK_SIZE,4000); if(nCnt > 0) strncpy((char*)szBuffer+i*RD_BLOCK_SIZE,szTmpBuffer,nCnt); i++; } while (nCnt > 0); pS = szBuffer; while(*pS) { cstate = strstr(pS, "STOPPED"); if (cstate !=NULL) { State = 0; } cstate = strstr(pS, "PAUSED"); if (cstate !=NULL) { State = 1; } cstate = strstr(pS, "PLAYING"); if (cstate !=NULL) { State = 2; } pS += (strlen(pS) + 1); } stream_close(pTcpStream); return State; } // End Function // Function witch gets information on the current song char* GetPositionInfo(char* PlayerAddress) { char rInfo[BUFF_SIZE]; STREAM* InfoStream = stream_create(PlayerAddress,0,0); char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; stream_write(InfoStream,Command,strlen(Command)); stream_flush(InfoStream); char InfoBuffer[4000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt); i++; } while (iCnt > 0); stream_close(InfoStream); strcpy(rInfo,InfoBuffer); return rInfo; } // End Function // Function witch gets information on the current song char* GetMediaInfo(char* PlayerAddress) { char sreturn[2000]; STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; stream_write(InfoStream,Command,strlen(Command)); stream_flush(InfoStream); char InfoBuffer[BUFF_SIZE]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char* cURI = "<CurrentURI>"; char* cURIMDend = "</CurrentURIMetaData>"; int length; char URI[4000]; char *pS; pS = InfoBuffer; p = strstrskip(pS, cURI); if (p!=NULL) { pp = strstr(p, cURIMDend); length = strlen(p)-strlen(pp); strncpy(URI, p, length); } strcpy(sreturn, URI); return URI; } // End Function // Function witch gets information on the current song char* GetVolume(char* PlayerAddress) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; stream_write(InfoStream,Command,strlen(Command)); stream_flush(InfoStream); char InfoBuffer[BUFF_SIZE]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* p; char* pp; char strVol[4]; pS = InfoBuffer; p = strstrskip(pS, "<CurrentVolume>"); int length; if (p!=NULL) { pp = strstr(p, "</CurrentVolume>"); length = strlen(p)-strlen(pp); strncpy(strVol, p, length); } char* retVol = strVol; return retVol; } // End Function // Function to set AV URI int SetAVuri(char* PlayerAddress, char* URICom) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; char Command[2000]; char* p = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:SetAVTransportURI "; strcpy(Command, "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:SetAVTransportURI "); strcat(Command, "xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><CurrentURI>"); strcat(Command, URICom); strcat(Command, "</CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>"); char Header[2000]; strcpy(Header, "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\n"); strcat(Header, "CONNECTION: close\r\nCONTENT-LENGTH: "); char* commLen; sprintf(commLen, "%d", 309 + strlen(URICom)); strcat(Header, commLen); strcat(Header, "\r\nCONTENT-TYPE: text/xml; "); strcat(Header, "charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI\"\r\n\r\n"); char Send[4000]; strcpy(Send, Header); strcat(Send, Command); stream_write(InfoStream,Send,strlen(Send)); stream_flush(InfoStream); //free(Send); //free(Header); //free(Command); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); int OK = 0; char *pS; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { OK = 1; } return OK; } // End Function // Function play int SetPlay(char* PlayerAddress) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#Play\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:Play xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope> "; stream_write(InfoStream,Command,strlen(Command)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* p; char* pp; char strVol[4]; int OK = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { OK = 1; } return OK; } // End Function // Function stop int SetStop(char* PlayerAddress) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#Stop\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:Stop xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Speed>1</Speed></u:Stop></s:Body></s:Envelope> "; stream_write(InfoStream,Command,strlen(Command)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* p; char* pp; char strVol[4]; int OK = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { OK = 1; } return OK; } // End Function // Function to set Vol int SetVolume(char* PlayerAddress, char* Vol) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; char Command[2000]; char* p = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:SetVolume "; strcpy(Command, "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:SetVolume "); strcat(Command, "xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel><DesiredVolume>"); strcat(Command, Vol); strcat(Command, "</DesiredVolume></u:SetVolume></s:Body></s:Envelope>"); char Header[2000]; strcpy(Header, "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\n"); strcat(Header, "CONNECTION: close\r\nCONTENT-LENGTH: "); char* commLen; sprintf(commLen, "%d", strlen(Command)); strcat(Header, commLen); strcat(Header, "\r\nCONTENT-TYPE: text/xml; "); strcat(Header, "charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#SetVolume\"\r\n\r\n"); char Send[4000]; strcpy(Send, Header); strcat(Send, Command); stream_write(InfoStream,Send,strlen(Send)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* pp; char strVol[4]; int fin = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { fin = 1; } return fin; } // End Function // Function Seek Track int Seek(char* PlayerAddress, char* Unit, char* Value) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; char Command[2000]; strcpy(Command, "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:Seek "); strcat(Command, "xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Unit>"); strcat(Command, Unit); strcat(Command, "</Unit><Target>"); strcat(Command, Value); strcat(Command, "</Target></u:Seek></s:Body></s:Envelope>"); char Header[2000]; strcpy(Header, "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\n"); strcat(Header, "CONNECTION: close\r\nCONTENT-LENGTH: "); char* commLen; sprintf(commLen, "%d", strlen(Command)); strcat(Header, commLen); strcat(Header, "\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#Seek\"\r\n\r\n "); char Send[4000]; strcpy(Send, Header); strcat(Send, Command); stream_write(InfoStream,Send,strlen(Send)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* pp; char strVol[4]; int fin = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { fin = 1; } return fin; } // End Function // Function Save Queue char* SaveQueue(char* PlayerAddress, char* Title, char* ID) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); char Command[2000]; strcpy(Command, "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:SaveQueue "); strcat(Command, "xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Title>"); strcat(Command, Title); strcat(Command, "</Title><ObjectID>"); strcat(Command, ID); strcat(Command,"</ObjectID></u:SaveQueue></s:Body></s:Envelope>"); char Header[2000]; strcpy(Header, "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\n"); strcat(Header, "CONNECTION: close\r\nCONTENT-LENGTH: "); char* commLen; sprintf(commLen, "%d", strlen(Command)); strcat(Header, commLen); strcat(Header, "\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#SaveQueue\"\r\n\r\n "); char Send[4000]; strcpy(Send, Header); strcat(Send, Command); stream_write(InfoStream,Send,strlen(Send)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char* p; char* pp; char strSQ[10]; char* pS = InfoBuffer; p = strstrskip(pS, "<AssignedObjectID>"); int length; if (p!=NULL) { pp = strstr(p, "</AssignedObjectID>"); length = strlen(p)-strlen(pp); strncpy(strSQ, p, length); } char* retSQ = strSQ; return retSQ; } // End Function // Function Load Playlist int LoadPlaylist(char* PlayerAddress, char* ID) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); char Command[2000]; strcpy(Command, "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:AddURIToQueue "); strcat(Command, "xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><EnqueuedURI>file:///jffs/settings/savedqueues.rsq#"); char* IDNr; IDNr = strstrskip(ID, "SQ:"); if (IDNr!=NULL) { strcat(Command, IDNr); } strcat(Command, "</EnqueuedURI><EnqueuedURIMetaData><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id=""); strcat(Command, ID); strcat(Command, "" parentID="SQ:" restricted="true"><dc:title>Temp</dc:title><upnp:class>object.container.playlistContainer</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">RINCON_AssociatedZPUDN</desc></item></DIDL-Lite></EnqueuedURIMetaData><DesiredFirstTrackNumberEnqueued>0</DesiredFirstTrackNumberEnqueued><EnqueueAsNext>1</EnqueueAsNext></u:AddURIToQueue></s:Body></s:Envelope>"); //strcpy(Command, "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:AddURIToQueue xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><EnqueuedURI>file:///jffs/settings/savedqueues.rsq#19</EnqueuedURI><EnqueuedURIMetaData><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="SQ:19" parentID="SQ:" restricted="true"><dc:title>Temp</dc:title><upnp:class>object.container.playlistContainer</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">RINCON_AssociatedZPUDN</desc></item></DIDL-Lite></EnqueuedURIMetaData><DesiredFirstTrackNumberEnqueued>0</DesiredFirstTrackNumberEnqueued><EnqueueAsNext>0</EnqueueAsNext></u:AddURIToQueue></s:Body></s:Envelope> "); char Header[1000]; strcpy(Header, "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\n"); strcat(Header, "CONNECTION: close\r\nCONTENT-LENGTH: "); char* commLen; sprintf(commLen, "%d", strlen(Command)); strcat(Header, commLen); strcat(Header, "\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#AddURIToQueue\"\r\n\r\n "); char Send[2000]; strcpy(Send, Header); strcat(Send, Command); stream_write(InfoStream,Send,strlen(Send)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* pp; char strVol[4]; int fin = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { fin = 1; } return fin; } // End Function // Function Clear Queue int ClearQueue(char* PlayerAddress) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#Play\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:Play xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope> "; char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#RemoveAllTracksFromQueue\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:RemoveAllTracksFromQueue xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:RemoveAllTracksFromQueue></s:Body></s:Envelope> "; stream_write(InfoStream,Command,strlen(Command)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* p; char* pp; char strVol[4]; int OK = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { OK = 1; } return OK; } // End Function //Funciton Destroy Object int destroyObject(char* PlayerAddress, char* ID) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; char Command[2000]; strcpy(Command, "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:DestroyObject "); strcat(Command, "xmlns:u=\"urn:schemas-upnp-org:service:ContentDirectory:1\"><ObjectID>"); strcat(Command, ID); strcat(Command, "</ObjectID></u:DestroyObject></s:Body></s:Envelope>"); char Header[2000]; strcpy(Header, "POST /MediaServer/ContentDirectory/Control HTTP/1.1\r\n"); strcat(Header, "CONNECTION: close\r\nCONTENT-LENGTH: "); char* commLen; sprintf(commLen, "%d", strlen(Command)); strcat(Header, commLen); strcat(Header, "\r\nCONTENT-TYPE: text/xml; "); strcat(Header, "charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:ContentDirectory:1#DestroyObject\"\r\n\r\n"); char Send[4000]; strcpy(Send, Header); strcat(Send, Command); stream_write(InfoStream,Send,strlen(Send)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* pp; char strVol[4]; int fin = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { fin = 1; } return fin; } // End Function // Function Ramp to Volume int RampToVolume(char* PlayerAddress, char* Vol, char* Type) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; char Command[2000]; strcpy(Command, "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><u:RampToVolume "); strcat(Command, "xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel><RampType>"); char* strType = Type; if (strlen(Type) == 0) { strType = "AUTOPLAY_RAMP_TYPE"; } strcat(Command, strType); strcat(Command, "</RampType><DesiredVolume>"); strcat(Command, Vol); strcat(Command, "</DesiredVolume><ResetVolumeAfter>false</ResetVolumeAfter><ProgramURI></ProgramURI></u:RampToVolume></s:Body></s:Envelope>"); char Header[2000]; strcpy(Header, "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\n"); strcat(Header, "CONNECTION: close\r\nCONTENT-LENGTH: "); char* commLen; sprintf(commLen, "%d", strlen(Command)); strcat(Header, commLen); strcat(Header, "\r\nCONTENT-TYPE: text/xml; "); strcat(Header, "charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#RampToVolume\"\r\n\r\n"); char Send[4000]; strcpy(Send, Header); strcat(Send, Command); stream_write(InfoStream,Send,strlen(Send)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* pp; char strVol[4]; int fin = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { fin = 1; } return fin; } // End Function // Function becomeAlone int becomeAlone(char* PlayerAddress) { STREAM* InfoStream = stream_create(PlayerAddress,0,0); //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 295\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetPositionInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetPositionInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetPositionInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#GetMediaInfo\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetMediaInfo xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:GetMediaInfo></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/RenderingControl/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 290\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetVolume xmlns:u=\"urn:schemas-upnp-org:service:RenderingControl:1\"><InstanceID>0</InstanceID><Channel>Master</Channel></u:GetVolume></s:Body></s:Envelope> "; //char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 266\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#Play\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:Play xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope> "; char* Command = "POST /MediaRenderer/AVTransport/Control HTTP/1.1\r\nCONNECTION: close\r\nCONTENT-LENGTH: 310\r\nCONTENT-TYPE: text/xml; charset=\"utf-8\"\r\nSOAPACTION: \"urn:schemas-upnp-org:service:AVTransport:1#BecomeCoordinatorOfStandaloneGroup\"\r\n\r\n<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:BecomeCoordinatorOfStandaloneGroup xmlns:u=\"urn:schemas-upnp-org:service:AVTransport:1\"><InstanceID>0</InstanceID></u:BecomeCoordinatorOfStandaloneGroup></s:Body></s:Envelope> "; stream_write(InfoStream,Command,strlen(Command)); stream_flush(InfoStream); char InfoBuffer[1000]; char InfoTmpBuffer[RD_BLOCK_SIZE]; int iCnt; int i = 0; do { iCnt = stream_read(InfoStream,InfoTmpBuffer,RD_BLOCK_SIZE ,4000); if(iCnt > 0) strncpy((char*)InfoBuffer+i*RD_BLOCK_SIZE,InfoTmpBuffer,iCnt);; i++; } while (iCnt > 0); stream_close(InfoStream); char *pS; char* p; char* pp; char strVol[4]; int OK = 0; pS = InfoBuffer; p = strstr(pS, "OK"); if (p!=NULL) { OK = 1; } return OK; } // End Function while(1==1) { char* actURI; char* actTime; char* actTrack; int actM; int Step; int read = 0; int readOK; // Status der Sonos player ermitteln // Sonos Status ermitteln int state; if (Step == 0){ SonosAddress = SonosAddress1; read = 1; Step = 1; } if (Step == 1){ if (readOK == 1){ setoutput(0,state); setoutput(1,actM); read = 0; readOK = 0; Step = 2; } } if (Step == 2){ sleeps(1); Step = 4; } if (Step == 4){ SonosAddress = SonosAddress2; read = 1; Step = 5; } if (Step == 5){ if (readOK == 1){ setoutput(2,state); setoutput(3,actM); read = 0; readOK = 0; Step = 6; } } if (Step == 6){ sleeps(1); Step = 8; } if (Step == 8){ SonosAddress = SonosAddress3; read = 1; Step = 9; } if (Step == 9){ if (readOK == 1){ setoutput(4,state); setoutput(5,actM); read = 0; readOK = 0; Step = 10; } } if (Step == 10){ sleeps(1); Step = 11; } if (Step == 11){ SonosAddress = SonosAddress4; read = 1; Step = 12; } if (Step == 12){ if (readOK == 1){ setoutput(6,state); setoutput(7,actM); read = 0; readOK = 0; sleeps(1); Step = 13; } } if (Step == 13){ SonosAddress = SonosAddress5; read = 1; Step = 14; } if (Step == 14){ if (readOK == 1){ setoutput(8,state); setoutput(9,actM); read = 0; readOK = 0; Step = 15; } } if (Step == 15){ sleeps(5); Step = 0; } if (read == 1){ state = GetPlayerStatus(SonosAddress); char* info = GetPositionInfo(SonosAddress); char* cURIend = "</TrackURI>"; char* cURI = "<TrackURI>"; char* cTrack = "<Track>"; char* cTrackend = "</Track>"; char* cTime = "<RelTime>"; char* cTimeend = "</RelTime>"; char TrURI[2000]; char Track[3]; char Time[20]; char* p; char* pp; char rString; char* tempin = strstr(info, "Envelope"); p = strstrskip(info, cURI); int length; if (p!=NULL) { pp = strstr(p, cURIend); length = strlen(p)-strlen(pp); strncpy(TrURI, p, length); } setoutputtext(0,TrURI); p = strstrskip(tempin, cTrack); if (p!=NULL) { pp = strstr(p, cTrackend); length = strlen(p)-strlen(pp); strncpy(Track, p, length); } p = strstrskip(tempin, cTime); if (p!=NULL) { pp = strstr(p, cTimeend); length = strlen(p)-strlen(pp); strncpy(Time, p, length); } actM = -1; // Aktuelles Medium ist Playlist p = strstr(TrURI, "file"); if (p!=NULL) { actM = 1; } // Aktuelles Medium ist Radio p = strstr(TrURI, "radio"); if (p!=NULL) { actM = 2; } // Aktuelles Medium ist Input p = strstr(TrURI, "rincon-stream:"); if (p!=NULL) { actM = 3; } // Aktuelles Medium ist Slave p = strstr(TrURI, "rincon:"); if (p!=NULL) { actM = 4; } // Aktuelles Medium ist 8-Tracks p = strstr(TrURI, "sonosprog"); if (p!=NULL) { actM = 5; } // Aktuelles Medium ist Spotify p = strstr(TrURI, "spotify"); if (p!=NULL) { actM = 6; } // Aktuelles Medium ist TV p = strstr(TrURI, "x-sonos-htastream"); if (p!=NULL) { actM = 7; } // Aktuelles Medium ist Apple Music p = strstr(TrURI, "x-sonos-http"); if (p!=NULL) { actM = 8; } char* Vol = GetVolume(SonosAddress); int iVol = atoi(Vol); readOK = 1; } sleep(100); //sleeps(100000); }
Hier noch der Befehl für Beats 1 (nur mit Apple Music):
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><CurrentURI>x-sonosapi-hls:hls%3ara.978194965?sid=204&flags=8224& sn=2</CurrentURI><CurrentURIMetaData><DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"><item id="00092020hls%3ara.978194965" parentID="00082064view%3aradio" restricted="true"><dc:title>Bea ts 1</dc:title><upnp:class>object.item.audioIte m.audioBroadcast</upnp:class><desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON52231_X_#Svc52231-0-Token</desc></item></DIDL-Lite></CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>
Kommentar