Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In Windows Phone 7.0 it wasn't possible using the "official" SDK to access the camera other than using <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.tasks.cameracapturetask%28v=vs.105%29.aspx" rel="nofollow noreferrer">CameraCaptureTask</a>. But using <code>Microsoft.Phone.InteropServices</code> library it was possible to create a custom camera view in the application. If you used this <code>VideoCamera</code> class, it had an event called <code>ThumbnailSavedToDisk</code>, which might be what you have heard about. But apps using <code>Microsoft.Phone.InteropServices</code> was never allowed in the Windows Phone Marketplace. You can read more <a href="http://dotnet.dzone.com/articles/how-videocameracamera-content" rel="nofollow noreferrer">about it here</a>.</p> <hr> <p>To generate a thumbnail from a video file one solution would be to read up on how the MP4 file format works and extract one of the frames and use that as a thumbnail. Unfortunatly I haven't found any libraries that can do this.</p> <p>Another, but far from optimal solution, would be to play the video in a MediaElement and then render that Control to a bitmap. This can be done with the following code (written in XAML/C#, I don't know VB.net, but should be easy to port):</p> <pre class="lang-xml prettyprint-override"><code>&lt;MediaElement x:Name="VideoPlayer" Width="640" Height="480" AutoPlay="True" RenderTransformOrigin="0.5, 0.5" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Fill" Canvas.Left="80"/&gt; </code></pre> <p>And then to create the thumbnail:</p> <pre><code>// Set an event handler for when video has loaded VideoPlayer.MediaOpened += VideoPlayer_MediaOpened; // Read video from storage IsolatedStorageFileStream videoFile = new IsolatedStorageFileStream("MyVideo.mp4", FileMode.Open, FileAccess.Read, IsolatedStorageFile.GetUserStoreForApplication()); VideoPlayer.SetSource(videoFile); // Start playback VideoPlayer.Play(); </code></pre> <p>And then create the event handler which "captures" the thumbnail:</p> <pre><code>void VideoPlayer_MediaOpened(object sender, RoutedEventArgs e) { Thread.Sleep(100); // Wait for a short time to avoid black frame WriteableBitmap wb = new WriteableBitmap(VideoPlayer, new TranslateTransform()); thumbnailImageHolder.Source = wb; // Setting it to a Image in the XAML code to see it VideoPlayer.Stop(); } </code></pre> <p>Here is how it looks when using a modified version of the <a href="http://code.msdn.microsoft.com/wpapps/Video-Recorder-Sample-5e800bbf" rel="nofollow noreferrer">Video Recorder Sample</a>. (The small image with the blue border in the upper right corner is the thumbnail of the recorded video. Behind is the camera Viewer.)</p> <p><img src="https://i.stack.imgur.com/lpz8n.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload