Display Current Video in Windows Phone 8 using Aud

2019-07-20 19:02发布

问题:

I've managed to setup code for a Windows Phone 8 Application that initializes and can start/stop recording video using an AudioVideoCaptureDevice. (saves it to an IRandomAccessStream)

//Initialize Camera Recording
Windows.Foundation.Size resolution = new Windows.Foundation.Size(640, 480);
captureDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, resolution);
captureDevice.VideoEncodingFormat = CameraCaptureVideoFormat.H264;
captureDevice.AudioEncodingFormat = CameraCaptureAudioFormat.Aac;
captureDevice.RecordingFailed += captureDevice_RecordingFailed;

However, I cannot figure out how to hook this recording up to a VideoBrush to display the recording to the user. I want the user to be able to see the video they are recording as it is happening...

I know there is a tutorial that shows how to do this using the old APIs for Windows Phone 7 (CaptureSource, VideoDevice, etc.) but I specifically need to use the AudioVideoCaptureDevice to record. Anyone know how to display this video on screen?

回答1:

Well, I was able to solve my problem.

Apparently there is a library in Microsoft.Devices that contains extensions for the VideoBrush class. Therefore, in order to set the videobrush source to an AudioVideoCaptureDevice, you must first have:

using Microsoft.Devices;

at the top of your class in which your using the videobrush. Hope this is able to help someone else.



回答2:

You should be able to simply use VideoBrush.SetSource(captureDevice).