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 ;}