Click here to Skip to main content
12,547,231 members (64,373 online)

connecting a webcam using in

Member 9626615 asked:

Open original thread
Hi everyone,

I am new to this forum and am a beginner programmer.

I wish to develop a motion detector program in Visual Basic.NET. I've tried the windows API for connecting the webcam to my project.
While surfing the net I came across to this forum and found a project which uses I downloaded and installed the framework and tried a certain project, to learn what is what.
I decided to rewrite the code myself, but encountered an error in the line
If VideoSourcePlayer1.Isrunning = True Then
It says that VideoSourcePlayer1 is not declared. It may be inaccessible due to its protection level.

Here is the code that I am trying to rewrite. The VideoSourcePlayer1 doesn't have an error.
I'm merely rewriting the code, so why am I encountering an error when it seems to work fine on the other project?

Kindly help me.

Thanks in advance.

Imports AForge.Video
Imports AForge.Video.DirectShow
Public Class MainWindow
    Dim VideoCaptureSource As VideoCaptureDevice
    Dim WCdevices As New FilterInfoCollection(FilterCategory.VideoInputDevice)

    Private Sub MainWindow_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim MyWebcam As FilterInfo
        If WCdevices.Count = 0 Then
            lstWCdevices.Items.Add("No Webcam Device Detected")
            For Each MyWebcam In WCdevices
        End If
        lstWCdevices.SelectedIndex = 0
    End Sub

    Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
        If lstWCdevices.SelectedItem <> "No Video Devices" Then

            If VideoSourcePlayer1.IsRunning = True Then
            End If
            VideoCaptureSource = New VideoCaptureDevice(VideoDevices(cboVideoSource.SelectedIndex).MonikerString)
            VideoSourcePlayer1.VideoSource = VideoCaptureSource
        End If
    End Sub
End Class
Tags: VB, VB.NET


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy | Mobile
Web02 | 2.8.161018.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100