Created
December 2, 2015 09:03
-
-
Save mendel129/a9cfc45a76f89a869f38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function play(){ | |
$var = getstate | |
if($var -eq "Paused") | |
{ | |
$play='<?xml version="1.0" encoding="utf-8"?> | |
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> | |
<s:Body> | |
<u:Play xmlns:u="urn:av-openhome-org:service:Playlist:1" /> | |
</s:Body> | |
</s:Envelope>' | |
$custHeaders = @{ "SOAPACTION"= '"urn:av-openhome-org:service:Playlist:1#Play"' }; | |
$url="http://192.168.1.28:62613/dev/5448c4e7-7178-7701-0000-000014b24816/svc/av-openhome-org/Playlist/action" | |
$drop=Invoke-WebRequest -Uri $url -Method:Post -ContentType:'text/xml; charset="utf-8"' -Headers $custHeaders -body $play | out-null | |
} | |
else | |
{ | |
write-warning "Already playing" | |
} | |
} | |
function getstate() | |
{ | |
$custHeaders = @{ "SOAPACTION"= '"urn:av-openhome-org:service:Playlist:1#TransportState"' }; | |
$statequery='<?xml version="1.0" encoding="utf-8"?> | |
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> | |
<s:Body> | |
<u:TransportState xmlns:u="urn:av-openhome-org:service:Playlist:1" /> | |
</s:Body> | |
</s:Envelope>' | |
$url="http://192.168.1.28:62613/dev/5448c4e7-7178-7701-0000-000014b24816/svc/av-openhome-org/Playlist/action" | |
$postData = [System.Text.Encoding]::UTF8.GetBytes($statequery) | |
Invoke-WebRequest -Uri $url -Method:Post -ContentType:'text/xml; charset="utf-8"' -Headers $custHeaders -body $postData -Outfile .\temp.txt | |
[xml]$status = Get-Content .\temp.txt -Encoding UTF8 | |
return [string]$status.envelope.body.transportstateresponse.value | |
} | |
function pause(){ | |
$var = getstate | |
if($var -eq "Playing") | |
{ | |
$custHeaders = @{ "SOAPACTION"= '"urn:av-openhome-org:service:Playlist:1#Pause"' }; | |
$pause=' | |
<?xml version="1.0" encoding="utf-8"?> | |
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> | |
<s:Body> | |
<u:Pause xmlns:u="urn:av-openhome-org:service:Playlist:1" /> | |
</s:Body> | |
</s:Envelope>' | |
$url="http://192.168.1.28:62613/dev/5448c4e7-7178-7701-0000-000014b24816/svc/av-openhome-org/Playlist/action" | |
$drop=Invoke-WebRequest -Uri $url -Method:Post -ContentType:'text/xml; charset="utf-8"' -Headers $custHeaders -body $pause | out-null | |
} | |
else | |
{write-warning "Already paused"} | |
} | |
function setvolume($volume) | |
{ | |
$custHeaders = @{ "SOAPACTION"= '"urn:av-openhome-org:service:Volume:1#SetVolume"' }; | |
$pause=" | |
<?xml version=`"1.0`" encoding=`"utf-8`"?> | |
<s:Envelope s:encodingStyle=`"http://schemas.xmlsoap.org/soap/encoding/`" xmlns:s=`"http://schemas.xmlsoap.org/soap/envelope/`"> | |
<s:Body> | |
<u:SetVolume xmlns:u=`"urn:av-openhome-org:service:Volume:1`"> | |
<Value>$($volume)</Value> | |
</u:SetVolume> | |
</s:Body> | |
</s:Envelope>" | |
$url="http://192.168.1.28:49193/dev/5448c4e7-7178-7701-0000-000014b24816/svc/av-openhome-org/Volume/action" | |
$drop=Invoke-WebRequest -Uri $url -Method:Post -ContentType:'text/xml; charset="utf-8"' -Headers $custHeaders -body $pause | out-null | |
} | |
#setvolume 50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment