示例#1
0
        public async Task <MediaCapture> InitAsync(string videoDeviceId, string audioDeviceId = null)
        {
            // Prevent the screen from sleeping
            DisplayRequest.RequestActive();

            if (DefaultManager != null)
            {
                var current = DefaultManager.MediaCaptureSettings.VideoDeviceId?.ToLower();
                if (current.Equals(videoDeviceId))
                {
                    return(DefaultManager);
                }
            }

            try
            {
                await StopEverythingAsync();
            }
            catch { }

            DefaultManager = new MediaCapture();
            DefaultManager.RecordLimitationExceeded += DefaultManager_RecordLimitationExceeded;
            var settings = new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Video,
            };

            if (videoDeviceId != null)
            {
                settings.VideoDeviceId = videoDeviceId;
            }
            if (audioDeviceId != null)
            {
                settings.AudioDeviceId = audioDeviceId;
            }

            await DefaultManager.InitializeAsync(settings);

            Face = new FaceLogic(DefaultManager);
            Face.FaceDetected += Face_FaceDetected;
            await Face.InitAsync();

            Preview = new PreviewLogic(DefaultManager, Face);
            Photo   = new PhotoLogic(DefaultManager);
            Video   = new VideoLogic(DefaultManager);

            return(DefaultManager);
        }
示例#2
0
 public PreviewLogic(MediaCapture defaultManager, FaceLogic face)
 {
     this.defaultManager = defaultManager;
     this.faceLogic      = face;
 }