1
有時我越來越黑屏,同時從我的Windows Phone 8應用程序錄制視頻。請你幫助我,以避免黑屏。 這裏我正在運行一個計時器來顯示視頻的時間。即使我刪除計時器也是我得到了黑屏。如何避免在視頻窗口時背屏幕電話8應用程序
public void InitializeVideoRecorder()
{
if (captureSource == null)
{
// Create the VideoRecorder objects.
captureSource = new CaptureSource();
fileSink = new FileSink();
videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
int videoformatcount = videoCaptureDevice.SupportedFormats.Count(); //We will get the avilable video format
if (videoformatcount > 0)
{
var Temp = videoCaptureDevice.SupportedFormats;
VideoFormat objVideoFormat = Temp[videoformatcount - 1];
videoCaptureDevice.DesiredFormat = new VideoFormat(PixelFormatType.Format8bppGrayscale, objVideoFormat.PixelWidth, objVideoFormat.PixelHeight, 1);
}
captureSource.VideoCaptureDevice = videoCaptureDevice;
// Add eventhandlers for captureSource.
captureSource.CaptureFailed += new EventHandler<ExceptionRoutedEventArgs>(OnCaptureFailed);
captureSource.CaptureImageCompleted += captureSource_CaptureImageCompleted;
// Initialize the camera if it exists on the device.
if (videoCaptureDevice != null)
{
// Create the VideoBrush for the viewfinder.
videoRecorderBrush = new VideoBrush();
videoRecorderBrush.SetSource(captureSource);
// Display the viewfinder image on the rectangle.
viewfinderRectangle.Fill = videoRecorderBrush;
// Start video capture and display it on the viewfinder.
captureSource.Start();
// Set the button state and the message.
UpdateUI(ButtonState.Initialized, "Tap record to start recording...");
}
else
{
// Disable buttons when the camera is not supported by the device.
UpdateUI(ButtonState.CameraNotSupported, "Camera is not supported on this device.");
}
}
}
private void StartVideoRecording()
{
try
{
// Connect fileSink to captureSource.
if (captureSource.VideoCaptureDevice != null && captureSource.State == CaptureState.Started)
{
captureSource.Stop();
// Connect the input and output of fileSink.
fileSink.CaptureSource = captureSource;
//if (isoVideoFileName == "" || isoVideoFileName == null)
isoVideoFileName = rdIMEI + "_" + DeviceIDAsString + "_" + DateTime.Now.ToFileTime().ToString() + ".mp4";
fileSink.IsolatedStorageFileName = isoVideoFileName;
}
// Begin recording.
if (captureSource.VideoCaptureDevice != null && captureSource.State == CaptureState.Stopped)
{
// captureSource.CaptureFailed += captureSource_CaptureFailed;
captureSource.Start();
captureSource.CaptureImageAsync();
}
// Set the button states and the message.
UpdateUI(ButtonState.Recording, "Recording...");
}
// If recording fails, display an error.
catch (Exception e)
{
this.Dispatcher.BeginInvoke(delegate()
{
//txtDebug.Text = "ERROR: " + e.Message.ToString();
});
}
}
它正在工作..非常感謝.. ..! – user3056216 2014-11-06 10:01:20