From 638936eac3f14722f5f119a05969a955fe902f2e Mon Sep 17 00:00:00 2001 From: David Ortinau Date: Mon, 18 Aug 2025 12:32:51 -0500 Subject: [PATCH] MediaPicker (.NET 10): add multi-select docs with PickPhotosAsync/PickVideosAsync, examples, and platform notes; moniker split maintained --- .../device-media/picker.md | 80 +++++++++++++++++-- 1 file changed, 74 insertions(+), 6 deletions(-) diff --git a/docs/platform-integration/device-media/picker.md b/docs/platform-integration/device-media/picker.md index c0a04eade..8fcbeedc3 100644 --- a/docs/platform-integration/device-media/picker.md +++ b/docs/platform-integration/device-media/picker.md @@ -99,21 +99,89 @@ No setup is required. ## Using media picker -The interface has the following methods that all return a , which can be used to get the file's location or read it. +::: moniker range="<=net-maui-9.0" -- \ +The interface has the following methods that return a , which can be used to get the file's location or read it. + +- \ Opens the media browser to select a photo. -- \ +- \ Opens the camera to take a photo. -- \ +- \ Opens the media browser to select a video. -- \ +- \ +Opens the camera to take a video. + +Each method optionally takes a parameter that allows the to be set on some operating systems, which is displayed to the user. + +::: moniker-end + +::: moniker range=">=net-maui-10.0" + +In .NET 10, the media picker adds multi-select support and new processing options. Use the following methods: + +- (returns `List`) \ +Opens the media browser to select one or more photos. + +- (returns `FileResult?`) \ +Opens the camera to take a photo. + +- (returns `List`) \ +Opens the media browser to select one or more videos. + +- (returns `FileResult?`) \ Opens the camera to take a video. -Each method optionally takes in a parameter type that allows the to be set on some operating systems, which is displayed to the user. +The parameter exposes additional fields such as , , , , , and . + +> [!IMPORTANT] +> When the user cancels a multi-select operation, the returned list is empty. On Android, some picker UIs may not enforce ; on Windows, `SelectionLimit` isn't supported. Implement your own logic to enforce limits or notify the user on these platforms. + +### Pick multiple photos + +```csharp +var results = await MediaPicker.PickPhotosAsync(new MediaPickerOptions +{ + // Default is 1; set to 0 for no limit + SelectionLimit = 10, + // Optional processing for images + MaximumWidth = 1024, + MaximumHeight = 768, + CompressionQuality = 85, + RotateImage = true, + PreserveMetaData = true, +}); + +foreach (var file in results) +{ + using var stream = await file.OpenReadAsync(); + // Process the stream +} +``` + +### Pick multiple videos + +```csharp +var results = await MediaPicker.PickVideosAsync(new MediaPickerOptions +{ + SelectionLimit = 3, + Title = "Select up to 3 videos", +}); + +foreach (var file in results) +{ + using var stream = await file.OpenReadAsync(); + // Process the stream +} +``` + +> [!TIP] +> For single selection, prefer `PickPhotosAsync`/`PickVideosAsync` as well. Set `SelectionLimit = 1` (the default) and read the first item if present. + +::: moniker-end > [!IMPORTANT] > All methods must be called on the UI thread because permission checks and requests are automatically handled by .NET MAUI.