Answered by:
preview video

Question
-
i want to preview video in windows phone silverlight 8.1 app.is it possible?Tuesday, August 25, 2015 2:36 PM
Answers
-
Hi zyRBuqiB,
Do you mean you want to preview video from the capture device? Please try with MediaCapturePreviewSink as following code. More information about MediaCapturePreviewSink, please read below article.
https://msdn.microsoft.com/en-us/library/windows/apps/dn655126(v=vs.105).aspx
private async void StartPreview() { // Initialize the MediaCapture and MediaCapturePreviewSink objects mediaCaptureManager = new Windows.Media.Capture.MediaCapture(); await mediaCaptureManager.InitializeAsync(); previewSink = new Windows.Phone.Media.Capture.MediaCapturePreviewSink(); // List of supported video preview formats to be used by the default preview format selector. var supportedVideoFormats = new List<string> { "nv12", "rgb32" }; // Find the supported preview format var availableMediaStreamProperties = mediaCaptureManager.VideoDeviceController.GetAvailableMediaStreamProperties( Windows.Media.Capture.MediaStreamType.VideoPreview) .OfType<Windows.Media.MediaProperties.VideoEncodingProperties>() .Where(p => p != null && !String.IsNullOrEmpty(p.Subtype) && supportedVideoFormats.Contains(p.Subtype.ToLower())) .ToList(); var previewFormat = availableMediaStreamProperties.FirstOrDefault(); // Start Preview stream await mediaCaptureManager.VideoDeviceController.SetMediaStreamPropertiesAsync( Windows.Media.Capture.MediaStreamType.VideoPreview, previewFormat); await mediaCaptureManager.StartPreviewToCustomSinkAsync( new Windows.Media.MediaProperties.MediaEncodingProfile { Video = previewFormat }, previewSink); // Set the source of the VideoBrush used for your preview Microsoft.Devices.CameraVideoBrushExtensions.SetSource(viewfinderBrush, previewSink); }
If misunderstanding, please feel free to let me know.Best Regards,
Weiwei- Marked as answer by zyRBuqiB Thursday, August 27, 2015 12:11 PM
Wednesday, August 26, 2015 2:42 AMModerator
All replies
-
You could make a teeny version of a specific video and play that, call it a preview.
They download that and play it.
If they decide to play the full thing they the download that file.
Dowloading a small file would of course be quicker.
Or you could play the video in a small sized version of the medialement control.
Otherwise, not so much.
Tuesday, August 25, 2015 4:39 PM -
Hi zyRBuqiB,
Do you mean you want to preview video from the capture device? Please try with MediaCapturePreviewSink as following code. More information about MediaCapturePreviewSink, please read below article.
https://msdn.microsoft.com/en-us/library/windows/apps/dn655126(v=vs.105).aspx
private async void StartPreview() { // Initialize the MediaCapture and MediaCapturePreviewSink objects mediaCaptureManager = new Windows.Media.Capture.MediaCapture(); await mediaCaptureManager.InitializeAsync(); previewSink = new Windows.Phone.Media.Capture.MediaCapturePreviewSink(); // List of supported video preview formats to be used by the default preview format selector. var supportedVideoFormats = new List<string> { "nv12", "rgb32" }; // Find the supported preview format var availableMediaStreamProperties = mediaCaptureManager.VideoDeviceController.GetAvailableMediaStreamProperties( Windows.Media.Capture.MediaStreamType.VideoPreview) .OfType<Windows.Media.MediaProperties.VideoEncodingProperties>() .Where(p => p != null && !String.IsNullOrEmpty(p.Subtype) && supportedVideoFormats.Contains(p.Subtype.ToLower())) .ToList(); var previewFormat = availableMediaStreamProperties.FirstOrDefault(); // Start Preview stream await mediaCaptureManager.VideoDeviceController.SetMediaStreamPropertiesAsync( Windows.Media.Capture.MediaStreamType.VideoPreview, previewFormat); await mediaCaptureManager.StartPreviewToCustomSinkAsync( new Windows.Media.MediaProperties.MediaEncodingProfile { Video = previewFormat }, previewSink); // Set the source of the VideoBrush used for your preview Microsoft.Devices.CameraVideoBrushExtensions.SetSource(viewfinderBrush, previewSink); }
If misunderstanding, please feel free to let me know.Best Regards,
Weiwei- Marked as answer by zyRBuqiB Thursday, August 27, 2015 12:11 PM
Wednesday, August 26, 2015 2:42 AMModerator -
Hi Weiwei,
Thank you, it works for me.
Thursday, August 27, 2015 12:12 PM