MediaCapture MediaCapture MediaCapture MediaCapture Class

Provides functionality for capturing photos, audio, and videos from a capture device, such as a webcam.

Syntax

Declaration

public sealed class MediaCapturepublic sealed class MediaCapturePublic NotInheritable Class MediaCapture

Remarks

The MediaCapture class is used to capture audio, video, and images from a camera. For how-to guidance for displaying the camera preview, see Display the camera preview. To quickly get started capturing photos, audio, or video, see Basic photo, video, and audio capture with MediaCapture.

The Camera page is the main hub for how-to guidance for using MediaCapture in your app. In addition to the basic camera tasks, this page links to how-to articles for advanced scenarios including:

  • Using the hardware camera button on devices that have one
  • Handling device and screen orientation
  • Using camera profiles to determine device capabilities
  • Setting the format, resolution, and frame rate of captured video
  • Using AdvancedPhotoCapture to capture HDR or low-light photos
  • Using the VideoDeviceController to access manual camera controls like exposure, white balance, auto-focus, and flash
  • Using effects while capturing video
  • Capturing photo sequences
  • Using MediaFrameReader to get a stream of frames from one or more cameras, including rgb, infrared, and depth cameras
  • Getting a frame from the preview stream The Camera article also links to all of the UWP SDK samples for camera, such as the Camera starter kit sample.

The InitializeAsync() method, which initializes the MediaCapture object, must be called before you can start previewing or capturing from the device. In C# or C++ apps, the first use of the MediaCapture object to call InitializeAsync should be on the STA thread. Calls from an MTA thread may result in undefined behavior. InitializeAsync() will launch a consent prompt to get the user's permission for the app to access the microphone or camera. InitializeAsync should be called from the main UI thread of your app. Apps must handle app suspension or termination by properly cleaning up media capture resources. For information on shutting down the MediaCapture object properly, see Basic photo, video, and audio capture with MediaCapture.

On Windows, music and media capture apps should monitor the SoundLevel to determine whether the audio streams on the app have been SoundLevel. For apps using the MediaCapture object, capture will be automatically stopped when the capture streams of the app are muted. Capture is not re-started automatically when the audio streams are unmuted, so the SoundLevel changed notification can be used to restart capture. Use the PropertyChanged event to determine when the SoundLevel property changes.

For Windows Phone Store app, music and media apps should clean up the MediaCapture object and associated resources in the Suspending event handler and recreate them in the Resuming event handler.

In Windows 8.1 audio only apps, if the MediaCategory setting is MediaCategory, then high latency mode is used. For low latency, set the MediaCategory setting to MediaCategory.

Adding an in-place editing Media Foundation Transform effect into the capture preview will have no effect on the stream.

Windows 8Windows Store app that have declared both the webcam and microphone capabilities will not function in Windows 8.1 if the user has not enabled both the webcam and microphone privacy settings.

MediaCapture only supports one pass CBR encoding.

Notes on JPEG: JPEG types are passthrough only. To capture an image, the image encoding profile can be set to Auto or you need to specify an encoding profile that matches the native type. To add an effect, you need to switch to an uncompressed video native media type, such as NV12 or RGB32.

Notes on H.264: If the native type is H.264, you can record using a video media type with type identical to the native type. You cannot add an effect to an H.264 native type stream. To capture video, the image encoding profile can be set to Auto or you need to specify an encoding profile that matches the native type.

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).

Examples

The following code sample shows how to create and initialize a MediaCapture object.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Threading.Tasks;
using System.Threading;
using Windows.UI.Core;
using Windows.ApplicationModel.Core;
using Windows.UI.Xaml.Media.Imaging;

using Windows.Media.Capture;
using Windows.Media.Devices;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=391641

