Class RadWebCam
Represents a web cam control that displays the stream provided by a web cam.
Inherited Members
Namespace: Telerik.WinControls.UI
Assembly: Telerik.WinControls.RadWebCam.dll
Syntax
[TelerikToolboxCategory("Data Controls")]
public class RadWebCam : RadControl, INotifyPropertyChanged, ISupportInitializeNotification, ISupportInitialize, IComponentTreeHandler, ILayoutHandler, IPCHost, IAnalyticsProvider, IMediaFoundationRenderSurface
Constructors
RadWebCam()
Initializes a new instance of the RadWebCam class with default settings. The control will automatically start the first detected webcam when loaded.
Declaration
public RadWebCam()
Properties
AutoStart
Gets or sets whether the control will automatically start the first webcam it finds when the control is loaded.
Declaration
public bool AutoStart { get; set; }
Property Value
System.Boolean
|
CameraBorderElement
Gets the element representing the border of the camera.
Declaration
public LightVisualElement CameraBorderElement { get; }
Property Value
LightVisualElement
|
ControlPanelHeight
Gets or sets the height of the panel with the camera controls.
Declaration
public int ControlPanelHeight { get; set; }
Property Value
System.Int32
|
DefaultSize
Gets the default size of the control.
Declaration
protected override Size DefaultSize { get; }
Property Value
System.Drawing.Size
|
HasError
Gets a value indicating whether the camera is in a state where something is preventing normal operation.
Declaration
public bool HasError { get; protected set; }
Property Value
System.Boolean
|
IsPreviewingSnapshot
Gets or sets a value indicating whether the control is in snapshot preview mode.
Declaration
public bool IsPreviewingSnapshot { get; set; }
Property Value
System.Boolean
|
IsRecording
Gets or sets a value indicating whether the source content is being recorded to a file.
Declaration
public bool IsRecording { get; set; }
Property Value
System.Boolean
|
PreviewSnapshots
Gets or sets whether the control will go into preview mode when a snapshot is taken.
Declaration
public bool PreviewSnapshots { get; set; }
Property Value
System.Boolean
|
RecordingFilePath
Gets or sets the file path where video files are saved when recording from the webcam. Must be set before calling StartRecording() method.
Declaration
public string RecordingFilePath { get; set; }
Property Value
System.String
|
SnapshotPreviewElement
Gets the element used to display snapshot previews or error messages.
Declaration
public LightVisualElement SnapshotPreviewElement { get; }
Property Value
LightVisualElement
|
VideoRecordingElapsedTimeFormat
Gets or sets the format string for displaying elapsed time during video recording. Uses standard DateTime format strings.
Declaration
public string VideoRecordingElapsedTimeFormat { get; set; }
Property Value
System.String
|
WebCamElement
Gets the main web cam control element.
Declaration
public RadWebCamElement WebCamElement { get; }
Property Value
RadWebCamElement
|
Methods
CreateCameraBorderElement()
Creates the camera border element.
Declaration
protected virtual LightVisualElement CreateCameraBorderElement()
Returns
LightVisualElement
|
CreateChildItems(RadElement)
Creates and initializes the child elements of the RadWebCam control.
Declaration
protected override void CreateChildItems(RadElement parent)
Parameters
RadElement
parent
The root element of the control's element tree. |
Overrides
CreateRootElement()
Creates the root RadElement of the control.
Declaration
protected override RootRadElement CreateRootElement()
Returns
RootRadElement
|
Overrides
CreateSnapshotPreviewElement()
Creates the snapshot preview element.
Declaration
protected virtual LightVisualElement CreateSnapshotPreviewElement()
Returns
LightVisualElement
|
CreateWebCamElement()
Creates the main RadWebCam element.
Declaration
protected virtual RadWebCamElement CreateWebCamElement()
Returns
RadWebCamElement
|
CreateWebCamRootElement()
Creates the root element of RadWebCam.
Declaration
protected virtual WebCamRootRadElement CreateWebCamRootElement()
Returns
WebCamRootRadElement
|
DiscardSnapshot()
Discards the taken snapshot when the control is in preview snapshot mode.
Declaration
public virtual void DiscardSnapshot()
Dispose(Boolean)
Releases the unmanaged resources used by the RadWebCam control and its child controls and optionally releases the managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
System.Boolean
disposing
true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
GetAudioCaptureDevices()
Gets a list with all the available audio capture devices on the system.
Declaration
public static ReadOnlyCollection<MediaFoundationDeviceInfo> GetAudioCaptureDevices()
Returns
System.Collections.ObjectModel.ReadOnlyCollection<MediaFoundationDeviceInfo>
A read-only collection of audio capture devices available on the system. |
GetVideoCaptureDevices()
Gets a list with all the available video capture devices (webcams) on the system.
Declaration
public static ReadOnlyCollection<MediaFoundationDeviceInfo> GetVideoCaptureDevices()
Returns
System.Collections.ObjectModel.ReadOnlyCollection<MediaFoundationDeviceInfo>
A read-only collection of video capture devices available on the system. |
GetVideoFormats(MediaFoundationDeviceInfo, Boolean)
Gets a list with all the available video file formats for the provided capture device.
Declaration
public static ReadOnlyCollection<MediaFoundationVideoFormatInfo> GetVideoFormats(MediaFoundationDeviceInfo device, bool recordingFormatsOnly = false)
Parameters
MediaFoundationDeviceInfo
device
The device for which to get the available formats. |
System.Boolean
recordingFormatsOnly
If set to true - only formats that allow saving to a video file will be returned. |
Returns
System.Collections.ObjectModel.ReadOnlyCollection<MediaFoundationVideoFormatInfo>
A read-only collection of video formats supported by the specified device. |
Initialize(MediaFoundationDeviceInfo, MediaFoundationVideoFormatInfo)
Starts up the video pipeline and displays the video from the source inside of the control.
Declaration
public virtual void Initialize(MediaFoundationDeviceInfo videoDevice, MediaFoundationVideoFormatInfo videoFormat)
Parameters
MediaFoundationDeviceInfo
videoDevice
The device to use as a video source. |
MediaFoundationVideoFormatInfo
videoFormat
The format from the video source. |
Initialize(MediaFoundationDeviceInfo, MediaFoundationVideoFormatInfo, MediaFoundationDeviceInfo)
Starts up the video pipeline and displays the video from the source inside of the control with audio support.
Declaration
public virtual void Initialize(MediaFoundationDeviceInfo videoDevice, MediaFoundationVideoFormatInfo videoFormat, MediaFoundationDeviceInfo audioDevice)
Parameters
MediaFoundationDeviceInfo
videoDevice
The device to use as a video source. |
MediaFoundationVideoFormatInfo
videoFormat
The format from the video source. |
MediaFoundationDeviceInfo
audioDevice
The device to use as an audio source. |
Exceptions
System.ArgumentNullException
Thrown when videoDevice or videoFormat is null. |
OnCameraError(CameraErrorEventArgs)
Fires the CameraError event.
Declaration
protected virtual void OnCameraError(CameraErrorEventArgs e)
Parameters
CameraErrorEventArgs
e
The event arguments. |
OnHandleCreated(EventArgs)
Raises the System.Windows.Forms.Control.HandleCreated event and initializes the default webcam if available.
Declaration
protected override void OnHandleCreated(EventArgs e)
Parameters
System.EventArgs
e
An System.EventArgs that contains the event data. |
OnLoad(Size)
Notifies that the control is about to be visualized and initializes the webcam position.
Declaration
protected override void OnLoad(Size desiredSize)
Parameters
System.Drawing.Size
desiredSize
The desired size of the control. |
Overrides
OnRecordingEnded(EventArgs)
Fires the RecordingEnded event.
Declaration
protected virtual void OnRecordingEnded(EventArgs e)
Parameters
System.EventArgs
e
The event arguments. |
OnRecordingStarted(CancelEventArgs)
Fires the RecordingStarted event.
Declaration
protected virtual void OnRecordingStarted(CancelEventArgs e)
Parameters
System.ComponentModel.CancelEventArgs
e
The event arguments. |
OnSettingsDialogShowing(CameraSettingsDialogShowingEventArgs)
Fires the SettingsDialogShowing event.
Declaration
protected virtual void OnSettingsDialogShowing(CameraSettingsDialogShowingEventArgs e)
Parameters
CameraSettingsDialogShowingEventArgs
e
The event arguments. |
OnSnapshotTaken(SnapshotTakenEventArgs)
Fires the SnapshotTaken event.
Declaration
protected virtual void OnSnapshotTaken(SnapshotTakenEventArgs e)
Parameters
SnapshotTakenEventArgs
e
The event arguments. |
Pause()
Pauses the video pipeline and pauses displaying the video feed.
Declaration
public virtual void Pause()
SaveSnapshot()
Triggers the SnapshotTaken event when the control is in preview snapshot mode.
Declaration
public virtual void SaveSnapshot()
SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)
Performs the work of setting the specified bounds of this control and updates the webcam stream position.
Declaration
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
Parameters
System.Int32
x
The new x-coordinate of the control. |
System.Int32
y
The new y-coordinate of the control. |
System.Int32
width
The new width of the control. |
System.Int32
height
The new height of the control. |
System.Windows.Forms.BoundsSpecified
specified
A bitwise combination of System.Windows.Forms.BoundsSpecified values. |
Overrides
ShowSettingsDialog()
Shows the camera settings dialog which allows configuring camera properties. The SettingsDialogShowing event can be used to customize or cancel the dialog.
Declaration
public virtual void ShowSettingsDialog()
ShutDown()
Shuts down the video pipeline.
Declaration
public virtual void ShutDown()
Start()
Starts the video pipeline and starts displaying the video feed.
Declaration
public virtual void Start()
StartRecording()
Starts capturing the media source(s) to a file. The RecordingFilePath property must be set before calling this method.
Declaration
public virtual void StartRecording()
Stop()
Stops the video pipeline and stops displaying the video feed.
Declaration
public virtual void Stop()
StopRecording()
Stops the file capture.
Declaration
public virtual void StopRecording()
TakeSnapshot()
Takes a snapshot from the currently displayed webcam video feed. If PreviewSnapshots is true, the snapshot will be displayed for preview before firing the SnapshotTaken event. Otherwise, the SnapshotTaken event will be fired immediately.
Declaration
public virtual void TakeSnapshot()
Events
CameraError
Occurs when an error is preventing the camera from operating normally.
Declaration
public event EventHandler<CameraErrorEventArgs> CameraError
Event Type
System.EventHandler<CameraErrorEventArgs>
|
RecordingEnded
Occurs when video recording has ended.
Declaration
public event EventHandler RecordingEnded
Event Type
System.EventHandler
|
RecordingStarted
Occurs when video recording is started.
Declaration
public event EventHandler<CancelEventArgs> RecordingStarted
Event Type
System.EventHandler<System.ComponentModel.CancelEventArgs>
|
SettingsDialogShowing
Occurs when the settings dialog is about to be shown.
Declaration
public event EventHandler<CameraSettingsDialogShowingEventArgs> SettingsDialogShowing
Event Type
System.EventHandler<CameraSettingsDialogShowingEventArgs>
|
SnapshotTaken
Occurs when a snapshot is taken from the webcam. If PreviewSnapshots is set to true, the event is fired only when the SaveSnapshot() method is called.
Declaration
public event EventHandler<SnapshotTakenEventArgs> SnapshotTaken
Event Type
System.EventHandler<SnapshotTakenEventArgs>
|
Explicit Interface Implementations
IMediaFoundationRenderSurface.GetHandle()
Declaration
IntPtr IMediaFoundationRenderSurface.GetHandle()
Returns
System.IntPtr
|