Windows Phone 8.1 Multi Media (2): Video

Source: Internet
Author: User

Original: Windows Phone 8.1 Multi Media (2): Video

Windows Phone 8.1 Multi Media (1): Photos

Windows Phone 8.1 Multi Media (2): Video

Windows Phone 8.1 Multi Media (3): Music

(1) Shooting video

The way to take a video and take a photo is basically the same:

MediaCapture MediaCapture; mediaencodingprofile videoencodingproperties; protected Override Async voidonnavigatedto (NavigationEventArgs e) {hardwarebuttons.camerahalfpressed+=hardwarebuttons_camerahalfpressed; Hardwarebuttons.camerareleased+=hardwarebuttons_camerareleased; Videocaptrueelement.source=awaitInitialize (); awaitMediacapture.startpreviewasync ();}Async voidHardwarebuttons_camerahalfpressed (Objectsender, Cameraeventargs e) {    if(MediaCapture! =NULL )    {         var video = await KnownFolders.VideosLibrary.CreateFileAsync ("video.mp4 " , creationcollisionoption.generateuniquename);  await Mediacapture.startrecordtostoragefileasync (videoencodingproperties, video);  }}Async voidHardwarebuttons_camerareleased (Objectsender, Cameraeventargs e) {    if(MediaCapture! =NULL )    {        await Mediacapture.stoprecordasync (); }}Private AsyncTask<mediacapture>Initialize () {mediaCapture=NewMediaCapture (); awaitMediacapture.initializeasync (); MediaCapture.VideoDeviceController.PrimaryUse = Captureuse.video; Videoencodingproperties=Mediaencodingprofile.createmp4 (VIDEOENCODINGQUALITY.VGA); returnmediaCapture;}protected Override voidOnnavigatedfrom (NavigationEventArgs e) {if(MediaCapture! =NULL) {mediacapture.dispose (); MediaCapture=NULL; }}

(2) Edit video

The video editing API is available under the Windows.Media.Editing namespace and is specific to MSDN: links

Simply put some video into Mediaclip, then add these videos to mediacomposition.clips and finally stitch them together or add a backgroundaudiotrack or something:

Mediaclip video =awaitMediaclip.createfromfileasync (
awaitStoragefile.getfilefromapplicationuriasync (NewUri ("Ms-appx:///thanks.mp4"))); Mediacomposition Videos=Newmediacomposition (); videos. Clips.add (video); Backgroundaudiotrack BGM=awaitBackgroundaudiotrack.createfromfileasync (
awaitStoragefile.getfilefromapplicationuriasync (NewUri ("Above Your Hand.mp3")) ; videos. Backgroundaudiotracks.clear (); videos. Backgroundaudiotracks.add (BGM);awaitVideos. Saveasync (awaitApplicationData.Current.LocalFolder.CreateFileAsync ("Video.mp4", creationcollisionoption.replaceexisting));

(3) Record phone screen video

Recording Phone screen video is WP8.1 's new API, using the same method as shooting video, just set the recording object to the screen:

varScreencapture = Screencapture.getforcurrentview (); MediaCapture=NewMediaCapture (); await Mediacapture.initializeasync (new  mediacaptureinitializationsettings{VideoSource = Screencapture.videosource, audiosource = Screencapture.audiosource,}); varFile =awaitKnownFolders.VideosLibrary.CreateFileAsync ("Screenrecording.mp4", creationcollisionoption.replaceexisting);awaitMediacapture.startrecordtostoragefileasync (Mediaencodingprofile.createmp4 (videoencodingquality.auto), file);

To stop recording:

if NULL ) {    await  mediacapture.stoprecordasync ();    Mediacapture.dispose ();     NULL ;}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.