Function IsVideoGrabberCreated () IsVideoGrabberCreated = not (document.getElementById("VideoGrabber") is nothing) End Function
sub CreateVideoGrabber() if not IsVideoGrabberCreated then dim m_vidgrab set m_vidgrab = document.createElement("object") with m_vidgrab .classID = "clsid:B7A1B3FE-59CB-4C8E-81CC-FFC6EC6834DE" .id = "VideoGrabber" .width = 320 .height = 240 end with document.body.appendChild m_vidgrab set m_vidgrab = nothing end if end sub
Sub RemoveVideoGrabber if IsVideoGrabberCreated then document.body.removeChild document.getElementById("VideoGrabber") end if End Sub
Sub StartPreview if IsVideoGrabberCreated then if CInt (document.all("VideoDeviceIndex").Value) >= VideoGrabber.VideoDevicesCount then MsgBox "there are only " & VideoGrabber.VideoDevicesCount & " video capture devices on this platform" else VideoGrabber.StopPreview VideoGrabber.VideoDevice = CInt (document.all("VideoDeviceIndex").Value) VideoGrabber.StartPreview end if end if End Sub
Sub NearestSize (VideoWidth, VideoHeight) if IsVideoGrabberCreated then VideoGrabber.UseNearestVideoSize VideoWidth, VideoHeight, true VideoGrabber.Width = VideoWidth VideoGrabber.Height = VideoHeight end if end sub
Sub StopPreview if IsVideoGrabberCreated then VideoGrabber.StopPreview end if End Sub
MsgBox "Preview started!"
TVideoGrabber ActiveX component
This is a simple demo of TVideoGrabber dynamically created or removed from a HTML page