File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 6161
6262 <FlexLayout Margin =" 5" JustifyContent =" SpaceBetween" Wrap =" Wrap" >
6363
64+ <Picker
65+ Title =" Cameras"
66+ ItemsSource =" {Binding Cameras}"
67+ ItemDisplayBinding =" {Binding Name}"
68+ SelectedItem =" {Binding SelectedCamera}" />
69+
6470 <Picker
6571 Title =" Flash"
6672 IsVisible =" {Binding Path=SelectedCamera.IsFlashSupported, FallbackValue=false}"
Original file line number Diff line number Diff line change @@ -66,13 +66,36 @@ partial void OnSelectedResolutionChanged(Size value)
6666 UpdateResolutionText ( ) ;
6767 }
6868
69+ partial void OnSelectedCameraChanged ( CameraInfo ? oldValue , CameraInfo ? newValue )
70+ {
71+ UpdateCameraInfoText ( ) ;
72+ }
73+
74+ void UpdateCameraInfoText ( )
75+ {
76+ if ( SelectedCamera is null )
77+ {
78+ CameraNameText = string . Empty ;
79+ ZoomRangeText = string . Empty ;
80+ }
81+ else
82+ {
83+ CameraNameText = $ "{ SelectedCamera . Name } ";
84+ ZoomRangeText = $ "Min Zoom: { SelectedCamera . MinimumZoomFactor } , Max Zoom: { SelectedCamera . MaximumZoomFactor } ";
85+ UpdateFlashModeText ( ) ;
86+ }
87+ }
88+
6989 void UpdateFlashModeText ( )
7090 {
7191 if ( SelectedCamera is null )
7292 {
73- return ;
93+ FlashModeText = string . Empty ;
94+ }
95+ else
96+ {
97+ FlashModeText = $ "{ ( SelectedCamera . IsFlashSupported ? $ "Flash mode: { FlashMode } " : "Flash not supported" ) } ";
7498 }
75- FlashModeText = $ "{ ( SelectedCamera . IsFlashSupported ? $ "Flash mode: { FlashMode } " : "Flash not supported" ) } ";
7699 }
77100
78101 void UpdateCurrentZoomText ( )
Original file line number Diff line number Diff line change @@ -14,12 +14,12 @@ public async partial ValueTask RefreshAvailableCameras(CancellationToken token)
1414 var deviceInfoCollection = await DeviceInformation . FindAllAsync ( DeviceClass . VideoCapture ) . AsTask ( token ) ;
1515 var mediaFrameSourceGroup = await MediaFrameSourceGroup . FindAllAsync ( ) . AsTask ( token ) ;
1616 var videoCaptureSourceGroup = mediaFrameSourceGroup . Where ( sourceGroup => deviceInfoCollection . Any ( deviceInfo => deviceInfo . Id == sourceGroup . Id ) ) . ToList ( ) ;
17- var mediaCapture = new MediaCapture ( ) ;
1817
1918 var availableCameras = new List < CameraInfo > ( ) ;
2019
2120 foreach ( var sourceGroup in videoCaptureSourceGroup )
2221 {
22+ using var mediaCapture = new MediaCapture ( ) ;
2323 await mediaCapture . InitializeCameraForCameraView ( sourceGroup . Id , token ) ;
2424
2525 CameraPosition position = CameraPosition . Unknown ;
You can’t perform that action at this time.
0 commit comments