1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Presentation page for Controlling a UPnP Television</TITLE>
</HEAD>
<BODY>
<H3><P ID=FName>Device Name</P></H3>
<H3>TvDevice Control State Table</H3>
<TABLE BGCOLOR='#D6D7DE' BORDER=0 VALIGN=top ALIGN=left CELLPADDING=1 CELLSPACING=3>
<TR>
<TD BGCOLOR='#000000' VALIGN=center ALIGN=center WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Variable</FONT></B></TD>
<TD VALIGN=middle ALIGN=left BGCOLOR='#000000' WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Value</FONT></B></TD>
<TD VALIGN=middle ALIGN=left BGCOLOR='#000000' WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Actions</FONT></B></TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Power</TD>
<TD BGCOLOR="#FFFFFF" valign="top"><P ID=Power></P></TD>
<TD BGCOLOR="#FFFFFF" valign="top">
<INPUT type="button" onclick="SetPowerOn()" value=" On ">
<INPUT type="button" onclick="SetPowerOff()" value=" Off ">
</TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Channel</TD>
<TD BGCOLOR="#FFFFFF" valign="top"><P ID=Channel></P></TD>
<TD BGCOLOR="#FFFFFF" valign="top">
<INPUT type="button" onclick="IncreaseChannel()" value=" Up ">
<INPUT type="button" onclick="DecreaseChannel()" value=" Down ">
</TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Volume</TD>
<TD BGCOLOR="#FFFFFF" valign="top"><P ID=Volume></P></TD>
<TD BGCOLOR="#FFFFFF" valign="top">
<INPUT type="button" onclick="IncreaseVolume()" value=" Up ">
<INPUT type="button" onclick="DecreaseVolume()" value=" Down ">
</TD>
</TR>
</TABLE>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<H3>TvDevice Picture State Table</H3>
<TABLE BGCOLOR='#D6D7DE' BORDER=0 VALIGN=top ALIGN=left CELLPADDING=1 CELLSPACING=3>
<TR>
<TD BGCOLOR='#000000' VALIGN=center ALIGN=center WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Variable</FONT></B></TD>
<TD VALIGN=middle ALIGN=left BGCOLOR='#000000' WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Value</FONT></B></TD>
<TD VALIGN=middle ALIGN=left BGCOLOR='#000000' WIDTH=60><B><FONT SIZE="2" COLOR=whitesmoke>Actions</FONT></B></TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Color</TD>
<TD BGCOLOR="#FFFFFF" valign="top"><P ID=Color></P></TD>
<TD BGCOLOR="#FFFFFF" valign="top">
<INPUT type="button" onclick="IncreaseColor()" value=" Up ">
<INPUT type="button" onclick="DecreaseColor()" value=" Down ">
</TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Tint</TD>
<TD BGCOLOR="#FFFFFF" valign="top"><P ID=Tint></P></TD>
<TD BGCOLOR="#FFFFFF" valign="top">
<INPUT type="button" onclick="IncreaseTint()" value=" Up ">
<INPUT type="button" onclick="DecreaseTint()" value=" Down ">
</TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Contrast</TD>
<TD BGCOLOR="#FFFFFF" valign="top"><P ID=Contrast></P></TD>
<TD BGCOLOR="#FFFFFF" valign="top">
<INPUT type="button" onclick="IncreaseContrast()" value=" Up ">
<INPUT type="button" onclick="DecreaseContrast()" value=" Down ">
</TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF" VALIGN=center ALIGN=center>Brightness</TD>
<TD BGCOLOR="#FFFFFF" valign="top"><P ID=Brightness></P></TD>
<TD BGCOLOR="#FFFFFF" valign="top">
<INPUT type="button" onclick="IncreaseBrightness()" value=" Up ">
<INPUT type="button" onclick="DecreaseBrightness()" value=" Down ">
</TD>
</TR>
</TABLE>
<H3> </H3>
<SCRIPT language=VBScript>
' *********************************************************
' Event handler called when the UPnP device submits events
' *********************************************************
Sub eventHandler(callbackType, svcObj, varName, value)
'Dim output
'output = output & "varName " & varName & vbCrLf
'output = output & "value " & value & vbCrLf
'output = output & "svcObj " & svcObj.Id & vbCrLf
'MsgBox output
If (callbackType = "VARIABLE_UPDATE") Then
select case svcObj.Id
case "urn:upnp-org:serviceId:tvcontrol1"
select case varName
Case "Power" Power.innerText = value
Case "Channel" Channel.innerText = value
Case "Volume" Volume.innerText = value
end select
case "urn:upnp-org:serviceId:tvpicture1"
select case varName
Case "Color" Color.innerText = value
Case "Tint" Tint.innerText = value
Case "Contrast" Contrast.innerText = value
Case "Brightness" Brightness.innerText = value
end select
end select
End If
End Sub
' **********************************************************
' Button action callbacks invoke actions
' **********************************************************
function SetPowerOn()
Dim inArgs(0)
Dim outArgs(0)
TvControlService.InvokeAction "PowerOn", inArgs, outArgs
end function
function SetPowerOff()
Dim inArgs(0)
Dim outArgs(0)
TvControlService.InvokeAction "PowerOff", inArgs, outArgs
end function
function IncreaseChannel()
Dim inArgs(0)
Dim outArgs(0)
TvControlService.InvokeAction "IncreaseChannel", inArgs, outArgs
end function
function DecreaseChannel()
Dim inArgs(0)
Dim outArgs(0)
TvControlService.InvokeAction "DecreaseChannel", inArgs, outArgs
end function
function IncreaseVolume()
Dim inArgs(0)
Dim outArgs(0)
TvControlService.InvokeAction "IncreaseVolume", inArgs, outArgs
end function
function DecreaseVolume()
Dim inArgs(0)
Dim outArgs(0)
TvControlService.InvokeAction "DecreaseVolume", inArgs, outArgs
end function
function IncreaseColor()
Dim inArgs(0)
Dim outArgs(0)
TvPictureService.InvokeAction "IncreaseColor", inArgs, outArgs
end function
function DecreaseColor()
Dim inArgs(0)
Dim outArgs(0)
TvPictureService.InvokeAction "DecreaseColor", inArgs, outArgs
end function
function IncreaseTint()
Dim inArgs(0)
Dim outArgs(0)
TvPictureService.InvokeAction "IncreaseTint", inArgs, outArgs
end function
function DecreaseTint()
Dim inArgs(0)
Dim outArgs(0)
TvPictureService.InvokeAction "DecreaseTint", inArgs, outArgs
end function
function IncreaseContrast()
Dim inArgs(0)
Dim outArgs(0)
TvPictureService.InvokeAction "IncreaseContrast", inArgs, outArgs
end function
function DecreaseContrast()
Dim inArgs(0)
Dim outArgs(0)
TvPictureService.InvokeAction "DecreaseContrast", inArgs, outArgs
end function
function IncreaseBrightness()
Dim inArgs(0)
Dim outArgs(0)
TvPictureService.InvokeAction "IncreaseBrightness", inArgs, outArgs
end function
function DecreaseBrightness()
Dim inArgs(0)
Dim outArgs(0)
TvPictureService.InvokeAction "DecreaseBrightness", inArgs, outArgs
end function
' ********************************************************
' Download the description document from the UPnP device
' ********************************************************
Dim TvDesc
Set TvDesc = CreateObject("UPnP.DescriptionDocument.1")
TvDesc.Load("tvdevicedesc.xml")
' ********************************************************
' Get the Root Device from the description document
' ********************************************************
Dim TvDevice
Set TvDevice = TvDesc.RootDevice
' ********************************************************
' Output some of the device properties to the user
' ********************************************************
Dim output
output = "Found: " & vbCrLf
output = output & "DisplayName: " & TvDevice.FriendlyName & vbCrLf
output = output & "Type: " & TvDevice.Type & vbCrLf
output = output & "UDN: " & TvDevice.UniqueDeviceName & vbCrLf
MsgBox output
FName.innerText = TvDevice.FriendlyName
' ********************************************************
' Attach the event handler to the tv control service
' ********************************************************
Dim TvControlService
set TvControlService=TvDevice.Services("urn:upnp-org:serviceId:tvcontrol1")
TvControlService.AddCallback GetRef("eventHandler")
' ********************************************************
' Attach the event handler to the tv picture service
' ********************************************************
Dim TvPictureService
set TvPictureService=TvDevice.Services("urn:upnp-org:serviceId:tvpicture1")
TvPictureService.AddCallback GetRef("eventHandler")
</SCRIPT>
</BODY>
</HTML>
|