/// <summary>
        /// CameraPreviewCaptureのファクトリメソッド
        /// </summary>
        /// <param name="onCreatedCallback"></param>
        public static async Task CreateAync(CaptureObjectCreatedCallback onCreatedCallback)
        {
            // カメラプレビューが可能なRGBカメラを含むMediaFrameSourceGroupの一覧を取得する
            var allFrameSourceGroups = await MediaFrameSourceGroup.FindAllAsync();                                              //Returns IReadOnlyList<MediaFrameSourceGroup>

            var candidateFrameSourceGroups = allFrameSourceGroups.Where(group =>
                                                                        group.SourceInfos.Any(sourceInfo =>
                                                                                              sourceInfo.MediaStreamType == MediaStreamType.VideoPreview &&
                                                                                              sourceInfo.SourceKind == MediaFrameSourceKind.Color
                                                                                              )
                                                                        );
            // 取得した一覧から先頭のMediaFrameSourceGroupを取得する
            var selectedFrameSourceGroup = candidateFrameSourceGroups.FirstOrDefault();

            if (selectedFrameSourceGroup == null)
            {
                onCreatedCallback?.Invoke(null);
                return;
            }
            // カメラプレビューが可能なRGBカメラのMediaFrameSourceInfoを取得
            var selectedFrameSourceInfo = selectedFrameSourceGroup.SourceInfos
                                          .Where(sourceInfo =>
                                                 sourceInfo.SourceKind == MediaFrameSourceKind.Color &&
                                                 sourceInfo.MediaStreamType == MediaStreamType.VideoPreview)
                                          .FirstOrDefault();

            if (selectedFrameSourceInfo == null)
            {
                onCreatedCallback?.Invoke(null);
                return;
            }
            // MediaFrameSourceのDeviceInformationを取得する
            var deviceInformation = selectedFrameSourceInfo.DeviceInformation;

            // devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);   //Returns DeviceCollection
            // deviceInformation = devices.FirstOrDefault();                               //Returns a single DeviceInformation

            if (deviceInformation == null)
            {
                onCreatedCallback?.Invoke(null);
                return;
            }
            // インスタンス化
            var videoCapture = new CameraPreviewCapture(selectedFrameSourceInfo);
            // MediaCaptureのインスタンスを作成
            var result = await videoCapture.CreateMediaCaptureAsync(selectedFrameSourceGroup, deviceInformation);

            if (result)
            {
                // インスタンスをコールバックに渡す
                onCreatedCallback?.Invoke(videoCapture);
            }
            else
            {
                onCreatedCallback?.Invoke(null);
            }
        }
Пример #2
0
 public async static Task CreateAync(CaptureObjectCreatedCallback onCreatedCallback)
 {
     throw new NotImplementedException();
 }