Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class MainPage : PhoneApplicationPage
- {
- private const CameraSensorLocation SENSOR_LOCATION = CameraSensorLocation.Back;
- private AudioVideoCaptureDevice _videoDevice = null;
- // ... ctor and camInitialization methods etc.
- private async void CameraButtons_ShutterKeyPressed(object sender, EventArgs e)
- {
- try{
- StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("videos", CreationCollisionOption.ReplaceExisting);
- StorageFile storageFile = await folder.CreateFileAsync("Video.mp4", CreationCollisionOption.GenerateUniqueName);
- using (var s = await storageFile.OpenAsync(FileAccessMode.ReadWrite))
- {
- _videoDevice.VideoEncodingFormat = CameraCaptureVideoFormat.H264;
- await _videoDevice.StartRecordingToStreamAsync(s);
- Thread.Sleep(3000);
- // I want the following 3 lines to be executed when I press the button again
- await _videoDevice.StopRecordingAsync();
- await s.FlushAsync();
- s.AsStream().Dispose();
- }
- } catch(Exception ex){
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement