I am working on an windows phone 8.1 application. Work of this app is to record screen activities and store mp4 file in storage. I do not get any compile time error. But
var screenCapture = ScreenCapture.GetForCurrentView();
line returns me UnauthorizedAccessException. I have already added capabilities for Microphone and Webcam to manifest file. I have also tried calling this code in page constructor and from separate class. I am using HTC 8x device with Windows Phone 8.1 OS
Following is my code block :
async private void Button_Tapped(object sender, TappedRoutedEventArgs e)
{
var screenCapture = ScreenCapture.GetForCurrentView();
mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
{
VideoSource = screenCapture.VideoSource,
AudioSource = screenCapture.AudioSource,
});
var file = await KnownFolders.VideosLibrary.CreateFileAsync("screenrecording.mp4", CreationCollisionOption.ReplaceExisting);
await mediaCapture.StartRecordToStorageFileAsync(MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto), file);
//sr.StartRecording();}
I referred this : http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn642093.aspx I have also read this : https://social.msdn.microsoft.com/Forums/sqlserver/en-US/8840d597-34ad-497f-9a5b-ea1cab6057f9/unauthorizedaccessexception-with-windowsmediacapturescreencapturegetforcurrentview?forum=winappswithcsharp
You need to check the capabilities for accessing the video library as well.
Hope this helps!