Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@

<FlexLayout Margin="5" JustifyContent="SpaceBetween" Wrap="Wrap">

<Picker
Title="Cameras"
ItemsSource="{Binding Cameras}"
ItemDisplayBinding="{Binding Name}"
SelectedItem="{Binding SelectedCamera}" />

<Picker
Title="Flash"
IsVisible="{Binding Path=SelectedCamera.IsFlashSupported, FallbackValue=false}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,36 @@ partial void OnSelectedResolutionChanged(Size value)
UpdateResolutionText();
}

partial void OnSelectedCameraChanged(CameraInfo? oldValue, CameraInfo? newValue)
{
UpdateCameraInfoText();
}

void UpdateCameraInfoText()
{
if (SelectedCamera is null)
{
CameraNameText = string.Empty;
ZoomRangeText = string.Empty;
}
else
{
CameraNameText = $"{SelectedCamera.Name}";
ZoomRangeText = $"Min Zoom: {SelectedCamera.MinimumZoomFactor}, Max Zoom: {SelectedCamera.MaximumZoomFactor}";
UpdateFlashModeText();
}
}

void UpdateFlashModeText()
{
if (SelectedCamera is null)
{
return;
FlashModeText = string.Empty;
}
else
{
FlashModeText = $"{(SelectedCamera.IsFlashSupported ? $"Flash mode: {FlashMode}" : "Flash not supported")}";
}
FlashModeText = $"{(SelectedCamera.IsFlashSupported ? $"Flash mode: {FlashMode}" : "Flash not supported")}";
}

void UpdateCurrentZoomText()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public async partial ValueTask RefreshAvailableCameras(CancellationToken token)
var deviceInfoCollection = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture).AsTask(token);
var mediaFrameSourceGroup = await MediaFrameSourceGroup.FindAllAsync().AsTask(token);
var videoCaptureSourceGroup = mediaFrameSourceGroup.Where(sourceGroup => deviceInfoCollection.Any(deviceInfo => deviceInfo.Id == sourceGroup.Id)).ToList();
var mediaCapture = new MediaCapture();

var availableCameras = new List<CameraInfo>();

foreach (var sourceGroup in videoCaptureSourceGroup)
{
using var mediaCapture = new MediaCapture();
await mediaCapture.InitializeCameraForCameraView(sourceGroup.Id, token);

CameraPosition position = CameraPosition.Unknown;
Expand Down
Loading