I´m trying to develop a decent tv tuner/capture application (since there are no such apps, nowhere, I say) in Visual Basic 6.0. I´m using the MSVidCtl component together with the AnalogTVTuningSpace and IChannelTuneRequest object to achieve this, as described here:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/directx9_c/directX/htm/hostingthevideocontrolinavisualbasicform.asp
and here:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/directx9_c/directx/htm/analogtvtuningspaceobjectvb.asp
and here:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/directx9_c/directX/htm/ichanneltunerequestobjectvb.asp
I want to connect to the analog antenna broadcast and since I live in Sweden I want the PAL (PAL_B) TV format.
But I can´t get it to work.
I´m connecting with my TV tuner card, no problems there, since the MSVidCtl.InputActive property shows my card manufacturers name and card brand. But I´m not sure exactly how to tune in to the right frequencies. The only property I can change is the IChannelTuneRequest.Channel property. And all I get by changing the Channel value is snowstorm, or really, a blue flickering picture with snowstorm audio noice.
I´ve already set the AnalogTVTuningSpace.CountryCode to 46, which is the country code for Sweden.
How do I set the frequencies
How do I choose TV format
I find this to be a highly interesting area, the whole tv tuner/recorder thing, and I would just love to get things running. Promise to give y'all the source code if you help me to get it working!!!
FYI, I have a AverMedia AverTV Studio 303 card, which works well, except for the software, which is really not that good.
Also, the components described above only work with Windows XP.
Source code so far:
Dim objTuningSpace As New AnalogTVTuningSpace
Dim objTuneRequest As IChannelTuneRequest
'country code for Sweden
objTuningSpace.CountryCode = 46
'-1 Indicates cable frequency.
'0 Indicates broadcast antenna frequency.
objTuningSpace.InputType = 0
Set objTuneRequest = objTuningSpace.CreateTuneRequest
'not much happening when I change this value
objTuneRequest.Channel = 1
'The MSVidCtl ActiveX object
VidControl.View objTuneRequest
'Here I will get a flickering, blue picture
VidControl.Run

