The static CreateMp4 method creates an MP4 encoding profile. The parameter to this method gives the target resolution for the video. In this case, VideoEncodingQuality.HD720p means 1280 x 720 pixels at 30 frames per second. ("720p" stands for 720 progressive scan lines per frame.) The other methods for creating predefined profiles all follow this pattern.

Cleaning up MediaCapture resources properly

Warning

It is extremely important that you properly shut down and dispose of the MediaCapture object and related objects when your app is suspended. Failure to do so could interfere with other apps accessing the device's camera which will result in a negative user experience for your app.

On Windows Phone, clean up your MediaCapture resources in the handler for the oncheckpoint app lifetime event. On Windows, use the SoundLevelChanged events and check if sound level was muted. If it was muted, then clean up the MediaCapture resources. If the event indicates any other sound level, use the event to recreate them. Note that this event will not trigger your code even if you manually mute/unmute the sound while the app is running. So, this event effectively serves the same purpose as Suspend and Resume on phone. This is necessary because, on Windows, the user may be able to switch between apps without the current app being suspended.

You should cleanup media capture resources in the oncheckpoint event on Windows Phone or the SoundLevelChanged on Windows, as explained in the guidance in the above note. A good way to do this is to declare some variables to store the MediaCapture object and booleans that indicate whether the app is currently recording or previewing video. Then, create a function that stops recording or previewing if they are in progress, calls the close method of the MediaCapture object and sets it to null. The following code shows an example implementation of this method.

Finally, add the following code to your oncheckpoint event handler. It is very important that you use a promise to call your cleanup method. This ensures that the system lets the method complete before suspending your app.