How to get the thumbnail of a recorded video - windows phone 8?

后端 未结 2 1725
不思量自难忘°
不思量自难忘° 2020-12-22 04:08

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 rec

2条回答
  •  [愿得一人]
    2020-12-22 04:22

    Here is the solution:

    [...]

    // Add eventhandlers for captureSource.
    captureSource.CaptureFailed += new EventHandler(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();
     }
    }
    



    UPDATE : Give the user the possibility to take the thumbnail when he want

    Add an Tap event to viewfinderRectangle

    
    

    Call captureSource.CaptureImageAsync(); in that Tap event

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

提交回复
热议问题