Microsoft DirectX 9.0 |
This topic applies to Windows XP only.
This article shows how to use the Video Control to tune to a station using Visual Basic. First, create a project and add the following references:
Also add the Video Control type library as a component. Draw the video control on your form and give it a name; for example, VidControl. To tune to a channel, do the following:
In step 1, it is preferable to get a pre-configured tune request from a database. That way, the application does not need to handle any details related to the network type. However, you can construct a tune request from scratch if you know the particular network type that you want to support. Do the following:
For example, the following procedure tunes to ATSC channel 46 when the form loads:
Private Sub Form_Load()
Dim objTSContainer As New SystemTuningSpaces
Dim objTuneRequest As IATSCChannelTuneRequest
Dim objLocator As New ATSCLocator
Set objTuneRequest = objTSContainer("ATSC").CreateTuneRequest
objLocator.PhysicalChannel = 46
objTuneRequest.Locator = objLocator
VidControl.View objTuneRequest
VidControl.Run
End Sub
The previous example specifies a tuning space in the SystemTuningSpaces collection by its unique name ("ATSC" in this example). You can also use a For...Each
loop to iterate through the collection. For example, the following code populates a list box with the names of all the available tuning spaces:
For Each tunespace In objTSContainer
TuneName = tunespace.UniqueName + " (" + tunespace.FriendlyName + ")"
List1.AddItem TuneName
Next
Analog cable does not require a locator object. The next example tunes to NTSC analog cable, channel 6:
Dim objTSContainer As New SystemTuningSpaces
Dim objTuneRequest As IChannelTuneRequest
Set objTuneRequest = objTSContainer("Cable").CreateTuneRequest
objTuneRequest.Channel = 6
VidControl.View objTuneRequest
VidControl.Run
As these examples show, when the application builds a tune request, it must target specific network types. If it always gets a preconfigured tune request from a database, it will function with any supported network type.
To change channels within the same network type, simply submit another tune request to the Video Control by calling MSVidCtl.View.