Blake81
Well-known member
I'm trying to make a messenger program that I'm hoping to use over the Internet if I can get it working, or at least use on my LAN. I've got it working where it will stream audio and video captured from a webcam, but I'd like my app to have radio buttons so you could switch the video between the cam and your monitor on the fly. I'm not even sure I understand the code fully, and I'm not sure how to change it to the monitor. I tried changing this line:
SrcVid.SetInput("DEVICE://Default_Video_Device")
to this:
SrcVid.SetInput("DEVICE://Monitor")
but that didn't work. How can I change this so that you can stream your monitor image? Here's the code:
One more very basic question. If I want to refer to one of these variables in another sub, it gives me problems because the variable isn't declared in that sub. How can I change the settings of these variables in other subs? I need to have some buttons to start and stop audio and to change video inputs. Thanks.
SrcVid.SetInput("DEVICE://Default_Video_Device")
to this:
SrcVid.SetInput("DEVICE://Monitor")
but that didn't work. How can I change this so that you can stream your monitor image? Here's the code:
VB.NET:
[SIZE=2][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Encoder [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.WMEncoder
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] EncoderApp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.WMEncoderApp
EncoderApp = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] WMEncoderLib.WMEncoderApp
Encoder = EncoderApp.Encoder
[/SIZE][SIZE=2][COLOR=#008000]' Display the predefined Encoder UI.
[/COLOR][/SIZE][SIZE=2]EncoderApp.Visible = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' Specify the source for the input stream.
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SrcGrpColl [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.IWMEncSourceGroupCollection
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SrcGrp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.IWMEncSourceGroup
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SrcVid [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.IWMEncSource
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SrcAud [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.IWMEncSource
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Preview [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMPREVIEWLib.WMEncDataView
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] lPreviewStream [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DVColl_Preview [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.IWMEncDataViewCollection
SrcGrpColl = Encoder.SourceGroupCollection
SrcGrp = SrcGrpColl.Add([/SIZE][SIZE=2][COLOR=#800000]"SG_1"[/COLOR][/SIZE][SIZE=2])
SrcVid = SrcGrp.AddSource(WMEncoderLib.WMENC_SOURCE_TYPE.WMENC_VIDEO)
SrcAud = SrcGrp.AddSource(WMEncoderLib.WMENC_SOURCE_TYPE.WMENC_AUDIO)
SrcVid.SetInput([/SIZE][SIZE=2][COLOR=#800000]"DEVICE://Default_Video_Device"[/COLOR][/SIZE][SIZE=2])
SrcAud.SetInput([/SIZE][SIZE=2][COLOR=#800000]"DEVICE://Default_Audio_Device"[/COLOR][/SIZE][SIZE=2])
DVColl_Preview = SrcVid.PreviewCollection
Preview = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] WMPREVIEWLib.WMEncDataView
[/SIZE][SIZE=2][COLOR=#008000]' Specify a profile.
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ProColl [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.IWMEncProfileCollection
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Pro [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.IWMEncProfile
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2]ProColl = Encoder.ProfileCollection
[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] i = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] ProColl.Count - 1
Pro = ProColl.Item(i)
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] Pro.Name = [/SIZE][SIZE=2][COLOR=#800000]"Windows Media Video 8 for Local Area Network (384 Kbps)"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]SrcGrp.Profile = Pro
[/SIZE][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]For
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][COLOR=#008000]' Create a broadcast.
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] BrdCst [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] WMEncoderLib.IWMEncBroadcast
BrdCst = Encoder.Broadcast
BrdCst.PortNumber(WMEncoderLib.WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP) = 8888
lPreviewStream = DVColl_Preview.Add(Preview)
[/SIZE][SIZE=2][COLOR=#008000]' Start the encoding process.
[/COLOR][/SIZE][SIZE=2]Encoder.Start()
PreviewFrame.URL = [/SIZE][SIZE=2][COLOR=#800000]"http://192.168.1.101:8888"
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[/SIZE]
One more very basic question. If I want to refer to one of these variables in another sub, it gives me problems because the variable isn't declared in that sub. How can I change the settings of these variables in other subs? I need to have some buttons to start and stop audio and to change video inputs. Thanks.