win8 metro MediaCapture 类

最近接触的项目是有关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 官网上面看看,或者我上两篇博文的实例里面都有一些涉及,谢谢大家,本期就介绍到这里。

win8 metro MediaCapture 类

时间: 2024-10-27 00:01:44

win8 metro MediaCapture 类的相关文章

win8 metro 调用摄像头拍摄照片并将照片保存在相应的位置

刚刚做过这类开发,所以就先献丑了,当然所贴上的源码都是经过验证过的,已经运行成功了,希望可以给大家一些借鉴: 下面是metro UI代码: <Page x:Class="Camera.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

win8 metro 自己写摄像头拍照项目

这个项目不是用的系统自带的CameraCaptureUI,是自己写的摄像头的调用,界面做的不好所以,不放了,但是可以实现拍照功能: 下面是using 程序命名空间: using Windows.Media.Capture; using Windows.Media.MediaProperties; using Windows.UI.Xaml.Media.Imaging; using Windows.Storage; using Windows.Storage.Pickers; using Wind

Win8 Metro动态加载内容框架

制作背景 为了参加ImagineCup 2013 世界公民类比赛,我们设计制作了一个可动态扩展的幼教类App.这个App需要能动态加载内容,内容包括带动画可交互的电子书,动画,视频,游戏. 技术支持 2012年10月第一次:因为SVG性能问题,将SVG换为cocos2d-x JSBind,可惜cocos2d-x JSBind不完善,最后换为cocos2d-x html5.11月第二次:cocos2d-x html5性能问题,破产.12月第三次:取消HTML5,转为使用XAML+JS模式. (微软

Win8 Metro风格的Web桌面HteOS

Checkbox类: 1.实现checkbox的全选功能 <script type="text/javascript"> //全选checkbox:1.当全选checkbox勾选,子checkbox(name为'ids'的checkbox)自动全部勾选 // 2.当全选checkbox取消勾选,子checkbox自动全部取消勾选 function checkAll(){ if($("#checkall")[0].checked){ $("inp

win8 metro 调用摄像头录制视频并将视频保存在相应的位置

上一篇文章介绍了在win8 metro 调用摄像头拍摄照片并将照片保存在相应的位置的功能,那么这一片文章主要介绍了的就是录制视频了,其实这个差不多,所用的思想也是一样的,因为图片和视频都可以转化为流文件,那么它们本质上都是一样的,但是还是有个别地方时不同的,接下来我们就介绍一下这个别地方的不同吧 下面是metro UI的代码: <Page x:Class="Camera1.MainPage" xmlns="http://schemas.microsoft.com/win

HteOS - Win8 Metro UI 风格的Web桌面

HteOS是一款Win8 Metro UI风格的Web桌面应用开发框架 现代的.简约的界面,丰富的组件.功能,全新的Web桌面 全新的Web桌面应用开发框架 全新设计 全新的Web桌面设计,告别古板与生硬 Win8 Metro风格界面,动态磁贴灵动轻巧 二次开发 应用场景广泛,能够适用各种项目兼容IE8+浏览器,快速进行二次开发 应用部署 没有环境限制,可以在任何平台进行部署不需要进行额外的部署设置,即插即用 不拘泥于平庸的Web桌面设计 卡片布局 Metro风格的卡片布局,不再是审美疲劳的树状

开发win8 metro monogame,显示pubcenter广告时会使游戏卡住的问题的解决方法。

开发win8 metro游戏,使用monogame,并且还加上pubcenter广告,但是在x64的机子上遇到了问题,广告一出,游戏卡死.经过一系列的判断,发现monogame一直在update和draw,没有停止工作,但是我们看到的画面一直定格在广告出来的那一刻.既然是在广告出来的时候死的,那我们就把广告停了再开试试,在广告的AdRefreshed事件中添加这两行代码 MyAd.Suspend();            MyAd.Resume(); 测试后发现广告不会卡游戏了.

Win8 Metro(C#)数字图像处理--2.56简单统计法图像二值化

原文:Win8 Metro(C#)数字图像处理--2.56简单统计法图像二值化  [函数名称] 简单统计法图像二值化 WriteableBitmap StatisticalThSegment(WriteableBitmap src) /// <summary> /// Statistical method of image segmention. /// </summary> /// <param name="src">The source im

Win8 Metro(C#)数字图像处理--2.52图像K均值聚类

原文:Win8 Metro(C#)数字图像处理--2.52图像K均值聚类 ?? [函数名称] ??图像KMeans聚类??????KMeansCluster(WriteableBitmap?src,int?k) /// <summary> /// KMeans Cluster process. /// </summary> /// <param name="src">The source image.</param> /// <pa