diff --git a/src/MediaAccessibility/MediaAccessibility.cs b/src/MediaAccessibility/MediaAccessibility.cs
index 054930908f62..449e99921397 100644
--- a/src/MediaAccessibility/MediaAccessibility.cs
+++ b/src/MediaAccessibility/MediaAccessibility.cs
@@ -361,6 +361,124 @@ public static bool IsCustomized (MACaptionAppearanceDomain domain)
{
return MACaptionAppearanceIsCustomized ((nint) (long) domain) != 0;
}
+
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ [DllImport (Constants.MediaAccessibilityLibrary)]
+ static extern /* CFArrayRef CF_RETURNS_RETAINED */ IntPtr MACaptionAppearanceCopyProfileIDs ();
+
+ /// Gets all the system and user-defined profile identifiers.
+ /// A string array of profile identifiers.
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ public static string []? GetProfileIds ()
+ {
+ var handle = MACaptionAppearanceCopyProfileIDs ();
+ var rv = CFArray.StringArrayFromHandle (handle, releaseHandle: true);
+ return (string []?) (object?) rv;
+ }
+
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ [DllImport (Constants.MediaAccessibilityLibrary)]
+ static extern void MACaptionAppearanceSetActiveProfileID (IntPtr /* CFStringRef */ profileID);
+
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ [DllImport (Constants.MediaAccessibilityLibrary)]
+ static extern /* CFStringRef CF_RETURNS_RETAINED */ IntPtr MACaptionAppearanceCopyActiveProfileID ();
+
+ /// Gets or sets the currently active system-wide caption-drawing profile by its identifier.
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ public static string? ActiveProfileId {
+ get {
+ return CFString.FromHandle (MACaptionAppearanceCopyActiveProfileID (), true);
+ }
+ set {
+ if (value is null)
+ ThrowHelper.ThrowArgumentNullException (nameof (value));
+
+ using var profileIdHandle = new TransientCFString (value);
+ MACaptionAppearanceSetActiveProfileID (profileIdHandle);
+ }
+ }
+
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ [DllImport (Constants.MediaAccessibilityLibrary)]
+ static extern /* CFStringRef CF_RETURNS_RETAINED */ IntPtr MACaptionAppearanceCopyProfileName (/* CFStringRef */ IntPtr profileId);
+
+ /// Get the human-readable name for a given profile identifier.
+ /// The profile identifier whose human-readable name to return.
+ /// The human-readable name for the specified profile identifier.
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ public static string? GetProfileName (string profileId)
+ {
+ if (profileId is null)
+ ThrowHelper.ThrowArgumentNullException (nameof (profileId));
+
+ using var profileIdHandle = new TransientCFString (profileId);
+ return CFString.FromHandle (MACaptionAppearanceCopyProfileName (profileIdHandle), true);
+ }
+
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ [DllImport (Constants.MediaAccessibilityLibrary)]
+ unsafe static extern void MACaptionAppearanceExecuteBlockForProfileID (IntPtr /* CFStringRef */ profileId, BlockLiteral* aBlock);
+
+ /// Execute a callback as if the specified profile was the currently active profile.
+ /// The identifier for the profile that will be active when the callback is executed.
+ /// The callback to call with the specified profile as the currently active profile.
+ /// This method can be used to get the fonts and colors for a profile without changing the currently selected profile.
+ [SupportedOSPlatform ("tvos26.0")]
+ [SupportedOSPlatform ("macos26.0")]
+ [SupportedOSPlatform ("ios26.0")]
+ [SupportedOSPlatform ("maccatalyst26.0")]
+ [BindingImpl (BindingImplOptions.Optimizable)]
+ public static void ExecuteCallbackForProfile (string profileId, Action callback)
+ {
+ if (profileId is null)
+ ThrowHelper.ThrowArgumentNullException (nameof (profileId));
+
+ if (callback is null)
+ ThrowHelper.ThrowArgumentNullException (nameof (callback));
+
+ using var profileIdHandle = new TransientCFString (profileId);
+
+ unsafe {
+ delegate* unmanaged trampoline = &Callback;
+ using var block = new BlockLiteral (trampoline, callback, typeof (MACaptionAppearance), nameof (Callback));
+ MACaptionAppearanceExecuteBlockForProfileID (profileIdHandle, &block);
+ }
+ }
+
+ [UnmanagedCallersOnly]
+ static void Callback (IntPtr block)
+ {
+ var del = BlockLiteral.GetTarget (block);
+ if (del is null)
+ return;
+
+ del ();
+ }
}
[SupportedOSPlatform ("ios")]
diff --git a/tests/monotouch-test/MediaAccessibility/CaptionAppearanceTest.cs b/tests/monotouch-test/MediaAccessibility/CaptionAppearanceTest.cs
index 3d6be5a9a74d..a13ad509de80 100644
--- a/tests/monotouch-test/MediaAccessibility/CaptionAppearanceTest.cs
+++ b/tests/monotouch-test/MediaAccessibility/CaptionAppearanceTest.cs
@@ -57,5 +57,35 @@ public void IsCustomized ()
Assert.That (MACaptionAppearance.IsCustomized (value), Is.EqualTo (true).Or.EqualTo (false), value.ToString ());
}
}
+
+ [Test]
+ public void TestProfiles ()
+ {
+ TestRuntime.AssertXcodeVersion (26, 0);
+
+ Assert.Multiple (() => {
+ var profiles = MACaptionAppearance.GetProfileIds ();
+ Assert.That (profiles, Is.Not.Empty, "Profiles");
+
+ Assert.That (MACaptionAppearance.ActiveProfileId, Is.Not.Null, "ActiveProfileId#1");
+ var originalProfileId = MACaptionAppearance.ActiveProfileId;
+ try {
+ MACaptionAppearance.ActiveProfileId = profiles [0];
+ Assert.That (MACaptionAppearance.ActiveProfileId, Is.EqualTo (profiles [0]), "ActiveProfileId#2");
+ } finally {
+ MACaptionAppearance.ActiveProfileId = originalProfileId;
+ }
+
+ foreach (var p in profiles) {
+ Assert.That (MACaptionAppearance.GetProfileName (p), Is.Not.Null.And.Not.Empty, $"ProfileName - {p}");
+ }
+
+ var calledCallback = false;
+ MACaptionAppearance.ExecuteCallbackForProfile (profiles [0], () => {
+ calledCallback = true;
+ });
+ Assert.That (calledCallback, Is.True, "ExecuteCallbackForProfile");
+ });
+ }
}
}
diff --git a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-MediaAccessibility.todo b/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-MediaAccessibility.todo
deleted file mode 100644
index d80bbc1b72bf..000000000000
--- a/tests/xtro-sharpie/api-annotations-dotnet/MacCatalyst-MediaAccessibility.todo
+++ /dev/null
@@ -1,5 +0,0 @@
-!missing-pinvoke! MACaptionAppearanceCopyActiveProfileID is not bound
-!missing-pinvoke! MACaptionAppearanceCopyProfileIDs is not bound
-!missing-pinvoke! MACaptionAppearanceCopyProfileName is not bound
-!missing-pinvoke! MACaptionAppearanceExecuteBlockForProfileID is not bound
-!missing-pinvoke! MACaptionAppearanceSetActiveProfileID is not bound
diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-MediaAccessibility.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-MediaAccessibility.todo
deleted file mode 100644
index d80bbc1b72bf..000000000000
--- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-MediaAccessibility.todo
+++ /dev/null
@@ -1,5 +0,0 @@
-!missing-pinvoke! MACaptionAppearanceCopyActiveProfileID is not bound
-!missing-pinvoke! MACaptionAppearanceCopyProfileIDs is not bound
-!missing-pinvoke! MACaptionAppearanceCopyProfileName is not bound
-!missing-pinvoke! MACaptionAppearanceExecuteBlockForProfileID is not bound
-!missing-pinvoke! MACaptionAppearanceSetActiveProfileID is not bound
diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-MediaAccessibility.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-MediaAccessibility.todo
deleted file mode 100644
index d80bbc1b72bf..000000000000
--- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-MediaAccessibility.todo
+++ /dev/null
@@ -1,5 +0,0 @@
-!missing-pinvoke! MACaptionAppearanceCopyActiveProfileID is not bound
-!missing-pinvoke! MACaptionAppearanceCopyProfileIDs is not bound
-!missing-pinvoke! MACaptionAppearanceCopyProfileName is not bound
-!missing-pinvoke! MACaptionAppearanceExecuteBlockForProfileID is not bound
-!missing-pinvoke! MACaptionAppearanceSetActiveProfileID is not bound
diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-MediaAccessibility.todo b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-MediaAccessibility.todo
deleted file mode 100644
index d80bbc1b72bf..000000000000
--- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-MediaAccessibility.todo
+++ /dev/null
@@ -1,5 +0,0 @@
-!missing-pinvoke! MACaptionAppearanceCopyActiveProfileID is not bound
-!missing-pinvoke! MACaptionAppearanceCopyProfileIDs is not bound
-!missing-pinvoke! MACaptionAppearanceCopyProfileName is not bound
-!missing-pinvoke! MACaptionAppearanceExecuteBlockForProfileID is not bound
-!missing-pinvoke! MACaptionAppearanceSetActiveProfileID is not bound