win8 metro MediaCapture 類

來源:互聯網
上載者:User

標籤:des   class   blog   code   tar   ext   

最近接觸的項目是有關win8 metro 中camera的項目,其中比較重要的類就是 MediaCapture類,現在介紹一下MediaCapture類,也總結一下自己的一些項目體會:

下面是MediaCapture類的一些方法調用:

using System;using Windows.Foundation;using Windows.Foundation.Collections;using Windows.Foundation.Metadata;using Windows.Media;using Windows.Media.Devices;using Windows.Media.MediaProperties;using Windows.Storage;using Windows.Storage.Streams;namespace Windows.Media.Capture{    // Summary:    //     Provides functionality for capturing photos, audio, and videos from a capture    //     device, such as a webcam.    [Activatable(100794368)]    [DualApiPartition(version = 100794368)]    [MarshalingBehavior(MarshalingType.Standard)]    [Threading(ThreadingModel.MTA)]    [Version(100794368)]    public sealed class MediaCapture : IDisposable    {        //     建立一個MediaCapture對象的執行個體        public MediaCapture();        //返回一個控制microphone設定的對象,AudioDeviceController對象就是控制microphone設定的對象        public AudioDeviceController AudioDeviceController { get; }        //             //MediaCaptureSettings對象包含MediaCapture的設定,這個函數返回MediaCapture對象的設定        public MediaCaptureSettings MediaCaptureSettings { get; }        //            //返回一個對象,這個對象控制video camera的設定,VideoDeviceController就是這個對象        public VideoDeviceController VideoDeviceController { get; }        // Summary:        //  這是MediaCapture類的 Events,當在media 捕獲的時候發生錯誤時發生這個事件        public event MediaCaptureFailedEventHandler Failed;        //        // Summary:        // 這也是MediaCapture類的Events,當超過記錄的限制的時候會觸發這個事件        public event RecordLimitationExceededEventHandler RecordLimitationExceeded;        // Summary:        //     Adds an audio or video effect.        //        // Parameters:        //   mediaStreamType:        //     Specifies the streams to which the effect will be applied.        //        //   effectActivationID:        //     The class identifier of the activatable runtime class that implements the        //     effect. The runtime class must implement the IMediaExtension interface.        //        //   effectSettings:        //     Configuration parameters for the effect.        //        // Returns:        //     Returns an IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction AddEffectAsync(MediaStreamType mediaStreamType, string effectActivationID, IPropertySet effectSettings);        //        // Summary:        //     Captures a photo to a storage file.        //        // Parameters:        //   type:        //     The encoding properties for the output image.        //        //   file:        //     The storage file where the image is saved.        //        // Returns:        //     Returns an IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction CapturePhotoToStorageFileAsync(ImageEncodingProperties type, IStorageFile file);        //        // Summary:        //     Captures a photo to a random-access stream.        //        // Parameters:        //   type:        //     The encoding properties for the output image.        //        //   stream:        //     The stream where the image data is written.        //        // Returns:        //     Returns an IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction CapturePhotoToStreamAsync(ImageEncodingProperties type, IRandomAccessStream stream);        //        // Summary:        //     Removes all audio and video effects from a stream.        //        // Parameters:        //   mediaStreamType:        //     The stream from which to remove the effects.        //        // Returns:        //     Returns a IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction ClearEffectsAsync(MediaStreamType mediaStreamType);        //        // Summary:        //     Performs tasks associated with freeing, releasing, or resetting unmanaged        //     resources.        public void Dispose();        //        // Summary:        //     Gets the value of an encoding property.        //        // Parameters:        //   mediaStreamType:        //     Specifies the stream to query for the encoding property.        //        //   propertyId:        //     The encoding property to retrieve.        //        // Returns:        //     Returns the value of the encoding property.        public object GetEncoderProperty(MediaStreamType mediaStreamType, Guid propertyId);        //        // Summary:        //     Queries whether the video stream is mirrored horizontally.        //        // Returns:        //     True if mirroring is enabled; false otherwise.        public bool GetPreviewMirroring();        //        // Summary:        //     Gets the rotation of the video preview stream.        //        // Returns:        //     The amount by which the video preview stream is rotated.        public VideoRotation GetPreviewRotation();        //        // Summary:        //     Gets the rotation of the recorded video.        //        // Returns:        //     The amount by which the recorded video is rotated.        public VideoRotation GetRecordRotation();        //        // Summary:        //     Initializes the MediaCapture object, using default settings.        //        // Returns:        //     Returns a IAsyncAction object that is used to control the asynchronous operation.        [Overload("InitializeAsync")]        public IAsyncAction InitializeAsync();        //        // Summary:        //     Initializes the MediaCapture object.        //        // Parameters:        //   mediaCaptureInitializationSettings:        //     The initialization settings.        //        // Returns:        //     Returns a IAsyncAction object that is used to control the asynchronous operation.        [Overload("InitializeWithSettingsAsync")]        public IAsyncAction InitializeAsync(MediaCaptureInitializationSettings mediaCaptureInitializationSettings);        //        // Summary:        //     Initializes the low shutter lag photo capture and provides the LowLagPhotoCapture        //     object used to manage the recording.        //        // Parameters:        //   type:        //     The encoding profile used for the image.        //        // Returns:        //     When this method completes, a LowLagPhotoCapture object is returned which        //     can be used to start the photo capture.        public IAsyncOperation<LowLagPhotoCapture> PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties type);        //        // Summary:        //     Initializes the low shutter lag photo sequence capture and provides the LowLagPhotoSequenceCapture        //     object used to manage the recording.        //        // Parameters:        //   type:        //     The encoding profile used for the image.        //        // Returns:        //     When this method completes, a LowLagPhotoSequenceCapture object is returned        //     which can be used to start the photo sequence capture.        public IAsyncOperation<LowLagPhotoSequenceCapture> PrepareLowLagPhotoSequenceCaptureAsync(ImageEncodingProperties type);        //        // Summary:        //     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.        //        // Parameters:        //   encodingProfile:        //     The encoding profile to use for the recording.        //        //   customMediaSink:        //     The media extension for the custom media sink.        //        // Returns:        //     When this method completes, a LowLagMediaRecording object is returned which        //     can be used to start the photo capture.        [Overload("PrepareLowLagRecordToCustomSinkAsync")]        public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink);        //        // Summary:        //     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.        //        // Parameters:        //   encodingProfile:        //     The encoding profile to use for the recording.        //        //   customSinkActivationId:        //     The activatable class ID of the media extension for the custom media sink.        //        //   customSinkSettings:        //     Contains properties of the media extension.        //        // Returns:        //     When this method completes, a LowLagMediaRecording object is returned which        //     can be used to start the photo capture.        [Overload("PrepareLowLagRecordToCustomSinkIdAsync")]        public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, string customSinkActivationId, IPropertySet customSinkSettings);        //        // Summary:        //     Initializes the low lag recording using the specified file to store the recording.        //     This method provides the LowLagMediaRecording object used to managed the        //     recording.        //        // Parameters:        //   encodingProfile:        //     The encoding profile for the recording.        //        //   file:        //     The storage file where the image is saved.        //        // Returns:        //     When this method completes, a LowLagMediaRecording object is returned which        //     can be used to start the photo capture.        public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStorageFileAsync(MediaEncodingProfile encodingProfile, IStorageFile file);        //        // Summary:        //     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.        //        // Parameters:        //   encodingProfile:        //     The encoding profile for the recording.        //        //   stream:        //     The stream where the image data is written.        //        // Returns:        //     When this method completes, a LowLagMediaRecording object is returned which        //     can be used to start the photo capture.        public IAsyncOperation<LowLagMediaRecording> PrepareLowLagRecordToStreamAsync(MediaEncodingProfile encodingProfile, IRandomAccessStream stream);        //        // Summary:        //     Sets an encoding property.        //        // Parameters:        //   mediaStreamType:        //     The type of media data the stream represents, such as video or audio.        //        //   propertyId:        //     The encoding property to set.        //        //   propertyValue:        //     The new value of the encoding property.        public void SetEncoderProperty(MediaStreamType mediaStreamType, Guid propertyId, object propertyValue);        //        // Summary:        //     Asynchronously sets the media encoding properties.        //        // Parameters:        //   mediaStreamType:        //     The type of media data the stream represents, such as video or audio.        //        //   mediaEncodingProperties:        //     The properties for the media encoding.        //        //   encoderProperties:        //     The properties for the encoder.        //        // Returns:        //     Object that is used to control the asynchronous operation.        public IAsyncAction SetEncodingPropertiesAsync(MediaStreamType mediaStreamType, IMediaEncodingProperties mediaEncodingProperties, MediaPropertySet encoderProperties);        //        // Summary:        //     Enables or disables horizontal mirroring of the video preview stream.        //        // Parameters:        //   value:        //     True to enable mirroring; false to disable mirroring.        public void SetPreviewMirroring(bool value);        //        // Summary:        //     Rotates the video preview stream.        //        // Parameters:        //   value:        //     The amount by which to rotate the video.        public void SetPreviewRotation(VideoRotation value);        //        // Summary:        //     Rotates the recorded video.        //        // Parameters:        //   value:        //     The amount by which to rotate the video.        public void SetRecordRotation(VideoRotation value);        //        // Summary:        //     Starts preview.        //        // Returns:        //     Returns a IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction StartPreviewAsync();        //        // Summary:        //     Starts sending a preview stream to a custom media sink using the specified        //     encoding profile.        //        // Parameters:        //   encodingProfile:        //     The encoding profile to use for the recording.        //        //   customMediaSink:        //     The media extension for the custom media sink.        //        // Returns:        //     An object that is used to control the asynchronous operation.        [Overload("StartPreviewToCustomSinkAsync")]        public IAsyncAction StartPreviewToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink);        //        // Summary:        //     Starts sending a preview stream to a custom media sink using the specified        //     encoding profile and sink settings.        //        // Parameters:        //   encodingProfile:        //     The encoding profile to use for the recording.        //        //   customSinkActivationId:        //     The activatable class ID of the media extension for the custom media sink.        //        //   customSinkSettings:        //     Contains properties of the media extension.        //        // Returns:        //     An object that is used to control the asynchronous operation.        [Overload("StartPreviewToCustomSinkIdAsync")]        public IAsyncAction StartPreviewToCustomSinkAsync(MediaEncodingProfile encodingProfile, string customSinkActivationId, IPropertySet customSinkSettings);        //        // Summary:        //     Start recording to a custom media sink using the specified encoding profile.        //        // Parameters:        //   encodingProfile:        //     The encoding profile to use for the recording.        //        //   customMediaSink:        //     The media extension for the custom media sink.        //        // Returns:        //     An object that is used to control the asynchronous operation.        [Overload("StartRecordToCustomSinkAsync")]        public IAsyncAction StartRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, IMediaExtension customMediaSink);        //        // Summary:        //     Start recording to a custom media sink using the specified encoding profile        //     and sink settings.        //        // Parameters:        //   encodingProfile:        //     The encoding profile to use for the recording.        //        //   customSinkActivationId:        //     The activatable class ID of the media extension for the custom media sink.        //        //   customSinkSettings:        //     Contains properties of the media extension.        //        // Returns:        //     Anobject that is used to control the asynchronous operation.        [Overload("StartRecordToCustomSinkIdAsync")]        public IAsyncAction StartRecordToCustomSinkAsync(MediaEncodingProfile encodingProfile, string customSinkActivationId, IPropertySet customSinkSettings);        //        // Summary:        //     Starts recording asynchronously to a storage file.        //        // Parameters:        //   encodingProfile:        //     The encoding profile for the recording.        //        //   file:        //     The storage file where the image is saved.        //        // Returns:        //     Returns a IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction StartRecordToStorageFileAsync(MediaEncodingProfile encodingProfile, IStorageFile file);        //        // Summary:        //     Starts recording to a random-access stream.        //        // Parameters:        //   encodingProfile:        //     The encoding profile for the recording.        //        //   stream:        //     The stream where the image data is written.        //        // Returns:        //     Returns a IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction StartRecordToStreamAsync(MediaEncodingProfile encodingProfile, IRandomAccessStream stream);        //        // Summary:        //     Stops preview.        //        // Returns:        //     Returns a IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction StopPreviewAsync();        //        // Summary:        //     Stops recording.        //        // Returns:        //     Returns a IAsyncAction object that is used to control the asynchronous operation.        public IAsyncAction StopRecordAsync();    }}

MediaCapture類主要利用一些捕獲裝置,例如camera、microphone等,捕獲照片、音頻、視頻等,並提供一些其他功能;

它的命名空間是 using Windows.Media.Capture;


如果要看一些樣本運用,建議可以去win8 官網上面看看,或者我上兩篇博文的執行個體裡面都有一些涉及,謝謝大家,本期就介紹到這裡。




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.