Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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