namespace MediaCaptureVideo
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        MainPage rootPage = null;

        

        public MainPage()
        {
            this.InitializeComponent();

            rootPage = this;

            this.NavigationCacheMode = NavigationCacheMode.Required;
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // TODO: Prepare page for display here.
        }
        //<SnippetMediaCaptureVideo_CompleteCS>

        MediaCaptureInitializationSettings _captureInitSettings;
        List<Windows.Devices.Enumeration.DeviceInformation> _deviceList;
        Windows.Media.MediaProperties.MediaEncodingProfile _profile;
        Windows.Media.Capture.MediaCapture _mediaCapture;
        bool _recording = false;
        bool _previewing = false;

        private async void EnumerateCameras()
        {
            var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(
                Windows.Devices.Enumeration.DeviceClass.VideoCapture);

            _deviceList = new List<Windows.Devices.Enumeration.DeviceInformation>();

            // Add the devices to deviceList
            if (devices.Count > 0)
            {

                for (var i = 0; i < devices.Count; i++)
                {
                    _deviceList.Add(devices[i]);
                }

                InitCaptureSettings();
                InitMediaCapture();
                rootPage.NotifyUser("Initialization complete.", NotifyType.StatusMessage);

            }
            else
            {
                rootPage.NotifyUser("No camera device is found ", NotifyType.ErrorMessage);
            }
        }

        // Begin initialization.
        private void Initialization()
        {
            rootPage.NotifyUser("Initialization started.", NotifyType.StatusMessage);
            EnumerateCameras();
        }


        // <SnippetMediaCaptureVideo_InitSettingsCS>
        private void InitCaptureSettings()
        {
            _captureInitSettings = null;
            _captureInitSettings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
            _captureInitSettings.AudioDeviceId = "";
            _captureInitSettings.VideoDeviceId = "";
            _captureInitSettings.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.AudioAndVideo;
            _captureInitSettings.PhotoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.VideoPreview;
            
            if (_deviceList.Count > 0)
                _captureInitSettings.VideoDeviceId = _deviceList[0].Id;
        }
        // </SnippetMediaCaptureVideo_InitSettingsCS>

        // <SnippetMediaCaptureVideo_CreateProfileCS>
        // Create a profile.
        private void CreateProfile()
        {
            _profile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(
            Windows.Media.MediaProperties.VideoEncodingQuality.Qvga);
        }
        // </SnippetMediaCaptureVideo_CreateProfileCS>

        // <SnippetMediaCaptureVideo_InitMCobjectCS>
        // Create and initialze the MediaCapture object.
        public async void InitMediaCapture()
        {
            _mediaCapture = null;
            // <SnippetMediaCaptureVideo_CreateMCobjectCS>
            _mediaCapture = new Windows.Media.Capture.MediaCapture();

            // Set the MediaCapture to a variable in App.xaml.cs to handle suspension.
            (App.Current as App).MediaCapture = _mediaCapture;
            // </SnippetMediaCaptureVideo_CreateMCobjectCS>

            await _mediaCapture.InitializeAsync(_captureInitSettings);

            CreateProfile();
        }
        // </SnippetMediaCaptureVideo_InitMCobjectCS>

        // <SnippetMediaCaptureVideo_StartRecordCS>
        // Start the video capture.
        private async void StartMediaCaptureSession()
        {
            var storageFile = await Windows.Storage.KnownFolders.VideosLibrary.CreateFileAsync(
                "cameraCapture.mp4", Windows.Storage.CreationCollisionOption.GenerateUniqueName);

            await _mediaCapture.StartRecordToStorageFileAsync(_profile, storageFile);
            _recording = true;
        }
        // </SnippetMediaCaptureVideo_StartRecordCS>

        // <SnippetMediaCaptureVideo_StopRecordCS>
        // Stop the video capture.
        private async void StopMediaCaptureSession()
        {
            await _mediaCapture.StopRecordAsync();
            _recording = false;
            (App.Current as App).IsRecording = false;
        }
        // </SnippetMediaCaptureVideo_StopRecordCS>
        // </SnippetMediaCaptureVideo_CompleteCS>


        public async Task CleanupCaptureResources()
        {
            if (_recording && _mediaCapture != null)
            {
                await _mediaCapture.StopRecordAsync();
                _recording = false;
            }
            if (_previewing && _mediaCapture != null)
            {
                await _mediaCapture.StopPreviewAsync();
                _previewing = false;
            }

            if (_mediaCapture != null)
            {
                if (previewElement != null)
                {
                    previewElement.Source = null;
                }
                _mediaCapture.Dispose();
            }
        }

        //protected async override void OnNavigatedFrom(NavigationEventArgs e)
        protected async override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            if (e.SourcePageType == typeof(MainPage))
            {
                await CleanupCaptureResources();
            }
            else
            {
                Task.Run(async () => await CleanupCaptureResources()).GetAwaiter().GetResult();
            }

        }


        public async void DevController()
        {

            // <SnippetMediaCaptureVideo_GetDeviceControllerCS>
            // Create the media capture object.
            var mediaCapture = new Windows.Media.Capture.MediaCapture();
            await mediaCapture.InitializeAsync();

            // Retrieve a video device controller.
            var videoDeviceController = mediaCapture.VideoDeviceController;

            // Retrieve an audio device controller.
            var audioDeviceController = mediaCapture.AudioDeviceController;
            // </SnippetMediaCaptureVideo_GetDeviceControllerCS>

            // <SnippetMediaCaptureVideo_SetVideoDeviceControllerPropertiesCS>
            // Retrieve the brightness capabilites of the video camera
            var brightnessCapabilities = videoDeviceController.Brightness.Capabilities;

            //
            // Determine if the video camera supports adjustment of the brightness setting.
            //
            if (brightnessCapabilities.Supported)
            {
                double brightness = 0;

                //
                // Retrieve the current brightness value.
                //

                if (videoDeviceController.Brightness.TryGetValue(out brightness))
                {
                    //
                    // Get the minimum, maximum and step size for the brightness value. 
                    // 
                    double min = brightnessCapabilities.Min;
                    double max = brightnessCapabilities.Max;
                    double step = brightnessCapabilities.Step;

                    //
                    // Increase the brightness value by one step as long as the new value is less than or equal to the maximum.
                    //

                    if ((brightness + step) <= max)
                    {
                        if (videoDeviceController.Brightness.TrySetValue(brightness + step))
                        {
                            // The brightness was successfully increased by one step.
                        }
                        else
                        {
                            // The brightness value couldn't be increased.
                        }
                    }
                    else
                    {
                        // The brightness value is greater than the maximum.
                    }
                }
                else
                {
                    // The brightness value couldn't be retrieved.
                }
            }
            else
            {
                // Setting the brightness value is not supported on this camera.
            }

            // </SnippetMediaCaptureVideo_SetVideoDeviceControllerProperties>
            // <SnippetMediaCaptureVideo_SetAudioDeviceControllerProperties>
            // Mute the microphone.
            audioDeviceController.Muted = true;

            // Un-mute the microphone.
            audioDeviceController.Muted = false;

            // Get the current volume setting.
            var currentVolume = audioDeviceController.VolumePercent;

            // Increase the volume by 10 percent, if possible.
            if (currentVolume <= 90)
            {
                audioDeviceController.VolumePercent = (currentVolume + 10);
            }
            // </SnippetMediaCaptureVideo_SetAudioDeviceControllerPropertiesCS>
        }


        // <SnippetMediaCaptureVideo_MirroringCompleteCS>
        public void TurnMirroringOn()
        {
            // <SnippetMediaCaptureVideo_PreviewMirroringCS>
            if( !_mediaCapture.GetPreviewMirroring() )
                _mediaCapture.SetPreviewMirroring(true);
            // </SnippetMediaCaptureVideo_PreviewMirroringCS>
        }

        public async void StopPreview()
        {
            // <SnippetMediaCaptureVideo_StopPreviewCS>   
            await _mediaCapture.StopPreviewAsync();
            // </SnippetMediaCaptureVideo_StopPreviewCS>
        }



        public async void startPreview()
        {

            _mediaCapture = new Windows.Media.Capture.MediaCapture();
            (App.Current as App).MediaCapture = _mediaCapture;
            
            await _mediaCapture.InitializeAsync();
            CreateProfile();

            TurnMirroringOn();

            // <SnippetMediaCaptureVideo_StartPreview>
            // Start Previewing
            await _mediaCapture.StartPreviewAsync();
            (App.Current as App).IsPreviewing = true;
            // </SnippetMediaCaptureVideo_StartPreview>

        }
        // </SnippetMediaCaptureVideo_MirroringComplete>

        //<SnippetAddSlowMotionEffectCS>
        public async void AddSlowMotionEffect()
        {

            Windows.Media.Effects.SlowMotionEffectDefinition slowMotionEffectDefinition = 
                new Windows.Media.Effects.SlowMotionEffectDefinition();

            // Setter and Getter for TimeStretchRate.
            slowMotionEffectDefinition.TimeStretchRate = 2;


            // Add the effect using the AddEffectAsync overloaded method
            await _mediaCapture.AddEffectAsync(
                MediaStreamType.VideoRecord,
                slowMotionEffectDefinition.ActivatableClassId,
                slowMotionEffectDefinition.Properties);

        }
        //</SnippetAddSlowMotionEffectCS>

        public void NotifyUser(string strMessage, NotifyType type)
        {
            if (StatusBlock != null)
            {
                switch (type)
                {
                    case NotifyType.StatusMessage:
                        StatusBorder.Background = new SolidColorBrush(Windows.UI.Colors.Green);
                        break;
                    case NotifyType.ErrorMessage:
                        StatusBorder.Background = new SolidColorBrush(Windows.UI.Colors.Red);
                        break;
                }
                StatusBlock.Text = strMessage;

                // Collapse the StatusBlock if it has no text to conserve real estate.
                if (StatusBlock.Text != String.Empty)
                {
                    StatusBorder.Visibility = Windows.UI.Xaml.Visibility.Visible;
                }
                else
                {
                    StatusBorder.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                }
            }
            
        }
        //<SnippetEnablePhotoConfirmation>
        private void EnablePhotoConfirmation()
        {
            _mediaCapture.VideoDeviceController.PhotoConfirmationControl.Enabled = true;
            _mediaCapture.PhotoConfirmationCaptured += PhotoConfirmationCaptured;
        }
        //</SnippetEnablePhotoConfirmation>

        //<SnippetPhotoConfirmationCaptured>
        void PhotoConfirmationCaptured(MediaCapture sender, PhotoConfirmationCapturedEventArgs args)
        {
            using (ManualResetEventSlim evt = new ManualResetEventSlim(false))
            {
                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                {
                    try
                    {
                        WriteableBitmap bmp = new WriteableBitmap(unchecked((int)args.Frame.Width), unchecked((int)args.Frame.Height));
                        using (var istream = args.Frame.AsStream())
                        using (var ostream = bmp.PixelBuffer.AsStream())
                        {
                            await istream.CopyStreamToAsync(ostream);
                        }
                    }
                    finally
                    {
                        evt.Set();
                    }

                });

                evt.Wait();
            }

        }
        //</SnippetPhotoConfirmationCaptured>
    }


    public enum NotifyType
    {
        StatusMessage,
        ErrorMessage
    };


    //<SnippetStreamExtenstions>

    public static class StreamEx
    {
        public static void CopyStreamTo(this Stream inputStream, Stream outputStream)
        {
            inputStream.CopyStreamTo(outputStream, 4096);
        }

        public static void CopyStreamTo(this Stream inputStream, Stream outputStream, int bufferSize)
        {
            if (inputStream == null)
            {
                throw new ArgumentNullException("inputStream");
            }

            if (!inputStream.CanSeek)
            {
                throw new ArgumentException("Cannot seek in the input stream.", "inputStream");
            }

            if (!inputStream.CanRead)
            {
                throw new ArgumentException("Input stream is not readable.", "inputStream");
            }

            if (outputStream == null)
            {
                throw new ArgumentNullException("outputStream");
            }

            if (!outputStream.CanSeek)
            {
                throw new ArgumentException("Cannot seek in the output stream.", "outputStream");
            }

            if (!outputStream.CanWrite)
            {
                throw new ArgumentException("Output stream is not writeable.", "outputStream");
            }

            if (bufferSize <= 0)
            {
                throw new ArgumentOutOfRangeException("bufferSize", "Buffer size is equal to zero or negative.");
            }

            inputStream.Seek(0, SeekOrigin.Begin);
            outputStream.Seek(0, SeekOrigin.Begin);

            byte[] buffer = new byte[bufferSize];
            while (inputStream.Position < inputStream.Length)
            {
                int bytesRead = inputStream.Read(buffer, 0, buffer.Length);
                outputStream.Write(buffer, 0, bytesRead);
            }
        }

        public static Task CopyStreamToAsync(this Stream inputStream, Stream outputStream)
        {
            return Task.Run(() => CopyStreamTo(inputStream, outputStream));
        }

        public static Task CopyStreamToAsync(this Stream inputStream, Stream outputStream, int bufferSize)
        {
            return Task.Run(() => CopyStreamTo(inputStream, outputStream, bufferSize));
        }
    }
    //</SnippetStreamExtenstions>

}
// Create and initialze the MediaCapture object.
function initMediaCapture() {
    oMediaCapture = null;
    oMediaCapture = new Windows.Media.Capture.MediaCapture();
    oMediaCapture.initializeAsync(captureInitSettings).then (function (result) {
       createProfile();
    }, errorHandler);    
}
<StackPanel Orientation="Horizontal">
    <CaptureElement x:Name="capturePreview" Width="320" Height="240" />
    <Image x:Name="imagePreview" Stretch="None" Width="320" Height="240" />
</StackPanel>

<StackPanel Orientation="Horizontal">
    <Button Click="InitCamera_Click" Content="Initialize Camera" />
    <Button Click="StartCapturePreview_Click" Content="Start Capture Preview" />
    <Button Click="CapturePhoto_Click" Content="Capture Photo"/>
    <Button Click="StopCapturePreview_Click" Content="Stop Capture Preview" />
</StackPanel>
Windows.Media.Capture.MediaCapture captureManager;

async private void InitCamera_Click(object sender, RoutedEventArgs e)
{
    captureManager = new MediaCapture();
    await captureManager.InitializeAsync();
}

async private void StartCapturePreview_Click(object sender, RoutedEventArgs e)
{
    capturePreview.Source = captureManager;
    await captureManager.StartPreviewAsync();
}

async private void StopCapturePreview_Click(object sender, RoutedEventArgs e)
{
    await captureManager.StopPreviewAsync();
}

async private void CapturePhoto_Click(object sender, RoutedEventArgs e)
{
    ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();

    // create storage file in local app storage
    StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(
        "TestPhoto.jpg",
        CreationCollisionOption.GenerateUniqueName);

    // take photo
    await captureManager.CapturePhotoToStorageFileAsync(imgFormat, file);

    // Get photo as a BitmapImage
    BitmapImage bmpImage = new BitmapImage(new Uri(file.Path));

    // imagePreview is a <Image> object defined in XAML
    imagePreview.Source = bmpImage;
}

Constructors summary

Creates a new instance of the MediaCapture object.

Properties summary

