diff --git a/CHANGELOG.md b/CHANGELOG.md index e155cba8a..eabfbc84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ ### Fixed +* [PostIt/Podcasts] Reuse the replay playback controls for live video on desktop and Android, remove the duplicate play/pause button, and retain seeking only for replays. Report resume failures and cover playback controls with targeted tests. + * [PostIt] Restore selectable error notification messages and update blog and rendez-vous tests for the current layouts and address editor. * [PostIt] Set a custom OpenStreetMap User-Agent for the address editor map tiles to satisfy the OSM tile usage policy. diff --git a/doc/architecture/postit.md b/doc/architecture/postit.md index e7198ccc5..8ad6f0804 100644 --- a/doc/architecture/postit.md +++ b/doc/architecture/postit.md @@ -284,7 +284,9 @@ affichées dans la barre de statut, sans les masquer par une déduction MIME. Les types `video/*` ouvrent `VideoPage` via `App.PushPageAsync` sur desktop. Cette page contient un `LibVLCSharp.Avalonia.VideoView`, lecture/pause et -une action d'ouverture externe. Le lecteur et ses ressources natives sont +une action d'ouverture externe. Les commandes superposées servent aussi à la +lecture/pause du direct ; la position et la durée sont réservées au replay. +Android utilise des commandes natives équivalentes. Le lecteur et ses ressources natives sont arrêtés et libérés à la sortie de la page. La lecture utilise directement `new LibVLC()`, `new MediaPlayer(libVlc)` et `Play(media)`, sans options spécifiques à Linux ni détection VAAPI/VDPAU. Le média est libéré après @@ -298,7 +300,7 @@ Après la navigation, `TryUpdateNativeControlPosition()` synchronise la surface native à la priorité `Loaded`, une fois la mise en page effectuée : les transformations de transition ne déclenchent pas de changement de `Bounds`. Le rappel est ignoré si le lecteur a été libéré ou remplacé entre-temps. -Sur Android et Browser, où ce contrôle natif desktop n'est pas disponible, +Sur Android, une surface native remplace le contrôle desktop. Sur Browser, les vidéos sont ouvertes dans le navigateur, comme les autres fichiers (images liées, PDF, téléchargements) et les liens externes. diff --git a/src/PostIt/PostIt.Android/PlatformBootstrap.cs b/src/PostIt/PostIt.Android/PlatformBootstrap.cs index 9e0224cf1..358a96200 100644 --- a/src/PostIt/PostIt.Android/PlatformBootstrap.cs +++ b/src/PostIt/PostIt.Android/PlatformBootstrap.cs @@ -24,7 +24,8 @@ internal static class PlatformBootstrap Platform.BackgroundChatService = AndroidBackgroundChatService.Instance; Platform.ShowSoftKeyboard = MainActivity.ShowSoftKeyboard; Platform.TryGetCurrentLocationAsync = AndroidCurrentLocationProvider.TryGetCurrentLocationAsync; - Platform.CreateVideoSurface = (player, replay) => new AndroidVideoSurface(player, replay); + Platform.CreateVideoSurface = (player, replay, playbackFailed) => + new AndroidVideoSurface(player, replay, showControls: true, playbackFailed); if (System.OperatingSystem.IsAndroidVersionAtLeast(26)) { Platform.CreateWebRtcMedia = () => System.OperatingSystem.IsAndroidVersionAtLeast(26) diff --git a/src/PostIt/PostIt.Android/Services/AndroidVideoSurface.cs b/src/PostIt/PostIt.Android/Services/AndroidVideoSurface.cs index 60105abc1..215883a44 100644 --- a/src/PostIt/PostIt.Android/Services/AndroidVideoSurface.cs +++ b/src/PostIt/PostIt.Android/Services/AndroidVideoSurface.cs @@ -14,7 +14,7 @@ using Button = Android.Widget.Button; namespace PostIt.Android.Services; -internal sealed class AndroidVideoSurface(MediaPlayer player, bool replay) : NativeControlHost, IDisposable +internal sealed class AndroidVideoSurface(MediaPlayer player, bool replay, bool showControls = false, Action? playbackFailed = null) : NativeControlHost, IDisposable { private VideoView? _video; private ReplayLayout? _layout; @@ -44,9 +44,9 @@ internal sealed class AndroidVideoSurface(MediaPlayer player, bool replay) : Nat { if (!_disposed) _ready.TrySetResult(); }, Avalonia.Threading.DispatcherPriority.Loaded); - if (replay && !_disposed) + if ((replay || showControls) && !_disposed) { - _layout = new ReplayLayout(activity, video, player); + _layout = new ReplayLayout(activity, video, player, replay, playbackFailed); return new AndroidViewControlHandle(_layout); } return new AndroidViewControlHandle(video); @@ -110,19 +110,23 @@ internal sealed class AndroidVideoSurface(MediaPlayer player, bool replay) : Nat private readonly Button _toggle; private readonly SeekBar _seek; private readonly TextView _time; + private readonly Action? _playbackFailed; private bool _stopped; - public ReplayLayout(Context context, VideoView video, MediaPlayer player) : base(context) + public ReplayLayout(Context context, VideoView video, MediaPlayer player, bool replay, Action? playbackFailed) : base(context) { _player = player; + _playbackFailed = playbackFailed; AddView(video, new FrameLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)); _bar = new LinearLayout(context) { Orientation = Orientation.Horizontal }; _bar.SetGravity(GravityFlags.CenterVertical); _bar.SetPadding(12, 8, 12, 8); _bar.SetBackgroundColor(global::Android.Graphics.Color.Argb(210, 20, 20, 20)); - _toggle = new Button(context) { Text = "Pause", ContentDescription = "Lecture ou pause du replay" }; + _toggle = new Button(context) { Text = "Pause", ContentDescription = "Lecture ou pause de la vidéo" }; _seek = new SeekBar(context) { Max = 10000, ContentDescription = "Position dans le replay" }; _time = new TextView(context); + _seek.Visibility = replay ? ViewStates.Visible : ViewStates.Gone; + _time.Visibility = replay ? ViewStates.Visible : ViewStates.Gone; _time.SetTextColor(global::Android.Graphics.Color.White); _bar.AddView(_toggle); _bar.AddView(_seek, new LinearLayout.LayoutParams(0, LayoutParams.WrapContent, 1)); @@ -160,7 +164,7 @@ internal sealed class AndroidVideoSurface(MediaPlayer player, bool replay) : Nat private void Toggle(object? sender, EventArgs e) { if (_player.IsPlaying) _player.Pause(); - else _player.Play(); + else if (!_player.Play()) _playbackFailed?.Invoke(); _state.Show(); } diff --git a/src/PostIt/PostIt.Tests/BlogReaderTests.cs b/src/PostIt/PostIt.Tests/BlogReaderTests.cs index 6d37f0204..e35d1388c 100644 --- a/src/PostIt/PostIt.Tests/BlogReaderTests.cs +++ b/src/PostIt/PostIt.Tests/BlogReaderTests.cs @@ -441,7 +441,7 @@ public class BlogReaderTests var vm = new VideoPageViewModel(new Uri("https://org.example.test/files/paul/clip.mp4"), "video/mp4"); var page = Assert.IsType(new ViewLocator().Build(vm)); Assert.NotNull(page.FindControl("VideoSurface")); - Assert.NotNull(page.FindControl