如何获取录制视频的缩略图 - windows phone 8? [英] How to get the thumbnail of a recorded video - windows phone 8?

查看:30
本文介绍了如何获取录制视频的缩略图 - windows phone 8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 CaptureSource() 录制了本主题中的视频 如何在适用于 Windows Phone 的相机应用程序中录制视频,但我无法获取录制视频的缩略图.

I've used CaptureSource() to record a video like in this Topic How to record video in a camera app for Windows Phone, but I can't get the thumbnail of the recorded video.

推荐答案

解决方案如下:

[...]

// Add eventhandlers for captureSource.
captureSource.CaptureFailed += new EventHandler<ExceptionRoutedEventArgs>(OnCaptureFailed);
captureSource.CaptureImageCompleted += captureSource_CaptureImageCompleted;

[...]

captureSource.Start();
captureSource.CaptureImageAsync();

[...]

void captureSource_CaptureImageCompleted(object sender, CaptureImageCompletedEventArgs e)
{
 using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
  {
    System.Windows.Media.Imaging.WriteableBitmap wb = e.Result;

     string fileName = "CameraMovie.jpg";
     if (isoStore.FileExists(fileName))
         isoStore.DeleteFile(fileName); 

     IsolatedStorageFileStream file = isoStore.CreateFile(fileName);

     System.Windows.Media.Imaging.Extensions.SaveJpeg(wb, file, wb.PixelWidth, wb.PixelHeight, 0, 85);

     file.Close();
 }
}



更新:让用户可以在需要时获取缩略图

viewfinderRectangle

<Rectangle 
    x:Name="viewfinderRectangle"
    [...]
    Tap="viewfinderRectangle_Tap" />

在该 Tap 事件中调用 captureSource.CaptureImageAsync();

Call captureSource.CaptureImageAsync(); in that Tap event

private void viewfinderRectangle_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
 captureSource.CaptureImageAsync();
}

这篇关于如何获取录制视频的缩略图 - windows phone 8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