Gets an object that controls settings for the microphone.

Gets the current stream state of the camera stream.

Gets a read-only dictionary of MediaFrameSource objects that can be used simultaneously to acquire media frames.

Gets the configuration settings for the MediaCapture object.

Gets a value that indicates the current thermal status of the capture device.

Gets an object that controls settings for the video camera.

Methods summary

Adds an audio effect to the capture pipeline.

Adds an audio or video effect.

Adds a video effect to the capture pipeline.

Captures a photo to a storage file.

Captures a photo to a random-access stream.

Removes all audio and video effects from a stream.

Closes the media capture object.

Creates a MediaFrameReader that is used to acquire frames from a MediaFrameSource.

Creates a MediaFrameReader that is used to acquire frames with the specified media encoding subtype from a MediaFrameSource.

Creates a MediaFrameReader that is used to acquire frames with the specified media encoding subtype and size from a MediaFrameSource.

Retrieves the list of all video profiles supported by the specified video capture device.

Retrieves the list of video profiles supported by the specified video capture device that can be used while another profile is used on a different capture device.

Retrieves the list of all video profiles supported by the specified video capture device that match the specified KnownVideoProfile value.

Gets the value of an encoding property.

Gets a preview frame from the capture device.

Gets a preview frame from the capture device, copied into the provided destination VideoFrame and converted into the destination frame's format.

Queries whether the video stream is mirrored horizontally.

Gets the rotation of the video preview stream.

Gets the rotation of the recorded video.

Initializes the MediaCapture object, using default settings.

Initializes the MediaCapture object.

Gets a boolean value indicating whether video profiles are supported by the specified video capture device.

Pauses an ongoing record operation.

Pauses an ongoing media record operation and provides a MediaCapturePauseResult that can be used to help the user align the camera with the last captured frame when resuming recording.

Initializes the advanced photo capture and provides the AdvancedPhotoCapture object used to manage the recording.

Initializes the low shutter lag photo capture and provides the LowLagPhotoCapture object used to manage the recording.

Initializes the low shutter lag photo sequence capture and provides the LowLagPhotoSequenceCapture object used to manage the recording.

Initializes the low lag recording using the specified custom sink to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

Initializes the low lag recording using the specified custom sink to store the recording. This method provides the LowLagMediaRecording object used to managed the capture.

Initializes the low lag recording using the specified file to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

Initializes the low lag recording using the specified random-access stream to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

Initializes the variable photo sequence capture and provides the VariablePhotoSequenceCapture object used to manage the recording.

Removes the specified effect from the capture pipeline.

Resumes a paused recording operation.

Sets an encoding property.

Asynchronously sets the media encoding properties.

Enables or disables horizontal mirroring of the video preview stream. This is not the preferred method for mirroring. See the Remarks section below for details.

Rotates the video preview stream.

Rotates the recorded video.

Starts preview.

Starts sending a preview stream to a custom media sink using the specified encoding profile and sink settings.

Starts sending a preview stream to a custom media sink using the specified encoding profile.

Start recording to a custom media sink using the specified encoding profile and sink settings.

Start recording to a custom media sink using the specified encoding profile.

Starts recording asynchronously to a storage file.

Starts recording to a random-access stream.

Stops preview.

Stops recording.

Asynchronously stops the media recording and provides a MediaCaptureStopResult that can be used to help the user align the camera with the last captured frame when restarting recording.

Prerelease. Creates a MultiSourceMediaFrameReader that is used to acquire time-correlated frames from one or more MediaFrameSource objects.

Events summary

Occurs when the state of the camera stream changes.

Raised when an error occurs during media capture.

Occurs when the capture device changes focus.

Occurs when a photo confirmation frame is captured.

Occurs when the record limit is exceeded.

Occurs when the thermal status of the capture device changes.

Prerelease. Occurs when the exclusive control status of the capture device changes.

Constructors

  • MediaCapture()
    MediaCapture()
    MediaCapture()
    MediaCapture()

    Creates a new instance of the MediaCapture object.

    public MediaCapture()public MediaCapture()Public Function MediaCapture() As

    Remarks

    You must call InitializeAsync() before using the MediaCapture object.

Properties

  • AudioDeviceController
    AudioDeviceController
    AudioDeviceController
    AudioDeviceController

    Gets an object that controls settings for the microphone.

    public AudioDeviceController AudioDeviceController { get; }public AudioDeviceController AudioDeviceController { get; }Public ReadOnly Property AudioDeviceController As AudioDeviceController

    Property Value

  • CameraStreamState
    CameraStreamState
    CameraStreamState
    CameraStreamState

    Gets the current stream state of the camera stream.

    public CameraStreamState CameraStreamState { get; }public CameraStreamState CameraStreamState { get; }Public ReadOnly Property CameraStreamState As CameraStreamState

    Property Value

    Remarks

    The state of the camera stream will change when recording is paused or resumed, when the system drops frames for privacy reasons, or when the camera stream is lost. To be notified when the camera stream state changes, handle the CameraStreamStateChanged event.

  • FrameSources
    FrameSources
    FrameSources
    FrameSources

    Gets a read-only dictionary of MediaFrameSource objects that can be used simultaneously to acquire media frames.

    public IMapView<MediaFrameSource> FrameSources { get; }public IMapView<MediaFrameSource> FrameSources { get; }Public ReadOnly Property FrameSources As IMapView<MediaFrameSource>

    Property Value

    • A read-only dictionary of MediaFrameSource objects that can be used simultaneously to acquire media frames.

    Remarks

    Initialize a MediaCaptureMemoryPreference object to use media frame sources by setting the SourceGroup property of the MediaCaptureInitializationSettings object to a MediaFrameSourceGroup returned by FindAllAsync() and then calling InitializeAsync(). The key for each entry in the dictionary is the Id property of the MediaFrameSourceInfo associated with each frame source in the group.

    For more information on using frame sources, see Process media frames with MediaFrameReader.

  • MediaCaptureSettings
    MediaCaptureSettings
    MediaCaptureSettings
    MediaCaptureSettings

    Gets the configuration settings for the MediaCapture object.

    public MediaCaptureSettings MediaCaptureSettings { get; }public MediaCaptureSettings MediaCaptureSettings { get; }Public ReadOnly Property MediaCaptureSettings As MediaCaptureSettings

    Property Value

  • ThermalStatus
    ThermalStatus
    ThermalStatus
    ThermalStatus

    Gets a value that indicates the current thermal status of the capture device.

    public MediaCaptureThermalStatus ThermalStatus { get; }public MediaCaptureThermalStatus ThermalStatus { get; }Public ReadOnly Property ThermalStatus As MediaCaptureThermalStatus

    Property Value

    Remarks

    Media capture scenarios that are extremely processor-intensive, such as high-resolution, high-frame rate, and real-time image processing can cause the capture hardware to overheat. On devices where the camera driver supports reporting of thermal status, you can check the ThermalStatus property to get the current thermal status of the capture device. You can also subscribe to the ThermalStatusChanged event to receive a notification when the thermal status changes. If the thermal status is MediaCaptureThermalStatus , you should stop the current capture session and save any captured media. Once the thermal status has returned to normal, you can begin capturing again.

  • VideoDeviceController
    VideoDeviceController
    VideoDeviceController
    VideoDeviceController

    Gets an object that controls settings for the video camera.

    public VideoDeviceController VideoDeviceController { get; }public VideoDeviceController VideoDeviceController { get; }Public ReadOnly Property VideoDeviceController As VideoDeviceController

    Property Value

    Remarks

    Some drivers may require that the camera device preview to be in a running state before it can determine which controls are supported by the VideoDeviceController. If you check whether a certain control is supported by the VideoDeviceController before the preview stream is running, the control may be described as unsupported even though it is supported by the video device.