hi,I am focusing on this subject......
KTMFBA
I may have a solution to your problem. I've been able to get the MS Video Control on the UK broadcasting system. You can see the VB code at:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp txtCodeId=46243&lngWId=1
By changing the country code, it may work with your TV Card.
Alternatively, you can see more information at my site at:
http://pavcules.fun.to > Software Ideas - Television
Or its direct link at:
http://members.lycos.co.uk/pavcules/software/television/index.htm
- Pavcules
Pete Verrone
You wer right about adding the tune request object. The previous error message is gone! Using the code shown below, the vidControl now comes alive, but shows only the colorKey color on the screen. Also, regardless of the color to which I set the colorKey in the object browser, the colorKey color always returns to magenta when the code is run.
I'm in the process of upgrading to DirectX v9. Till now I've been using the version included in Windows XP last year. Maybe that will help get a video image to the vidControl.
Another interesting phenomena: If I have one of the Happauge WinTV display programs running when I run the below code, the WinTV display changes channel. It always changes to the same channel, and not the tune request channel in the code.
I continue to learn. Thanks for your help.
-------------------------------------------------
Private Sub Form_Load()
Dim objTSContainer As New SystemTuningSpaces
Dim objTuneRequest As IChannelTuneRequest
Set objTuneRequest = objTSContainer("Cable").CreateTuneRequest
objTuneRequest.Channel = 7
VidControl.View objTuneRequest
On Error GoTo ErrorHandler
VidControl.Run
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 0
'no error
Case -2147418113
' bad tuning space, ignore and retry
Resume
Case Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
Resume Next
End Select
QuantaCat
Good idea about the second Windows install. I´ll do dat.
I suck at C/C++. Maybe the old guy
;-)
an2ny79
It's defenitly a good idea to upgrade do DirectX 9, since MSVidCtl was officially introduced with DX9. In XP there was a downgrade for DX7 included. Maybe that helps. Give it a try.
For me it's reasonable that your WinTV display changes the channel if you tune to another channel with your VB app, since there is only one tuner chip on your tv card. It's interessting that you can operate your tv software while running your vb app. On my system the MSVidCtl won't show video and come up with some error.
The color key issue:
It's very interesting that you got the control to show the color key. I wanted it to do so, but never archieved it. But I think i found an error in the MSVidCtl: setting the colorkey-property while design your application doesn't work. You have to set it while runtime with:
vidcontrol.colorkey = rgb(255,0,0) 'red
David Chang
I suppose with the "VidControl.Run" statement you want to start the live picture in the MSVidCtl
Then you need to add the following lines
Dim objTuneRequest As IChannelTuneRequest
Set objTuneRequest = objTSContainer("Antenna").CreateTuneRequest
objTuneRequest.Channel = 6
VidControl.View objTuneRequest
On Error GoTo ErrorHandler
VidControl.Run
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 0
'no error
Case -2147418113
' bad tuning space, ignore and retry
Resume
Case Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
Resume Next
End Select
Note the ErrorHandler, since the "bad tuning space" error comes up all the time and it works if you just retry. You might also want to change the "antenna" to "cable" for your purposes.
Mongkut
The "old guy" is a retired jack-of-all-trades who started programming in the BELL language on an IBM 40 in 1958, and who doesn't know diddly about C/C++. At one time I was very fluent in Fortran and other archaic languages. I got out of the field for a number of years till I bought an IBM Model 1 PC in 1981. After that I flew charter aircraft for a few years, and in the early 90's got back into IT through consulting. I became a Paradox and later SQL dba and intranet webmaster for a large medical company. Fortunately for me and my IRA/401, Y2K came along and there was a strong demand for programmers until the stock market tumble. I retired two years ago, and am trying to keep mentally fit with projects like these.
Sorry, but I can help you in C/C++.
signy
The install of DirectX 9 went smoothly, however there was no aparent effect on my VB app. Still no picture.
However, your direction on the setting of the colorKey worked. I can set the screen color to my preference at run time. I was mislead by the following quote taken directly from the MSDN website page on MSVidCtl.ColorKey: "In Visual Basic, you can set this property at design time using the Properties dialog." So much for Microsoft as the final authority.
Each day I go back to the MSDN instructions for hosting video in a VB app, and search for something I may have missed. I haven't found any books on the subject in my local big box book store. I hope that if I keep tweeking the code and asking, eventually I'll get video displayed.
I'm sorry to hear that the MSVidCtl won't show video on your system. Lets keep each other posted on our progress.
OffThaTop
Per your request, my VB app code is shown below. When the app is run,
1) the form appears with a blue screen (the colorKey)
2) the system speakers start buzzing and humming.
3) the red activity LED on on the winTV-USB box turns on.
4) there is no video picture!
If I start the WinTV2000 program running while my VB app is also running, the WinTV runs OK with a good video display, while my app continues to show a solid blue screen. The one anomaly is that the sound is repeated with about a 1/2 second delay. It sounds as a large echo chamber would sound.
When the winTV2000 program is run without my VB app running, video and sound are both fine.
I have tried initializing my app with "Cable", "DirectCable", "Auxln1", and the "MyTV" shown in the code below. The results are always a solid blue screen and buzzing.
I will be interested in reading how this code runs on your machine.
--------------------------------------------------------
Private Sub Form_Load()
Dim objTuningSpaceContainer As New SystemTuningSpaces
Dim objTunerRequest As IChannelTuneRequest
Dim objTuneSpace As ITuningSpace
Dim objAnalogTuneSpace As New AnalogTVTuningSpace
' IF A PREVIOUS MyTV TUNING SPACE EXISTS, REMOVE IT.
' THIS IS JUST PROTECTION, IF YOU RE-ADD THE SAME TUNING SPACE INTO THE SYSTEM.
For Each objTuneSpace In objTuningSpaceContainer
If objTuneSpace.UniqueName = "MyTV" Then
objTuningSpaceContainer.Remove "MyTV"
End If
Next
' SET UP THE NEW MyTV TUNING SPACE.
' THE INFORMATION GETS STORED IN THE REGISTRY.
objAnalogTuneSpace.UniqueName = "MyTV"
objAnalogTuneSpace.FriendlyName = "My Television"
objAnalogTuneSpace.CountryCode = 1 ' USA
objAnalogTuneSpace.MaxChannel = 99
objAnalogTuneSpace.MinChannel = 1
objAnalogTuneSpace.NetworkType = "{00000000-0000-0000-0000-000000000000}" ' CABLE
objAnalogTuneSpace.InputType = TunerInputDigitalCable
' ADD THE NEW TUNING SPACE INTO THE COLLECTION.
objTuningSpaceContainer.Add objAnalogTuneSpace
' POINT THE VIDEO TO THE TUNER SPACE
Set objTunerRequest = objTuningSpaceContainer("MyTV").CreateTuneRequest
objTunerRequest.Channel = 7
VideoControl.View objTunerRequest
On Error GoTo ErrorHandler
VideoControl.ColorKey = RGB(64, 128, 255) 'BLUE
VideoControl.Enabled = True
VideoControl.Run
ErrorHandler:
Select Case Err.Number
Case 0
'no error
Case -2147418113
' bad tuning space, ignore and retry
Resume
Case Else
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
Resume Next
End Select
'LIST THE AVAILABLE TUNING SPACES
List1.AddItem "TUNING SPACES:"
For Each tunespace In objTuningSpaceContainer
TuneName = tunespace.UniqueName + " (" + tunespace.FriendlyName + ")"
List1.AddItem TuneName
Next
' LIST THE AVAILABLE TUNERS ON THE SYSTEM.
Const clsidAnalogTuners = "{a799a800-a46d-11d0-a18c-00a02401dcd4}" ' Non-BDA analog tuner devices.
List1.AddItem "__________"
' List the non-BDA tuners on the system.
List1.AddItem "AVAILABLE TUNERS:"
Dim objTuner As MSVidAnalogTunerDevice
For Each objTuner In VideoControl.InputsAvailable(clsidAnalogTuners)
List1.AddItem objTuner.Name
Next
End Sub
T.F.E
You, me and Pav seem to be the only three people in the world using these components ;-) Strange that.
Thanx for the suggestion. I´ve tried it but the picture still flickers. Pav has mentioned that it might be a driver issue. I´m not sure about that but I´ll re-install XP anyway (not funny) to see what happens.
I wonder what happens if you use the same control in VS.NET. Is it realistic to hope that things work better on the .NET platform
Sorry, but I haven´t used any alpha-blending on the msvidctl.
Vijaylakshmy
Alok Goyal
My project is a scheduled automatic screen capture from cable video. I'll use it to grab images which are posted on our local community activities website, www.timberpines.tv. Currently the capture is a manually initiated process.
I have a Hauppauge WinTV USB which works OK with the WinTV software, and is listed as an available tuner by the code below, most of which I scarfed from Pavcules website.
However, when run, the code shown below hangs on the vidControl.run statement. The error is: "This object is not initialized". I'm enough of a newbie at VB (45 years of computer programming) that I need help. Any constructive guidance is appreciated.
My resourses: VB6sp1, XPpro
---------------------------------------------------------
Private Sub Form_Load()
Dim objTSContainer As New SystemTuningSpaces
Dim objTuneSpace As ITuningSpace
Dim objAnalogTuneSpace As New AnalogTVTuningSpace
' If a previous MyTV Tuning Space exists, remove it.
' This is just protection if you re-add the same tuning space into the system.
For Each objTuneSpace In objTSContainer
If objTuneSpace.UniqueName = "MyTV" Then
objTSContainer.Remove "MyTV"
End If
Next
' Set up the new MyTV Tuning Space.
' You only have to add it once as the information gets stored in the registry.
objAnalogTuneSpace.UniqueName = "MyTV"
objAnalogTuneSpace.FriendlyName = "My Television"
objAnalogTuneSpace.CountryCode = 1 ' USA
objAnalogTuneSpace.MaxChannel = 69
objAnalogTuneSpace.MinChannel = 1
objAnalogTuneSpace.NetworkType = "{00000000-0000-0000-0000-000000000000}"
objAnalogTuneSpace.InputType = TunerInputCable
' Add the new Tuning Space into the collection.
objTSContainer.Add objAnalogTuneSpace
'LIST THE AVAILABLE TUNING SPACES
List1.AddItem "TUNING SPACES:"
For Each tunespace In objTSContainer
TuneName = tunespace.UniqueName + " (" + tunespace.FriendlyName + ")"
List1.AddItem TuneName
Next
' LIST THE AVAILABLE TUNERS ON THE SYSTEM.
Const clsidAnalogTuners = "{a799a800-a46d-11d0-a18c-00a02401dcd4}" ' Non-BDA analog tuner devices.
List1.AddItem "__________"
' List the non-BDA tuners on the system.
List1.AddItem "AVAILABLE TUNERS:"
Dim objTuner As MSVidAnalogTunerDevice
For Each objTuner In VidControl.InputsAvailable(clsidAnalogTuners)
List1.AddItem objTuner.Name
Next
VidControl.Run
End Sub
Prajkta
does video work with your WinTV application Maybe you tuned to the wrong TuningSpace. If you use "AuxIn1" then I get a blue screen until I connect a video device. Can you post your source code, then I can check if it runs on my system....
JettFree
This problem appears under windows 2000 all the time (it is possible to use msvidctl with win2k if you copy the dlls).
Under XP it helps to start the tv software, tune in a channel (in my case aux), close the tv software and the start your VB app again. Then it works with me.
Has anyone of you guys experience with alpha-blending an image on the msvidctl
There's an MSDN article at:
http://msdn.microsoft.com/library/en-us/directx9_c/directX/htm/mixinganimageontothevideowindowinvisualbasic.asp
showing how to mix an image on the the control. It works fine, but you can't have transparency on some part of the image.
I thought .colorkey might be the solution, but i could get it to work.
Any ideas
Tal Kedem
We really seem to be the only one out here. I searched google now for more than one day and found no more (interesting) sites.
What tv card are you using I have a terratec tvalue with a bt878 chip set. Maybe just update your video driver or directx drivers. If you install XP again, do a second installation on your harddisk, which you use for testing purposes. This saves you a lot of time installing all the other apps.
About .NET: I never had my hands on .net personally, but while I was searching google, I figured out, that people have still problems geting DirectShow to work with .net (they need custom dlls and that sort of stuff).
On the MSDN-site there're a lot of C examples but I'm not into that language. Is anyone of you good at C/C++
schuon