c# - Access camera preview-stream on Windows Phone 8.1 -
c# - Access camera preview-stream on Windows Phone 8.1 -
i'm trying create basic photographic camera application (for first application targeted towards wp). , want to, of course, preview photographic camera info screen before taking shot.
but samples see online msdn etc old (many objects have been removed, ie libraries beingness updated making articles obsolete)
i'm having problem getting started preview-stream. appreciated if knowledge give me help in matter.
thank you.
i suggest using captureelement control
on xaml add together this:
<captureelement x:name="capture" stretch="uniformtofill" flowdirection="lefttoright" />
i don't know if want utilize front end or webcam i'll show code both.
in codebehind (or viewmodel if using mvvm) add together code:
// first need find webcams deviceinformationcollection webcamlist = await deviceinformation.findallasync(deviceclass.videocapture) // query find front end webcam deviceinformation frontwebcam = (from webcam in webcamlist webcam.enclosurelocation != null && webcam.enclosurelocation.panel == windows.devices.enumeration.panel.front select webcam).firstordefault(); // same webcam deviceinformation backwebcam = (from webcam in webcamlist webcam.enclosurelocation != null && webcam.enclosurelocation.panel == windows.devices.enumeration.panel.back select webcam).firstordefault(); // need initialize mediacapture var newcapture = new mediacapture(); await newcapture.initializeasync(new mediacaptureinitializationsettings { // take webcam want (backwebcam or frontwebcam) videodeviceid = backwebcam.id, audiodeviceid = "", streamingcapturemode = streamingcapturemode.video, photocapturesource = photocapturesource.videopreview }); // set source of captureelement mediacapture capture.source = newcapture; // start preview await newcapture.startpreviewasync();
this show stream of chosen webcam in captureelement control, , works on both windows phone 8.1 , windows 8.1
c# wpf windows-phone-8.1
Comments
Post a Comment