Methods

  • AddAudioEffectAsync(Windows.Media.Effects.IAudioEffectDefinition)
    AddAudioEffectAsync(Windows.Media.Effects.IAudioEffectDefinition)
    AddAudioEffectAsync(Windows.Media.Effects.IAudioEffectDefinition)
    AddAudioEffectAsync(Windows.Media.Effects.IAudioEffectDefinition)

    Adds an audio effect to the capture pipeline.

    public IAsyncOperation<IMediaExtension> AddAudioEffectAsync(Windows.Media.Effects.IAudioEffectDefinition definition)public IAsyncOperation<IMediaExtension> AddAudioEffectAsync(Windows.Media.Effects.IAudioEffectDefinition definition)Public Function AddAudioEffectAsync(definition As Windows.Media.Effects.IAudioEffectDefinition) As IAsyncOperation( Of IMediaExtension )

    Parameters

    Returns

    • An asynchronous operation that returns an IMediaExtension upon successful completion.

  • AddEffectAsync(Windows.Media.Capture.MediaStreamType,System.String,Windows.Foundation.Collections.IPropertySet)
    AddEffectAsync(Windows.Media.Capture.MediaStreamType,System.String,Windows.Foundation.Collections.IPropertySet)
    AddEffectAsync(Windows.Media.Capture.MediaStreamType,System.String,Windows.Foundation.Collections.IPropertySet)
    AddEffectAsync(Windows.Media.Capture.MediaStreamType,System.String,Windows.Foundation.Collections.IPropertySet)

    Adds an audio or video effect.

    public IAsyncAction AddEffectAsync(Windows.Media.Capture.MediaStreamType mediaStreamType,System.String effectActivationID,Windows.Foundation.Collections.IPropertySet effectSettings)public IAsyncAction AddEffectAsync(Windows.Media.Capture.MediaStreamType mediaStreamType,System.String effectActivationID,Windows.Foundation.Collections.IPropertySet effectSettings)Public Function AddEffectAsync(mediaStreamType As Windows.Media.Capture.MediaStreamType,effectActivationID As System.String,effectSettings As Windows.Foundation.Collections.IPropertySet) As IAsyncAction

    Parameters

    Returns

    Remarks

    As of Windows 10, this method is deprecated. Use AddAudioEffectAsync(Windows.Media.Effects.IAudioEffectDefinition) or AddVideoEffectAsync(Windows.Media.Effects.IVideoEffectDefinition,Windows.Media.Capture.MediaStreamType) instead. For how-to guidance on adding effects to the camera capture and preview streams, see Effects for video capture.

  • AddVideoEffectAsync(Windows.Media.Effects.IVideoEffectDefinition,Windows.Media.Capture.MediaStreamType)
    AddVideoEffectAsync(Windows.Media.Effects.IVideoEffectDefinition,Windows.Media.Capture.MediaStreamType)
    AddVideoEffectAsync(Windows.Media.Effects.IVideoEffectDefinition,Windows.Media.Capture.MediaStreamType)
    AddVideoEffectAsync(Windows.Media.Effects.IVideoEffectDefinition,Windows.Media.Capture.MediaStreamType)

    Adds a video effect to the capture pipeline.

    public IAsyncOperation<IMediaExtension> AddVideoEffectAsync(Windows.Media.Effects.IVideoEffectDefinition definition,Windows.Media.Capture.MediaStreamType mediaStreamType)public IAsyncOperation<IMediaExtension> AddVideoEffectAsync(Windows.Media.Effects.IVideoEffectDefinition definition,Windows.Media.Capture.MediaStreamType mediaStreamType)Public Function AddVideoEffectAsync(definition As Windows.Media.Effects.IVideoEffectDefinition,mediaStreamType As Windows.Media.Capture.MediaStreamType) As IAsyncOperation( Of IMediaExtension )

    Parameters

    Returns

    • An asynchronous operation that returns an IMediaExtension upon successful completion.

    Remarks

    For how-to guidance on adding effects to the camera capture and preview streams, see Effects for video capture.

  • CapturePhotoToStorageFileAsync(Windows.Media.MediaProperties.ImageEncodingProperties,Windows.Storage.IStorageFile)
    CapturePhotoToStorageFileAsync(Windows.Media.MediaProperties.ImageEncodingProperties,Windows.Storage.IStorageFile)
    CapturePhotoToStorageFileAsync(Windows.Media.MediaProperties.ImageEncodingProperties,Windows.Storage.IStorageFile)
    CapturePhotoToStorageFileAsync(Windows.Media.MediaProperties.ImageEncodingProperties,Windows.Storage.IStorageFile)

    Captures a photo to a storage file.

    public IAsyncAction CapturePhotoToStorageFileAsync(Windows.Media.MediaProperties.ImageEncodingProperties type,Windows.Storage.IStorageFile file)public IAsyncAction CapturePhotoToStorageFileAsync(Windows.Media.MediaProperties.ImageEncodingProperties type,Windows.Storage.IStorageFile file)Public Function CapturePhotoToStorageFileAsync(type As Windows.Media.MediaProperties.ImageEncodingProperties,file As Windows.Storage.IStorageFile) As IAsyncAction

    Parameters

    Returns

    Remarks

    For how-to guidance on capturing a photo to a storage file, see Basic Basic photo, video, and audio capture with MediaCapture.

  • CapturePhotoToStreamAsync(Windows.Media.MediaProperties.ImageEncodingProperties,Windows.Storage.Streams.IRandomAccessStream)
    CapturePhotoToStreamAsync(Windows.Media.MediaProperties.ImageEncodingProperties,Windows.Storage.Streams.IRandomAccessStream)
    CapturePhotoToStreamAsync(Windows.Media.MediaProperties.ImageEncodingProperties,Windows.Storage.Streams.IRandomAccessStream)
    CapturePhotoToStreamAsync(Windows.Media.MediaProperties.ImageEncodingProperties,Windows.Storage.Streams.IRandomAccessStream)

    Captures a photo to a random-access stream.

    public IAsyncAction CapturePhotoToStreamAsync(Windows.Media.MediaProperties.ImageEncodingProperties type,Windows.Storage.Streams.IRandomAccessStream stream)public IAsyncAction CapturePhotoToStreamAsync(Windows.Media.MediaProperties.ImageEncodingProperties type,Windows.Storage.Streams.IRandomAccessStream stream)Public Function CapturePhotoToStreamAsync(type As Windows.Media.MediaProperties.ImageEncodingProperties,stream As Windows.Storage.Streams.IRandomAccessStream) As IAsyncAction

    Parameters

    Returns

  • ClearEffectsAsync(Windows.Media.Capture.MediaStreamType)
    ClearEffectsAsync(Windows.Media.Capture.MediaStreamType)
    ClearEffectsAsync(Windows.Media.Capture.MediaStreamType)
    ClearEffectsAsync(Windows.Media.Capture.MediaStreamType)

    Removes all audio and video effects from a stream.

    public IAsyncAction ClearEffectsAsync(Windows.Media.Capture.MediaStreamType mediaStreamType)public IAsyncAction ClearEffectsAsync(Windows.Media.Capture.MediaStreamType mediaStreamType)Public Function ClearEffectsAsync(mediaStreamType As Windows.Media.Capture.MediaStreamType) As IAsyncAction

    Parameters

    Returns

  • Close()
    Close()
    Close()
    Close()

    Closes the media capture object.

    public void Close()public void Close()Public Function Close() As void
  • CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource)

    Creates a MediaFrameReader that is used to acquire frames from a MediaFrameSource.

    public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource inputSource)public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource inputSource)Public Function CreateFrameReaderAsync(inputSource As Windows.Media.Capture.Frames.MediaFrameSource) As IAsyncOperation( Of MediaFrameReader )

    Parameters

    Returns

  • CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource,System.String)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource,System.String)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource,System.String)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource,System.String)

    Creates a MediaFrameReader that is used to acquire frames with the specified media encoding subtype from a MediaFrameSource.

    public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource inputSource,System.String outputSubtype)public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource inputSource,System.String outputSubtype)Public Function CreateFrameReaderAsync(inputSource As Windows.Media.Capture.Frames.MediaFrameSource,outputSubtype As System.String) As IAsyncOperation( Of MediaFrameReader )

    Parameters

    Returns

  • CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource,System.String,Windows.Graphics.Imaging.BitmapSize)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource,System.String,Windows.Graphics.Imaging.BitmapSize)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource,System.String,Windows.Graphics.Imaging.BitmapSize)
    CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource,System.String,Windows.Graphics.Imaging.BitmapSize)

    Creates a MediaFrameReader that is used to acquire frames with the specified media encoding subtype and size from a MediaFrameSource.

    public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource inputSource,System.String outputSubtype,Windows.Graphics.Imaging.BitmapSize outputSize)public IAsyncOperation<MediaFrameReader> CreateFrameReaderAsync(Windows.Media.Capture.Frames.MediaFrameSource inputSource,System.String outputSubtype,Windows.Graphics.Imaging.BitmapSize outputSize)Public Function CreateFrameReaderAsync(inputSource As Windows.Media.Capture.Frames.MediaFrameSource,outputSubtype As System.String,outputSize As Windows.Graphics.Imaging.BitmapSize) As IAsyncOperation( Of MediaFrameReader )

    Parameters

    Returns

  • FindAllVideoProfiles(System.String)
    FindAllVideoProfiles(System.String)
    FindAllVideoProfiles(System.String)
    FindAllVideoProfiles(System.String)

    Retrieves the list of all video profiles supported by the specified video capture device.

    public static IVectorView<MediaCaptureVideoProfile> FindAllVideoProfiles(System.String videoDeviceId)public static IVectorView<MediaCaptureVideoProfile> FindAllVideoProfiles(System.String videoDeviceId)Public Static Function FindAllVideoProfiles(videoDeviceId As System.String) As IVectorView( Of MediaCaptureVideoProfile )

    Parameters

    • videoDeviceId
      System.String
      System.String
      System.String
      System.String

      The identifier of the video device for which supported video profiles are queried. For information on getting the video device ID, see FindAllAsync(System.String).

    Returns

    • The list of video profiles supported by the specified video capture device.

    Remarks

    Before calling this method, call IsVideoProfileSupported(System.String) to make sure that the capture device supports video profiles.

    Use FindKnownVideoProfiles(System.String,Windows.Media.Capture.KnownVideoProfile) to request profiles with specific functionality using one of the KnownVideoProfile values.

    For how-to guidance for working with camera profiles, see Discover and select camera capabilities with camera profiles.

  • FindConcurrentProfiles(System.String)
    FindConcurrentProfiles(System.String)
    FindConcurrentProfiles(System.String)
    FindConcurrentProfiles(System.String)

    Retrieves the list of video profiles supported by the specified video capture device that can be used while another profile is used on a different capture device.

    public static IVectorView<MediaCaptureVideoProfile> FindConcurrentProfiles(System.String videoDeviceId)public static IVectorView<MediaCaptureVideoProfile> FindConcurrentProfiles(System.String videoDeviceId)Public Static Function FindConcurrentProfiles(videoDeviceId As System.String) As IVectorView( Of MediaCaptureVideoProfile )

    Parameters

    • videoDeviceId
      System.String
      System.String
      System.String
      System.String

      The identifier of the video device for which supported video profiles are queried. For information on getting the video device ID, see FindAllAsync(System.String).

    Returns

    • The list of video profiles supported by the specified video capture device that support concurrency.

    Remarks

    Before calling this method, call IsVideoProfileSupported(System.String) to make sure that the capture device supports video profiles.

    This method supports the scenario where you capture video from two capture devices at the same time, such as a device's front camera and rear camera. Call the GetConcurrency() method of one of the MediaCaptureVideoProfile objects in the returned list to get a list of profiles that can be used concurrently with that profile.

    For how-to guidance for working with camera profiles, see Discover and select camera capabilities with camera profiles.

  • FindKnownVideoProfiles(System.String,Windows.Media.Capture.KnownVideoProfile)
    FindKnownVideoProfiles(System.String,Windows.Media.Capture.KnownVideoProfile)
    FindKnownVideoProfiles(System.String,Windows.Media.Capture.KnownVideoProfile)
    FindKnownVideoProfiles(System.String,Windows.Media.Capture.KnownVideoProfile)

    Retrieves the list of all video profiles supported by the specified video capture device that match the specified KnownVideoProfile value.

    public static IVectorView<MediaCaptureVideoProfile> FindKnownVideoProfiles(System.String videoDeviceId,Windows.Media.Capture.KnownVideoProfile name)public static IVectorView<MediaCaptureVideoProfile> FindKnownVideoProfiles(System.String videoDeviceId,Windows.Media.Capture.KnownVideoProfile name)Public Static Function FindKnownVideoProfiles(videoDeviceId As System.String,name As Windows.Media.Capture.KnownVideoProfile) As IVectorView( Of MediaCaptureVideoProfile )

    Parameters

    Returns

    • The list of video profiles supported by the specified video capture device that match the specified known profile name.

    Remarks

    Before calling this method, call IsVideoProfileSupported(System.String) to make sure that the capture device supports video profiles.

    This method allows you to request profiles with specific functionality by using one of the KnownVideoProfile values. Some hardware may support additional profiles that do not correspond to any of the known profile names. Use FindAllVideoProfiles(System.String) to retrieve all video profiles supported by the video capture device.

    For how-to guidance for working with camera profiles, see Discover and select camera capabilities with camera profiles.

  • GetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid)
    GetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid)
    GetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid)
    GetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid)

    Gets the value of an encoding property.

    public object GetEncoderProperty(Windows.Media.Capture.MediaStreamType mediaStreamType,System.Guid propertyId)public object GetEncoderProperty(Windows.Media.Capture.MediaStreamType mediaStreamType,System.Guid propertyId)Public Function GetEncoderProperty(mediaStreamType As Windows.Media.Capture.MediaStreamType,propertyId As System.Guid) As object

    Parameters

    Returns

    • object
      object
      object
      object

      Returns the value of the encoding property.

  • GetPreviewFrameAsync()
    GetPreviewFrameAsync()
    GetPreviewFrameAsync()
    GetPreviewFrameAsync()

    Gets a preview frame from the capture device.

    public IAsyncOperation<VideoFrame> GetPreviewFrameAsync()public IAsyncOperation<VideoFrame> GetPreviewFrameAsync()Public Function GetPreviewFrameAsync() As IAsyncOperation( Of VideoFrame )

    Returns

    • An asynchronous operation that returns a VideoFrame on successful completion.

    Remarks

    This method returns the preview frame in the current format of the capture device without copying or converting the frame. To get the preview frame in another format, use the GetPreviewFrameAsync(Windows.Media.VideoFrame) overload and pass in a GetPreviewFrameAsync(Windows.Media.VideoFrame) with your desired format.

    For how-to guidance on preview frames, see Get a preview frame.

  • GetPreviewFrameAsync(Windows.Media.VideoFrame)
    GetPreviewFrameAsync(Windows.Media.VideoFrame)
    GetPreviewFrameAsync(Windows.Media.VideoFrame)
    GetPreviewFrameAsync(Windows.Media.VideoFrame)

    Gets a preview frame from the capture device, copied into the provided destination VideoFrame and converted into the destination frame's format.

    public IAsyncOperation<VideoFrame> GetPreviewFrameAsync(Windows.Media.VideoFrame destination)public IAsyncOperation<VideoFrame> GetPreviewFrameAsync(Windows.Media.VideoFrame destination)Public Function GetPreviewFrameAsync(destination As Windows.Media.VideoFrame) As IAsyncOperation( Of VideoFrame )

    Parameters

    Returns

    • An asynchronous operation that returns a VideoFrame on successful completion.

    Remarks

    To get a preview frame without going through a copy or conversion operation, use the no argument overload of GetPreviewFrameAsync(Windows.Media.VideoFrame).

    For how-to guidance on preview frames, see Get a preview frame.

  • GetPreviewMirroring()
    GetPreviewMirroring()
    GetPreviewMirroring()
    GetPreviewMirroring()

    Queries whether the video stream is mirrored horizontally.

    public bool GetPreviewMirroring()public bool GetPreviewMirroring()Public Function GetPreviewMirroring() As bool

    Returns

    • bool
      bool
      bool
      bool

      True if mirroring is enabled; false otherwise.

  • GetPreviewRotation()
    GetPreviewRotation()
    GetPreviewRotation()
    GetPreviewRotation()

    Gets the rotation of the video preview stream.

    public VideoRotation GetPreviewRotation()public VideoRotation GetPreviewRotation()Public Function GetPreviewRotation() As VideoRotation

    Returns

  • GetRecordRotation()
    GetRecordRotation()
    GetRecordRotation()
    GetRecordRotation()

    Gets the rotation of the recorded video.

    public VideoRotation GetRecordRotation()public VideoRotation GetRecordRotation()Public Function GetRecordRotation() As VideoRotation

    Returns

  • InitializeAsync()
    InitializeAsync()
    InitializeAsync()
    InitializeAsync()

    Initializes the MediaCapture object, using default settings.

    public IAsyncAction InitializeAsync()public IAsyncAction InitializeAsync()Public Function InitializeAsync() As IAsyncAction

    Returns

    Remarks

    InitializeAsync() will launch a consent prompt to get the user's permission for the app to access the microphone or camera. InitializeAsync() should be called from the main UI thread of your app. In apps that use C# or C++, the first use of the MediaCapture object to call InitializeAsync() should be on the STA thread. Calls from an MTA thread may result in undefined behavior.

    For how-to guidance on initializing and shutting down the MediaCapture object, see Basic photo, video, and audio capture with MediaCapture.

  • InitializeAsync(Windows.Media.Capture.MediaCaptureInitializationSettings)
    InitializeAsync(Windows.Media.Capture.MediaCaptureInitializationSettings)
    InitializeAsync(Windows.Media.Capture.MediaCaptureInitializationSettings)
    InitializeAsync(Windows.Media.Capture.MediaCaptureInitializationSettings)

    Initializes the MediaCapture object.

    public IAsyncAction InitializeAsync(Windows.Media.Capture.MediaCaptureInitializationSettings mediaCaptureInitializationSettings)public IAsyncAction InitializeAsync(Windows.Media.Capture.MediaCaptureInitializationSettings mediaCaptureInitializationSettings)Public Function InitializeAsync(mediaCaptureInitializationSettings As Windows.Media.Capture.MediaCaptureInitializationSettings) As IAsyncAction

    Parameters

    Returns

    Remarks

    InitializeAsync(Windows.Media.Capture.MediaCaptureInitializationSettings) will launch a consent prompt to get the user's permission for the app to access the microphone or camera. InitializeAsync(Windows.Media.Capture.MediaCaptureInitializationSettings) should be called from the main UI thread of your app. In apps that use C# or C++, the first use of the MediaCapture object to call InitializeAsync() should be on the STA thread. Calls from an MTA thread may result in undefined behavior.

    For how-to guidance on initializing and shutting down the MediaCapture object, see Basic photo, video, and audio capture with MediaCapture.

  • IsVideoProfileSupported(System.String)
    IsVideoProfileSupported(System.String)
    IsVideoProfileSupported(System.String)
    IsVideoProfileSupported(System.String)

    Gets a boolean value indicating whether video profiles are supported by the specified video capture device.

    public static bool IsVideoProfileSupported(System.String videoDeviceId)public static bool IsVideoProfileSupported(System.String videoDeviceId)Public Static Function IsVideoProfileSupported(videoDeviceId As System.String) As bool

    Parameters

    • videoDeviceId
      System.String
      System.String
      System.String
      System.String

      The identifier of the video device for which supported video profile support is queried. For information on getting the video device ID, see FindAllAsync(System.String).

    Returns

    • bool
      bool
      bool
      bool

      True if video profiles are supported; otherwise, false.

  • PauseRecordAsync(Windows.Media.Devices.MediaCapturePauseBehavior)
    PauseRecordAsync(Windows.Media.Devices.MediaCapturePauseBehavior)
    PauseRecordAsync(Windows.Media.Devices.MediaCapturePauseBehavior)
    PauseRecordAsync(Windows.Media.Devices.MediaCapturePauseBehavior)

    Pauses an ongoing record operation.

    public IAsyncAction PauseRecordAsync(Windows.Media.Devices.MediaCapturePauseBehavior behavior)public IAsyncAction PauseRecordAsync(Windows.Media.Devices.MediaCapturePauseBehavior behavior)Public Function PauseRecordAsync(behavior As Windows.Media.Devices.MediaCapturePauseBehavior) As IAsyncAction

    Parameters

    Returns

    Remarks

    Resume recording by calling ResumeRecordAsync().

  • PauseRecordWithResultAsync(Windows.Media.Devices.MediaCapturePauseBehavior)
    PauseRecordWithResultAsync(Windows.Media.Devices.MediaCapturePauseBehavior)
    PauseRecordWithResultAsync(Windows.Media.Devices.MediaCapturePauseBehavior)
    PauseRecordWithResultAsync(Windows.Media.Devices.MediaCapturePauseBehavior)

    Pauses an ongoing media record operation and provides a MediaCapturePauseResult that can be used to help the user align the camera with the last captured frame when resuming recording.

    public IAsyncOperation<MediaCapturePauseResult> PauseRecordWithResultAsync(Windows.Media.Devices.MediaCapturePauseBehavior behavior)public IAsyncOperation<MediaCapturePauseResult> PauseRecordWithResultAsync(Windows.Media.Devices.MediaCapturePauseBehavior behavior)Public Function PauseRecordWithResultAsync(behavior As Windows.Media.Devices.MediaCapturePauseBehavior) As IAsyncOperation( Of MediaCapturePauseResult )

    Parameters

    Returns

  • PrepareAdvancedPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareAdvancedPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareAdvancedPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareAdvancedPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)

    Initializes the advanced photo capture and provides the AdvancedPhotoCapture object used to manage the recording.

    public IAsyncOperation<AdvancedPhotoCapture> PrepareAdvancedPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties encodingProperties)public IAsyncOperation<AdvancedPhotoCapture> PrepareAdvancedPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties encodingProperties)Public Function PrepareAdvancedPhotoCaptureAsync(encodingProperties As Windows.Media.MediaProperties.ImageEncodingProperties) As IAsyncOperation( Of AdvancedPhotoCapture )

    Parameters

    Returns

  • PrepareLowLagPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareLowLagPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareLowLagPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareLowLagPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)

    Initializes the low shutter lag photo capture and provides the LowLagPhotoCapture object used to manage the recording.

    public IAsyncOperation<LowLagPhotoCapture> PrepareLowLagPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties type)public IAsyncOperation<LowLagPhotoCapture> PrepareLowLagPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties type)Public Function PrepareLowLagPhotoCaptureAsync(type As Windows.Media.MediaProperties.ImageEncodingProperties) As IAsyncOperation( Of LowLagPhotoCapture )

    Parameters

    Returns

    • When this method completes, a LowLagPhotoCapture object is returned which can be used to start the photo capture.

    Remarks

    Use PrepareLowLagPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties) to initialize the capture. This is an asynchronous calls which returns a LowLagPhotoCapture object when it is finished, which is used to start the actual photo capture by calling CaptureAsync().

    PrepareLowLagPhotoCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties) must be called before CaptureAsync().

    For how-to guidance on using LowLagPhotoCapture to capture a photo, see Basic photo, video, and audio capture with MediaCapture.

  • PrepareLowLagPhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareLowLagPhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareLowLagPhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareLowLagPhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)

    Initializes the low shutter lag photo sequence capture and provides the LowLagPhotoSequenceCapture object used to manage the recording.

    public IAsyncOperation<LowLagPhotoSequenceCapture> PrepareLowLagPhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties type)public IAsyncOperation<LowLagPhotoSequenceCapture> PrepareLowLagPhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties type)Public Function PrepareLowLagPhotoSequenceCaptureAsync(type As Windows.Media.MediaProperties.ImageEncodingProperties) As IAsyncOperation( Of LowLagPhotoSequenceCapture )

    Parameters

    Returns

    • When this method completes, a LowLagPhotoSequenceCapture object is returned which can be used to start the photo sequence capture.

    Remarks

    Use PrepareLowLagPhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties) to initialize the photo sequence capture. This is an asynchronous call which returns a LowLagPhotoSequenceCapture object when it is finished, which is used start the photo sequence capture by calling StartAsync().

    PrepareLowLagPhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties) must be called before StartAsync().

  • PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)

    Initializes the low lag recording using the specified custom sink to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

    public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,System.String customSinkActivationId,Windows.Foundation.Collections.IPropertySet customSinkSettings)public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,System.String customSinkActivationId,Windows.Foundation.Collections.IPropertySet customSinkSettings)Public Function PrepareLowLagRecordToCustomSinkAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,customSinkActivationId As System.String,customSinkSettings As Windows.Foundation.Collections.IPropertySet) As IAsyncOperation( Of LowLagMediaRecording )

    Parameters

    Returns

    • When this method completes, a LowLagMediaRecording object is returned which can be used to start the photo capture.

  • PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)

    Initializes the low lag recording using the specified custom sink to store the recording. This method provides the LowLagMediaRecording object used to managed the capture.

    public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Media.IMediaExtension customMediaSink)public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Media.IMediaExtension customMediaSink)Public Function PrepareLowLagRecordToCustomSinkAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,customMediaSink As Windows.Media.IMediaExtension) As IAsyncOperation( Of LowLagMediaRecording )

    Parameters

    Returns

    • When this method completes, a LowLagMediaRecording object is returned which can be used to start the photo capture.

  • PrepareLowLagRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.IStorageFile)
    PrepareLowLagRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.IStorageFile)
    PrepareLowLagRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.IStorageFile)
    PrepareLowLagRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.IStorageFile)

    Initializes the low lag recording using the specified file to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

    public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Storage.IStorageFile file)public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Storage.IStorageFile file)Public Function PrepareLowLagRecordToStorageFileAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,file As Windows.Storage.IStorageFile) As IAsyncOperation( Of LowLagMediaRecording )

    Parameters

    Returns

    • When this method completes, a LowLagMediaRecording object is returned which can be used to start the photo capture.

  • PrepareLowLagRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.Streams.IRandomAccessStream)
    PrepareLowLagRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.Streams.IRandomAccessStream)
    PrepareLowLagRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.Streams.IRandomAccessStream)
    PrepareLowLagRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.Streams.IRandomAccessStream)

    Initializes the low lag recording using the specified random-access stream to store the recording. This method provides the LowLagMediaRecording object used to managed the recording.

    public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Storage.Streams.IRandomAccessStream stream)public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Storage.Streams.IRandomAccessStream stream)Public Function PrepareLowLagRecordToStreamAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,stream As Windows.Storage.Streams.IRandomAccessStream) As IAsyncOperation( Of LowLagMediaRecording )

    Parameters

    Returns

    • When this method completes, a LowLagMediaRecording object is returned which can be used to start the photo capture.

  • PrepareVariablePhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareVariablePhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareVariablePhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)
    PrepareVariablePhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties)

    Initializes the variable photo sequence capture and provides the VariablePhotoSequenceCapture object used to manage the recording.

    public IAsyncOperation<VariablePhotoSequenceCapture> PrepareVariablePhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties type)public IAsyncOperation<VariablePhotoSequenceCapture> PrepareVariablePhotoSequenceCaptureAsync(Windows.Media.MediaProperties.ImageEncodingProperties type)Public Function PrepareVariablePhotoSequenceCaptureAsync(type As Windows.Media.MediaProperties.ImageEncodingProperties) As IAsyncOperation( Of VariablePhotoSequenceCapture )

    Parameters

    Returns

  • RemoveEffectAsync(Windows.Media.IMediaExtension)
    RemoveEffectAsync(Windows.Media.IMediaExtension)
    RemoveEffectAsync(Windows.Media.IMediaExtension)
    RemoveEffectAsync(Windows.Media.IMediaExtension)

    Removes the specified effect from the capture pipeline.

    public IAsyncAction RemoveEffectAsync(Windows.Media.IMediaExtension effect)public IAsyncAction RemoveEffectAsync(Windows.Media.IMediaExtension effect)Public Function RemoveEffectAsync(effect As Windows.Media.IMediaExtension) As IAsyncAction

    Parameters

    Returns

    Remarks

    Pass the effect instance returned by AddVideoEffectAsync(Windows.Media.Effects.IVideoEffectDefinition,Windows.Media.Capture.MediaStreamType) or AddAudioEffectAsync(Windows.Media.Effects.IAudioEffectDefinition) into this method to remove the effect from the pipeline.

  • ResumeRecordAsync()
    ResumeRecordAsync()
    ResumeRecordAsync()
    ResumeRecordAsync()

    Resumes a paused recording operation.

    public IAsyncAction ResumeRecordAsync()public IAsyncAction ResumeRecordAsync()Public Function ResumeRecordAsync() As IAsyncAction

    Returns

    Remarks

    Pause recording by calling PauseRecordAsync(Windows.Media.Devices.MediaCapturePauseBehavior).

  • SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object)
    SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object)
    SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object)
    SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object)

    Sets an encoding property.

    public void SetEncoderProperty(Windows.Media.Capture.MediaStreamType mediaStreamType,System.Guid propertyId,System.Object propertyValue)public void SetEncoderProperty(Windows.Media.Capture.MediaStreamType mediaStreamType,System.Guid propertyId,System.Object propertyValue)Public Function SetEncoderProperty(mediaStreamType As Windows.Media.Capture.MediaStreamType,propertyId As System.Guid,propertyValue As System.Object) As void

    Parameters

    • mediaStreamType

      The type of media data the stream represents, such as video or audio.

    • propertyId
      System.Guid
      System.Guid
      System.Guid
      System.Guid

      The encoding property to set.

    • propertyValue
      System.Object
      System.Object
      System.Object
      System.Object

      The new value of the encoding property.

    Remarks

    You can only call SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object) with mediaStreamType equal to MediaStreamType, if the encoder property is applied to only the audio encoder in the record sink. The preview sink does not allow you to set an encoding profile with compressed audio.

    For non-H.264 cameras, when you call SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object) before recording or previewing has started, the property is stored locally. When you start recording, the property is applied to the encoder at the time of encoder initialization. To configure static encoding properties, you must call SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object) before recording or previewing starts. Before recording or previewing starts, GetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid) will return the value of the property stored locally.

    If the camera is a H.264 camera and the stream that SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object) is called on is of type MediaStreamType, then the property is applied directly to the camera. This is true both before and after recording has started.

    For non-H.264 cameras, when you call SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object) after you get the record or preview started completion callback, the property is set directly on the encoder and is therefore used to configure dynamic encoding properties.

    If you call SetEncoderProperty(Windows.Media.Capture.MediaStreamType,System.Guid,System.Object) after you issue a call to start recording or previewing and before you get the record or preview started completion callback, you will receive an MF_E_INVALIDREQUEST error since the property cannot be applied to static nor dynamic settings.

    To rotate the preview stream, use the GUID defined as MF_MT_VIDEO_ROTATION. For how-to guidance on handling orientation when using the camera, see Handle device orientation with MediaCapture.

  • SetEncodingPropertiesAsync(Windows.Media.Capture.MediaStreamType,Windows.Media.MediaProperties.IMediaEncodingProperties,Windows.Media.MediaProperties.MediaPropertySet)
    SetEncodingPropertiesAsync(Windows.Media.Capture.MediaStreamType,Windows.Media.MediaProperties.IMediaEncodingProperties,Windows.Media.MediaProperties.MediaPropertySet)
    SetEncodingPropertiesAsync(Windows.Media.Capture.MediaStreamType,Windows.Media.MediaProperties.IMediaEncodingProperties,Windows.Media.MediaProperties.MediaPropertySet)
    SetEncodingPropertiesAsync(Windows.Media.Capture.MediaStreamType,Windows.Media.MediaProperties.IMediaEncodingProperties,Windows.Media.MediaProperties.MediaPropertySet)

    Asynchronously sets the media encoding properties.

    public IAsyncAction SetEncodingPropertiesAsync(Windows.Media.Capture.MediaStreamType mediaStreamType,Windows.Media.MediaProperties.IMediaEncodingProperties mediaEncodingProperties,Windows.Media.MediaProperties.MediaPropertySet encoderProperties)public IAsyncAction SetEncodingPropertiesAsync(Windows.Media.Capture.MediaStreamType mediaStreamType,Windows.Media.MediaProperties.IMediaEncodingProperties mediaEncodingProperties,Windows.Media.MediaProperties.MediaPropertySet encoderProperties)Public Function SetEncodingPropertiesAsync(mediaStreamType As Windows.Media.Capture.MediaStreamType,mediaEncodingProperties As Windows.Media.MediaProperties.IMediaEncodingProperties,encoderProperties As Windows.Media.MediaProperties.MediaPropertySet) As IAsyncAction

    Parameters

    Returns

    Remarks

    This method sets the encoding properties of the encoder that processes the data before it’s passed on to a CaptureElement to be displayed, written out to a IRandomAccessStream or StorageFile, or delivered to a custom media sink. This method does not change the configuration of the source of the data, which is the camera device. It is possible to set the encoding properties to a resolution that is not natively supported by the camera. In this case, the MediaCapture pipeline will use an encoder to perform the conversion to the requested format. Note that this conversion does consume system resources and can result in poor performance or even errors, especially on devices that with limited or no graphics acceleration. For typical scenarios, it is recommended that you choose a resolution supported by the camera that is closest to your desired resolution. You can get a list of a capture device's supported resolutions by calling GetAvailableMediaStreamProperties(Windows.Media.Capture.MediaStreamType). For more information, see Set format, resolution, and frame rate for MediaCapture and the Camera Resolution Sample.

    To rotate the record or preview stream, use the GUID defined by MF_MT_VIDEO_ROTATION to add metadata to the stream. Note that this rotation is performed by the consumer of the stream, such as the CaptureElement or a video player app, while the actual pixels in the stream still retain their original orientation. For how-to guidance on handling orientation when using the camera, see Handle device orientation with MediaCapture.

    To modify the properties of the capture device, use SetMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType,Windows.Media.MediaProperties.IMediaEncodingProperties).

  • SetPreviewMirroring(System.Boolean)
    SetPreviewMirroring(System.Boolean)
    SetPreviewMirroring(System.Boolean)
    SetPreviewMirroring(System.Boolean)

    Enables or disables horizontal mirroring of the video preview stream. This is not the preferred method for mirroring. See the Remarks section below for details.

    public void SetPreviewMirroring(System.Boolean value)public void SetPreviewMirroring(System.Boolean value)Public Function SetPreviewMirroring(value As System.Boolean) As void

    Parameters

    • value
      System.Boolean
      System.Boolean
      System.Boolean
      System.Boolean

      True to enable mirroring; false to disable mirroring.

    Remarks

    Horizontal mirroring is useful for video conferencing or video chat applications, because the users typically want to see a reflected image of themselves. The non-mirrored view can look strange, because we are used to seeing ourselves in a mirror.

    To mirror the preview video, apps should instead use the following method. Windows app using JavaScript should use the msHorizontalMirror property of the video object. Windows Store app using C++, C#, or Visual Basic should use the FlowDirection property on the CaptureElement.

    SetPreviewMirroring(System.Boolean) can potentially be used as a performance optimization on some devices

    For how-to guidance on handling orientation and mirroring when using the camera, see Handle device orientation with MediaCapture.

  • SetPreviewRotation(Windows.Media.Capture.VideoRotation)
    SetPreviewRotation(Windows.Media.Capture.VideoRotation)
    SetPreviewRotation(Windows.Media.Capture.VideoRotation)
    SetPreviewRotation(Windows.Media.Capture.VideoRotation)

    Rotates the video preview stream.

    public void SetPreviewRotation(Windows.Media.Capture.VideoRotation value)public void SetPreviewRotation(Windows.Media.Capture.VideoRotation value)Public Function SetPreviewRotation(value As Windows.Media.Capture.VideoRotation) As void

    Parameters

    Remarks

    For how-to guidance on handling orientation when using the camera, see Handle device orientation with MediaCapture.

  • SetRecordRotation(Windows.Media.Capture.VideoRotation)
    SetRecordRotation(Windows.Media.Capture.VideoRotation)
    SetRecordRotation(Windows.Media.Capture.VideoRotation)
    SetRecordRotation(Windows.Media.Capture.VideoRotation)

    Rotates the recorded video.

    public void SetRecordRotation(Windows.Media.Capture.VideoRotation value)public void SetRecordRotation(Windows.Media.Capture.VideoRotation value)Public Function SetRecordRotation(value As Windows.Media.Capture.VideoRotation) As void

    Parameters

    Remarks

    For how-to guidance on handling orientation when using the camera, see Handle device orientation with MediaCapture.

  • StartPreviewAsync()
    StartPreviewAsync()
    StartPreviewAsync()
    StartPreviewAsync()

    Starts preview.

    public IAsyncAction StartPreviewAsync()public IAsyncAction StartPreviewAsync()Public Function StartPreviewAsync() As IAsyncAction

    Returns

  • StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)

    Starts sending a preview stream to a custom media sink using the specified encoding profile and sink settings.

    public IAsyncAction StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,System.String customSinkActivationId,Windows.Foundation.Collections.IPropertySet customSinkSettings)public IAsyncAction StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,System.String customSinkActivationId,Windows.Foundation.Collections.IPropertySet customSinkSettings)Public Function StartPreviewToCustomSinkAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,customSinkActivationId As System.String,customSinkSettings As Windows.Foundation.Collections.IPropertySet) As IAsyncAction

    Parameters

    Returns

    Remarks

    When you call StartPreviewToCustomSinkAsync, the system will call the custom sink’s IMFMediaTypeHandler::IsMediaTypeSupported method, passing in the native media type of the capture device. This check is performed in an effort to avoid unnecessary video conversion. If the custom sink returns S_OK from IsMediaTypeSupported when this check is made, then the preview stream will use the native media type instead of the type specified by the encodingProfile parameter.

  • StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)

    Starts sending a preview stream to a custom media sink using the specified encoding profile.

    public IAsyncAction StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Media.IMediaExtension customMediaSink)public IAsyncAction StartPreviewToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Media.IMediaExtension customMediaSink)Public Function StartPreviewToCustomSinkAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,customMediaSink As Windows.Media.IMediaExtension) As IAsyncAction

    Parameters

    Returns

    Remarks

    When you call StartPreviewToCustomSinkAsync, the system will call the custom sink’s IMFMediaTypeHandler::IsMediaTypeSupported method, passing in the native media type of the capture device. This check is performed in an effort to avoid unnecessary video conversion. If the custom sink returns S_OK from IsMediaTypeSupported when this check is made, then the preview stream will use the native media type instead of the type specified by the encodingProfile parameter.

  • StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)
    StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,System.String,Windows.Foundation.Collections.IPropertySet)

    Start recording to a custom media sink using the specified encoding profile and sink settings.

    public IAsyncAction StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,System.String customSinkActivationId,Windows.Foundation.Collections.IPropertySet customSinkSettings)public IAsyncAction StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,System.String customSinkActivationId,Windows.Foundation.Collections.IPropertySet customSinkSettings)Public Function StartRecordToCustomSinkAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,customSinkActivationId As System.String,customSinkSettings As Windows.Foundation.Collections.IPropertySet) As IAsyncAction

    Parameters

    Returns

    Remarks

    A RecordLimitationExceeded event is raised if the record limit is exceeded. In the current release, the record limit is three hours.

  • StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)
    StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Media.IMediaExtension)

    Start recording to a custom media sink using the specified encoding profile.

    public IAsyncAction StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Media.IMediaExtension customMediaSink)public IAsyncAction StartRecordToCustomSinkAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Media.IMediaExtension customMediaSink)Public Function StartRecordToCustomSinkAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,customMediaSink As Windows.Media.IMediaExtension) As IAsyncAction

    Parameters

    Returns

    Remarks

    A RecordLimitationExceeded event is raised if the record limit is exceeded. In the current release, record limit is three hours.

  • StartRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.IStorageFile)
    StartRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.IStorageFile)
    StartRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.IStorageFile)
    StartRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.IStorageFile)

    Starts recording asynchronously to a storage file.

    public IAsyncAction StartRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Storage.IStorageFile file)public IAsyncAction StartRecordToStorageFileAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Storage.IStorageFile file)Public Function StartRecordToStorageFileAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,file As Windows.Storage.IStorageFile) As IAsyncAction

    Parameters

    Returns

    Remarks

    For how-to guidance on recording to a file, see Basic photo, video, and audio capture with MediaCapture.

  • StartRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.Streams.IRandomAccessStream)
    StartRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.Streams.IRandomAccessStream)
    StartRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.Streams.IRandomAccessStream)
    StartRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile,Windows.Storage.Streams.IRandomAccessStream)

    Starts recording to a random-access stream.

    public IAsyncAction StartRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Storage.Streams.IRandomAccessStream stream)public IAsyncAction StartRecordToStreamAsync(Windows.Media.MediaProperties.MediaEncodingProfile encodingProfile,Windows.Storage.Streams.IRandomAccessStream stream)Public Function StartRecordToStreamAsync(encodingProfile As Windows.Media.MediaProperties.MediaEncodingProfile,stream As Windows.Storage.Streams.IRandomAccessStream) As IAsyncAction

    Parameters

    Returns

    Remarks

    For how-to guidance on recording to a file, see Basic photo, video, and audio capture with MediaCapture.

  • StopPreviewAsync()
    StopPreviewAsync()
    StopPreviewAsync()
    StopPreviewAsync()

    Stops preview.

    public IAsyncAction StopPreviewAsync()public IAsyncAction StopPreviewAsync()Public Function StopPreviewAsync() As IAsyncAction

    Returns

  • StopRecordAsync()
    StopRecordAsync()
    StopRecordAsync()
    StopRecordAsync()

    Stops recording.

    public IAsyncAction StopRecordAsync()public IAsyncAction StopRecordAsync()Public Function StopRecordAsync() As IAsyncAction

    Returns

    Remarks

    Before playing back a video, the RandomAccessStream should be closed when StopRecordAsync() completes.

  • StopRecordWithResultAsync()
    StopRecordWithResultAsync()
    StopRecordWithResultAsync()
    StopRecordWithResultAsync()

    Asynchronously stops the media recording and provides a MediaCaptureStopResult that can be used to help the user align the camera with the last captured frame when restarting recording.

    public IAsyncOperation<MediaCaptureStopResult> StopRecordWithResultAsync()public IAsyncOperation<MediaCaptureStopResult> StopRecordWithResultAsync()Public Function StopRecordWithResultAsync() As IAsyncOperation( Of MediaCaptureStopResult )

    Returns

  • CreateMultiSourceFrameReaderAsync(Windows.Foundation.Collections.IIterable{Windows.Media.Capture.Frames.MediaFrameSource})
    CreateMultiSourceFrameReaderAsync(Windows.Foundation.Collections.IIterable{Windows.Media.Capture.Frames.MediaFrameSource})
    CreateMultiSourceFrameReaderAsync(Windows.Foundation.Collections.IIterable{Windows.Media.Capture.Frames.MediaFrameSource})
    CreateMultiSourceFrameReaderAsync(Windows.Foundation.Collections.IIterable{Windows.Media.Capture.Frames.MediaFrameSource})

    Prerelease. Creates a MultiSourceMediaFrameReader that is used to acquire time-correlated frames from one or more MediaFrameSource objects.

    public IAsyncOperation<MultiSourceMediaFrameReader> CreateMultiSourceFrameReaderAsync(Windows.Foundation.Collections.IIterable{Windows.Media.Capture.Frames.MediaFrameSource} inputSources)public IAsyncOperation<MultiSourceMediaFrameReader> CreateMultiSourceFrameReaderAsync(Windows.Foundation.Collections.IIterable{Windows.Media.Capture.Frames.MediaFrameSource} inputSources)Public Function CreateMultiSourceFrameReaderAsync(inputSources As Windows.Foundation.Collections.IIterable{Windows.Media.Capture.Frames.MediaFrameSource}) As IAsyncOperation( Of MultiSourceMediaFrameReader )

    Parameters

    Returns

