yavsc/src/PostIt/PostIt.Android/PlatformBootstrap.cs
Paul Schneider 2f4a7cb4c9
Reuse replay controls for live playback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-16 12:12:18 +00:00

48 lines
2.4 KiB
C#

using PostIt.Services;
using PostIt.Android.Services;
namespace PostIt.Android;
/// <summary>
/// One-shot platform bootstrap. Called from
/// <see cref="MainActivity.OnCreate"/> so that the shared OIDC login
/// path sees the Android-specific redirect URI and a working
/// <c>IBrowser</c> (Chrome Custom Tabs) without referencing Android
/// APIs from the shared library.
/// </summary>
internal static class PlatformBootstrap
{
internal static void InitPlatform()
{
Platform.CreateBrowser = () =>
{
var activity = MainActivity.Current;
return activity is null ? null : new AndroidSystemBrowser(activity);
};
Platform.CreateServiceProvider = AndroidServiceProvider.GetOrCreate;
Platform.BackgroundChatService = AndroidBackgroundChatService.Instance;
Platform.ShowSoftKeyboard = MainActivity.ShowSoftKeyboard;
Platform.TryGetCurrentLocationAsync = AndroidCurrentLocationProvider.TryGetCurrentLocationAsync;
Platform.CreateVideoSurface = (player, replay, playbackFailed) =>
new AndroidVideoSurface(player, replay, showControls: true, playbackFailed);
if (System.OperatingSystem.IsAndroidVersionAtLeast(26))
{
Platform.CreateWebRtcMedia = () => System.OperatingSystem.IsAndroidVersionAtLeast(26)
? new AndroidWebRtcMedia()
: throw new System.PlatformNotSupportedException("Android 8 requis pour WebRTC.");
Platform.GetWebRtcDevices = AndroidLanCallMedia.GetDevices;
Platform.GetLanCallDevices = AndroidLanCallMedia.GetDevices;
Platform.CreateLanCallMedia = (address, port) =>
System.OperatingSystem.IsAndroidVersionAtLeast(26)
? new AndroidLanCallMedia(address, port)
: throw new System.PlatformNotSupportedException("Android 8 requis pour les appels LAN.");
Platform.GetPodcastCaptureDevices = AndroidPodcastCapture.GetDevices;
Platform.RequestPodcastPermissionsAsync = AndroidPodcastCapture.RequestPermissionsAsync;
Platform.CreatePodcastCaptureAsync = AndroidPodcastCapture.StartAsync;
Platform.CreatePodcastPreviewAsync = AndroidPodcastCapture.StartPreviewAsync;
Platform.CreateBlurredPodcastCaptureAsync = AndroidPodcastCapture.StartBlurredAsync;
Platform.CreateBlurredPodcastPreviewAsync = AndroidPodcastCapture.StartBlurredPreviewAsync;
}
}
}