Microsoft DirectX 8.1 (C++) |
This topic applies to Windows XP Home Edition and Windows XP Professional only.
To enable closed captioning (CC), the application must activate the closed captioning feature. For analog television, the application must also activate the data services feature. You can find the features by enumerating them from the Video Control's available features collection. To activate a feature, add it to the active features collection.
To activate the closed captioning feature, perform the following steps:
Perform these steps before calling MSVidCtl.Build or MSVidCtl.Run. Once the CC feature is in the active features collection, you can enable or disable closed captioning at any time by setting the CC feature's MSVidClosedCaptioning.Enable property. By default, the feature is disabled.
The following code example enables closed captioning for analog television:
Const CLSID_CC As String = "{7F9CB14D-48E4-43B6-9346-1AEBC39C64D3}"
Const CLSID_DATASVC As String = "{334125C0-77E5-11D3-B653-00C04F79498E}"
Private mCCFeature as MSVidClosedCaptioning
Dim colFeatures As New MSVidFeatures
Dim objFeature As IMSVidFeature
' Find the CC and Data Services features, and add them to the collection.
For Each objFeature In VidControl.FeaturesAvailable
If objFeature.ClassID = CLSID_CC Then
colFeatures.Add objFeature
Set mCCFeature = objFeature
ElseIf objFeature.ClassID = CLSID_DATASVC Then
colFeatures.Add objFeature
End If
Next
' Use this collection for the active features.
VidControl1.FeaturesActive = colFeatures
mCCFeature.Enable = True
In this example, the CLSID_CC and CLSID_DATASVC constants contain the CLSIDs of the features, in string format. The application compares these strings against the IMSVidDevice.ClassID property. For digital television, you could omit the ElseIf
clause, unless you wanted the data services feature in order to receive IP data.
Once the CC feature is active, you can display captions by setting the CC feature's MSVidClosedCaptioning.Enable property to True. You can hide the captions again by setting this property to False.