Events

  • CameraStreamStateChanged
    CameraStreamStateChanged
    CameraStreamStateChanged
    CameraStreamStateChanged

    Occurs when the state of the camera stream changes.

    public event TypedEventHandler CameraStreamStateChangedpublic event TypedEventHandler CameraStreamStateChangedPublic Event CameraStreamStateChanged

    Remarks

    The state of the camera stream will change when recording is paused or resumed, when the system drops frames for privacy reasons, or when the camera stream is lost.

  • Failed
    Failed
    Failed
    Failed

    Raised when an error occurs during media capture.

    public event MediaCaptureFailedEventHandler Failedpublic event MediaCaptureFailedEventHandler FailedPublic Event Failed
  • FocusChanged
    FocusChanged
    FocusChanged
    FocusChanged

    Occurs when the capture device changes focus.

    public event TypedEventHandler FocusChangedpublic event TypedEventHandler FocusChangedPublic Event FocusChanged
  • PhotoConfirmationCaptured
    PhotoConfirmationCaptured
    PhotoConfirmationCaptured
    PhotoConfirmationCaptured

    Occurs when a photo confirmation frame is captured.

    public event TypedEventHandler PhotoConfirmationCapturedpublic event TypedEventHandler PhotoConfirmationCapturedPublic Event PhotoConfirmationCaptured

    Remarks

    The CapturedFrame object passed to this event contains raw pixel data and therefore must be manually copied into the pixel buffer of a bitmap. For information on how to do this, see the Remarks section of the Frame property.

  • RecordLimitationExceeded
    RecordLimitationExceeded
    RecordLimitationExceeded
    RecordLimitationExceeded

    Occurs when the record limit is exceeded.

    public event RecordLimitationExceededEventHandler RecordLimitationExceededpublic event RecordLimitationExceededEventHandler RecordLimitationExceededPublic Event RecordLimitationExceeded

    Remarks

    If an app receives a RecordLimitationExceeded event, it is expected to finalize the file it is recording. If it does not finalize, the capture engine will stop sending samples to the file that the app was recording to.

    In the current release, the record limit is three hours.

  • ThermalStatusChanged
    ThermalStatusChanged
    ThermalStatusChanged
    ThermalStatusChanged

    Occurs when the thermal status of the capture device changes.

    public event TypedEventHandler ThermalStatusChangedpublic event TypedEventHandler ThermalStatusChangedPublic Event ThermalStatusChanged

    Remarks

    Media capture scenarios that are extremely processor-intensive, such as high-resolution, high-frame rate, and real-time image processing can cause the capture hardware to overheat. On devices where the camera driver supports reporting of thermal status, you can check the ThermalStatus property to get the current thermal status of the capture device. You can also subscribe to the ThermalStatusChanged event to receive a notification when the thermal status changes. If the thermal status is MediaCaptureThermalStatus , you should stop the current capture session and save any captured media. Once the thermal status has returned to normal, you can begin capturing again.

  • CaptureDeviceExclusiveControlStatusChanged
    CaptureDeviceExclusiveControlStatusChanged
    CaptureDeviceExclusiveControlStatusChanged
    CaptureDeviceExclusiveControlStatusChanged

    Prerelease. Occurs when the exclusive control status of the capture device changes.

    public event TypedEventHandler CaptureDeviceExclusiveControlStatusChangedpublic event TypedEventHandler CaptureDeviceExclusiveControlStatusChangedPublic Event CaptureDeviceExclusiveControlStatusChanged

    Remarks

    When an app has exclusive control of the capture device, it can modify the settings of the device. An app that does not have exclusive control of the capture device can still capture media, but it can't change the capture settings. Request exclusive control by setting the SharingMode property to ExclusiveControl before passing the structure into InitializeAsync(). The call to InitializeAsync will fail if you request exclusive control when another app already has exclusive access to the device. In this case, you can listen for CaptureDeviceExclusiveControlStatusChanged, and if the value of Status is ExclusiveControlAvailable, then you can attempt to reinitialize the MediaCapture with exclusive control.

    If the CaptureDeviceExclusiveControlStatusChanged event is raised and the value of MediaCaptureDeviceExclusiveControlStatusChangedEventArgs.Status is SharedReadOnlyAvailable, then another app has acquired exclusive control of the device. In this case, you may want to update your UI to alert the user that another app may adjust the capture device settings.

Capabilities

webcam
microphone

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute

Details

Assembly

Windows.Media.Capture.dll