diff --git a/CHANGELOG.md b/CHANGELOG.md index d06589982..164899d03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,10 @@ ### Fixed +* [PostIt/Capture] Automatically upload finalized screen recordings as `video/mp4` to `Mes fichiers / screencast`, streaming the multipart file from disk and retaining the local copy if the upload fails. + +* [PostIt/Capture] Decode the PipeWire node identifier from the ScreenCast portal `streams` array of `(node id, properties)` structures, let the user choose a full screen, a window or the portal picker, and mux system audio from the default output monitor into the H.264/AAC MP4. Stop GStreamer with SIGINT so the muxer receives EOS and writes a valid `moov` atom. + * [PostIt.Tests] Run every Avalonia UI test in the shared `AvaloniaUiCollection` fixture: replace `[AvaloniaFact]`/`[AvaloniaTheory]` and direct `GetOrStartForAssembly` dispatches, which started a second headless session alongside the fixture's and could hang `PodcastBroadcasterTests`, with `ui.RunAsync` (new synchronous overload). Update contact-preference assertions in `MessagingSessionTests` for the audio-only capabilities the Linux desktop announces. * [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. diff --git a/src/PostIt/PostIt.Desktop/Services/LinuxScreenCaptureService.cs b/src/PostIt/PostIt.Desktop/Services/LinuxScreenCaptureService.cs index 427da06a4..f44acf7e8 100644 --- a/src/PostIt/PostIt.Desktop/Services/LinuxScreenCaptureService.cs +++ b/src/PostIt/PostIt.Desktop/Services/LinuxScreenCaptureService.cs @@ -23,6 +23,7 @@ public class LinuxScreenCaptureService : IScreenCaptureService private DBusConnection? _dbusConnection; private Process? _gstProcess; + private Task? _gstErrorOutput; private SafeFileHandle? _pipewireFd; private CancellationTokenSource? _timerCts; @@ -32,9 +33,13 @@ public class LinuxScreenCaptureService : IScreenCaptureService [DllImport("libc", SetLastError = true)] private static extern int fcntl(int fd, int cmd, int arg); + [DllImport("libc", SetLastError = true)] + private static extern int kill(int pid, int sig); + private const int F_GETFD = 1; private const int F_SETFD = 2; private const int FD_CLOEXEC = 1; + private const int SIGINT = 2; public string? LatestRestoreToken { get; private set; } @@ -52,6 +57,8 @@ public class LinuxScreenCaptureService : IScreenCaptureService { if (IsRecording) throw new InvalidOperationException("Un enregistrement est déjà en cours."); + LatestRestoreToken = options.RestoreToken; + // 1. Connexion D-Bus avec DBusConnection et DBusAddress _dbusConnection = new DBusConnection(DBusAddress.Session!); await _dbusConnection.ConnectAsync(); @@ -68,16 +75,19 @@ public class LinuxScreenCaptureService : IScreenCaptureService () => CallCreateSessionAsync(createToken, sessionToken), cancellationToken ); - if (createResponse.TryGetValue("restore_token", out var tokenVariant)) - { - LatestRestoreToken = tokenVariant.GetString(); - // Pense à sauvegarder LatestRestoreToken dans tes préférences utilisateur ici ! - } - string sessionHandle = createResponse["session_handle"].GetString(); // 3. Sélection de la source - uint sourceType = options.TargetWindowHandle.HasValue ? 2u : 1u; + ScreenCaptureSource effectiveSource = options.TargetWindowHandle.HasValue + ? ScreenCaptureSource.Window + : options.Source; + uint sourceType = effectiveSource switch + { + ScreenCaptureSource.Screen => 1u, + ScreenCaptureSource.Window => 2u, + ScreenCaptureSource.Prompt => 3u, + _ => throw new ArgumentOutOfRangeException(nameof(options), options.Source, "Source de capture inconnue.") + }; uint cursorMode = options.CaptureCursor ? 2u : 1u; string selectToken = $"monapp_req_{Guid.NewGuid():N}"; @@ -85,7 +95,12 @@ public class LinuxScreenCaptureService : IScreenCaptureService await SendPortalRequestAsync( expectedSelectPath, - () => CallSelectSourcesAsync(sessionHandle, selectToken, sourceType, cursorMode, LatestRestoreToken), + () => CallSelectSourcesAsync( + sessionHandle, + selectToken, + sourceType, + cursorMode, + effectiveSource == ScreenCaptureSource.Screen ? LatestRestoreToken : null), cancellationToken ); @@ -99,11 +114,16 @@ public class LinuxScreenCaptureService : IScreenCaptureService cancellationToken ); - var streams = startResponse["streams"].GetArray(); - if (streams.Length == 0) + if (startResponse.TryGetValue("restore_token", out var tokenVariant)) + { + LatestRestoreToken = tokenVariant.GetString(); + } + + var streams = startResponse["streams"]; + if (streams.Count == 0) throw new OperationCanceledException("Aucune source vidéo sélectionnée."); - uint pipewireNodeId = streams[0].GetUInt32(); + uint pipewireNodeId = streams.GetItem(0).GetItem(0).GetUInt32(); // 5. Récupération du File Descriptor PipeWire @@ -112,7 +132,7 @@ public class LinuxScreenCaptureService : IScreenCaptureService MakeFdInheritable(rawFd); // Indispensable pour que gst-launch-1.0 voie le flux PipeWire - StartGStreamerPipeline(rawFd, pipewireNodeId, options); + await StartGStreamerPipelineAsync(rawFd, pipewireNodeId, options); IsRecording = true; StartDurationTimer(); @@ -131,7 +151,7 @@ public class LinuxScreenCaptureService : IScreenCaptureService }); } - private void StartGStreamerPipeline(int fd, uint nodeId, CaptureOptions options) + private async Task StartGStreamerPipelineAsync(int fd, uint nodeId, CaptureOptions options) { // Pipeline GStreamer : // pipewiresrc lit directement les textures GPU (DMA-BUF) @@ -143,7 +163,16 @@ public class LinuxScreenCaptureService : IScreenCaptureService string args = $"-e pipewiresrc fd={fd} path={nodeId} do-timestamp=true keepalive-time=1000 ! " + $"videorate ! video/x-raw,framerate={options.Fps}/1 ! " + - $"{encoder} ! h264parse ! mp4mux ! filesink location=\"{options.OutputFilePath}\""; + $"{encoder} ! h264parse ! queue ! mp4mux name=mux ! " + + $"filesink location=\"{EscapeGStreamerString(options.OutputFilePath)}\""; + + if (options.CaptureAudio) + { + string audioDevice = await GetDefaultAudioMonitorAsync(); + args += $" pulsesrc device=\"{EscapeGStreamerString(audioDevice)}\" do-timestamp=true ! " + + "queue ! audioconvert ! audioresample ! avenc_aac bitrate=192000 ! " + + "aacparse ! queue ! mux."; + } _gstProcess = new Process { @@ -158,7 +187,61 @@ public class LinuxScreenCaptureService : IScreenCaptureService }; _gstProcess.Start(); + _gstErrorOutput = _gstProcess.StandardError.ReadToEndAsync(); } + + private static string EscapeGStreamerString(string value) => + value.Replace("\\", "\\\\", StringComparison.Ordinal) + .Replace("\"", "\\\"", StringComparison.Ordinal); + + private static async Task GetDefaultAudioMonitorAsync() + { + Process process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "pactl", + Arguments = "get-default-sink", + UseShellExecute = false, + RedirectStandardOutput = true, + RedirectStandardError = true, + CreateNoWindow = true + } + }; + + try + { + process.Start(); + Task outputTask = process.StandardOutput.ReadToEndAsync(); + Task errorTask = process.StandardError.ReadToEndAsync(); + await process.WaitForExitAsync().WaitAsync(TimeSpan.FromSeconds(3)); + + string output = (await outputTask).Trim(); + if (process.ExitCode != 0 || string.IsNullOrWhiteSpace(output)) + { + string error = (await errorTask).Trim(); + throw new InvalidOperationException( + $"Impossible de déterminer la sortie audio par défaut.{FormatProcessError(error)}"); + } + + return output + ".monitor"; + } + catch (TimeoutException) + { + if (!process.HasExited) + { + process.Kill(entireProcessTree: true); + await process.WaitForExitAsync(); + } + + throw new InvalidOperationException("La détection de la sortie audio a expiré."); + } + finally + { + process.Dispose(); + } + } + private static bool HasVaapiSupport() { try @@ -200,11 +283,72 @@ public class LinuxScreenCaptureService : IScreenCaptureService public async Task StopRecordingAsync() { - if (!IsRecording) return; + if (!IsRecording && _gstProcess is null) return; IsRecording = false; + _timerCts?.Cancel(); + _timerCts?.Dispose(); + _timerCts = null; + + Process? process = _gstProcess; + if (process is null) return; + + string errorOutput; + int exitCode; + try + { + if (!process.HasExited && kill(process.Id, SIGINT) != 0) + { + throw new InvalidOperationException( + $"Impossible d'envoyer SIGINT à GStreamer (errno {Marshal.GetLastPInvokeError()})."); + } + + await process.WaitForExitAsync().WaitAsync(TimeSpan.FromSeconds(10)); + errorOutput = _gstErrorOutput is null ? string.Empty : await _gstErrorOutput; + exitCode = process.ExitCode; + } + catch (TimeoutException) + { + if (!process.HasExited) + { + process.Kill(entireProcessTree: true); + await process.WaitForExitAsync(); + } + + throw new InvalidOperationException( + "GStreamer n'a pas finalisé le fichier MP4 dans les dix secondes."); + } + catch + { + if (!process.HasExited) + { + process.Kill(entireProcessTree: true); + await process.WaitForExitAsync(); + } + + throw; + } + finally + { + _pipewireFd?.Dispose(); + _pipewireFd = null; + _dbusConnection?.Dispose(); + _dbusConnection = null; + process.Dispose(); + _gstProcess = null; + _gstErrorOutput = null; + } + + if (exitCode != 0) + { + throw new InvalidOperationException( + $"GStreamer s'est arrêté avec le code {exitCode}.{FormatProcessError(errorOutput)}"); + } } + private static string FormatProcessError(string errorOutput) => + string.IsNullOrWhiteSpace(errorOutput) ? string.Empty : $" Détail : {errorOutput.Trim()}"; + private async Task> SendPortalRequestAsync( string expectedRequestPath, Func dbusCall, @@ -339,8 +483,23 @@ public class LinuxScreenCaptureService : IScreenCaptureService public void Dispose() { _timerCts?.Cancel(); - _gstProcess?.Kill(); - _gstProcess?.Dispose(); + _timerCts?.Dispose(); + + if (_gstProcess is not null) + { + if (!_gstProcess.HasExited) + { + kill(_gstProcess.Id, SIGINT); + if (!_gstProcess.WaitForExit(10_000)) + { + _gstProcess.Kill(entireProcessTree: true); + _gstProcess.WaitForExit(); + } + } + + _gstProcess.Dispose(); + } + _pipewireFd?.Dispose(); _dbusConnection?.Dispose(); } diff --git a/src/PostIt/PostIt.Tests/UserFilesApiClientTests.cs b/src/PostIt/PostIt.Tests/UserFilesApiClientTests.cs new file mode 100644 index 000000000..822274228 --- /dev/null +++ b/src/PostIt/PostIt.Tests/UserFilesApiClientTests.cs @@ -0,0 +1,89 @@ +using System.Net.Http; +using System.Text; +using Yavsc.Api.Client; + +namespace PostIt.Tests; + +public class UserFilesApiClientTests +{ + [Fact] + public async Task Upload_from_file_streams_video_to_screencast_directory() + { + string filePath = Path.Combine(Path.GetTempPath(), $"postit-{Guid.NewGuid():N}.mp4"); + byte[] expected = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70]; + await File.WriteAllBytesAsync(filePath, expected, TestContext.Current.CancellationToken); + + try + { + var api = new UploadApi(); + var client = new UserFilesApiClient(api, "https://blogs.example/api/v1/"); + + var received = await client.UploadAsync( + "screencast", + filePath, + "video/mp4", + TestContext.Current.CancellationToken); + + Assert.Single(received); + Assert.Equal(HttpMethod.Post, api.Method); + Assert.Equal("fs/screencast", api.Path); + string multipart = Encoding.UTF8.GetString(api.MultipartBody); + Assert.Contains(Path.GetFileName(filePath), multipart); + Assert.Contains("video/mp4", multipart); + Assert.True(api.MultipartBody.AsSpan().IndexOf(expected) >= 0); + } + finally + { + File.Delete(filePath); + } + } + + private sealed class UploadApi : IYavscApiClient + { + public HttpClient Http { get; } = new(); + public HttpMethod? Method { get; private set; } + public string? Path { get; private set; } + public byte[] MultipartBody { get; private set; } = []; + + public async Task CallAsync( + HttpMethod method, + string path, + Func contentFactory, + CancellationToken ct = default) + { + Method = method; + Path = path; + using HttpContent content = contentFactory(); + MultipartBody = await content.ReadAsByteArrayAsync(ct); + return (T)(object)new List + { + new() { FileName = Path, ContentType = "video/mp4", Length = MultipartBody.Length } + }; + } + + public Task CallAsync( + HttpMethod method, + string path, + object? body = null, + CancellationToken ct = default) => throw new NotSupportedException(); + + public Task CallAsync( + HttpMethod method, + string path, + object? body = null, + CancellationToken ct = default) => throw new NotSupportedException(); + + public Task CallAsync( + HttpMethod method, + string path, + Func contentFactory, + CancellationToken ct = default) => throw new NotSupportedException(); + + public Task DownloadAsync( + HttpMethod method, + string path, + CancellationToken ct = default) => throw new NotSupportedException(); + + public ValueTask DisposeAsync() => ValueTask.CompletedTask; + } +} diff --git a/src/PostIt/PostIt/Helpers/ServiceCollectionHelpers.cs b/src/PostIt/PostIt/Helpers/ServiceCollectionHelpers.cs index a1e1e7aa4..f9ccfb5a9 100644 --- a/src/PostIt/PostIt/Helpers/ServiceCollectionHelpers.cs +++ b/src/PostIt/PostIt/Helpers/ServiceCollectionHelpers.cs @@ -2,11 +2,13 @@ using System; using Microsoft.Extensions.DependencyInjection; using PostIt.Services; using PostIt.ViewModels; +using PostIt.ViewModels.Capture; using PostIt.ViewModels.Chat; using PostIt.Views; using PostIt.Views.Blogs; using PostIt.Views.Chat; using PostIt.Views.Commands; +using PostIt.Views.Video; using Yavsc.Api.Client; namespace PostIt.Helpers; @@ -137,7 +139,8 @@ public static class ServiceCollectionHelpers services.AddTransient(); services.AddSingleton(); services.AddTransient(); - + services.AddSingleton(); + services.AddSingleton(); // Dialogs (modal-light pages): the ViewLocator resolves // them when a caller pushes a PostAclDialogViewModel or // AddCircleMemberDialogViewModel via App.PushPageAsync. diff --git a/src/PostIt/PostIt/Interfaces/IScreenCaptureService.cs b/src/PostIt/PostIt/Interfaces/IScreenCaptureService.cs index 8ae9396d6..dea956cc6 100644 --- a/src/PostIt/PostIt/Interfaces/IScreenCaptureService.cs +++ b/src/PostIt/PostIt/Interfaces/IScreenCaptureService.cs @@ -4,12 +4,21 @@ using System.Threading.Tasks; namespace PostIt.Interfaces; +public enum ScreenCaptureSource +{ + Screen, + Window, + Prompt +} + public record CaptureOptions( string OutputFilePath, int Fps = 60, IntPtr? TargetWindowHandle = null, // Null = Écran principal complet bool CaptureCursor = true, - string? RestoreToken = null // Token sauvegardé de la session précédente + string? RestoreToken = null, // Token sauvegardé de la session précédente + ScreenCaptureSource Source = ScreenCaptureSource.Screen, + bool CaptureAudio = true ); public interface IScreenCaptureService : IDisposable diff --git a/src/PostIt/PostIt/ViewLocator.cs b/src/PostIt/PostIt/ViewLocator.cs index 77801933b..121fb04da 100644 --- a/src/PostIt/PostIt/ViewLocator.cs +++ b/src/PostIt/PostIt/ViewLocator.cs @@ -10,6 +10,8 @@ using PostIt.Views; using PostIt.Views.Blogs; using PostIt.Views.Chat; using PostIt.Views.Commands; +using PostIt.ViewModels.Capture; +using PostIt.Views.Video; namespace PostIt; @@ -41,6 +43,7 @@ public class ViewLocator : IDataTemplate var services = app!.ServiceProvider!; return data switch { + ScreenCaptureViewModel => services.GetRequiredService(), BlogsViewModel => services.GetRequiredService(), VideoPageViewModel => services.GetRequiredService(), ReplayEditorPageViewModel => services.GetRequiredService(), diff --git a/src/PostIt/PostIt/ViewModels/Blogs/BlogsViewModel.cs b/src/PostIt/PostIt/ViewModels/Blogs/BlogsViewModel.cs index 37f50e745..94fcbb826 100644 --- a/src/PostIt/PostIt/ViewModels/Blogs/BlogsViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/Blogs/BlogsViewModel.cs @@ -606,6 +606,9 @@ public partial class BlogsViewModel : ViewModelBase, IActionStatusViewModel Services = services; _resources = resources ?? new BlogResourceService(); Init(settings); + ScreenCaptureViewModel = Platform.IsScreenCaptureSupported && services is not null + ? services.GetService() + : null; } partial void OnSearchTextChanged(string value) diff --git a/src/PostIt/PostIt/ViewModels/Capture/ScreenCaptureViewModel.cs b/src/PostIt/PostIt/ViewModels/Capture/ScreenCaptureViewModel.cs index e735565cc..c9d971ef4 100644 --- a/src/PostIt/PostIt/ViewModels/Capture/ScreenCaptureViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/Capture/ScreenCaptureViewModel.cs @@ -1,36 +1,121 @@ using System; using System.IO; using System.Threading.Tasks; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using PostIt.Interfaces; +using PostIt.Models; using PostIt.Services; +using Yavsc.Api.Client; namespace PostIt.ViewModels.Capture; -public class ScreenCaptureViewModel : ViewModelBase +public record CaptureSourceOption(ScreenCaptureSource Source, string Label); + +public partial class ScreenCaptureViewModel : ViewModelBase, IActionStatusViewModel { IScreenCaptureService _captureService; + private readonly UserFilesApiClient? _userFiles; + private string? _outputFilePath; - public ScreenCaptureViewModel() + public CaptureSourceOption[] CaptureSources { get; } = + [ + new(ScreenCaptureSource.Screen, "Écran entier"), + new(ScreenCaptureSource.Window, "Fenêtre"), + new(ScreenCaptureSource.Prompt, "Choisir au lancement") + ]; + + private CaptureSourceOption _selectedCaptureSource = null!; + public CaptureSourceOption SelectedCaptureSource + { + get => _selectedCaptureSource; + set => SetProperty(ref _selectedCaptureSource, value); + } + + private bool _captureAudio = true; + public bool CaptureAudio + { + get => _captureAudio; + set => SetProperty(ref _captureAudio, value); + } + + private bool _isBusy; + public bool IsBusy + { + get => _isBusy; + set + { + if (SetProperty(ref _isBusy, value)) + OnPropertyChanged(nameof(CanConfigure)); + } + } + + public bool CanConfigure => !IsRecording && !IsBusy; + + private string _statusMessage = "Prêt."; + public string StatusMessage + { + get => _statusMessage; + set => SetProperty(ref _statusMessage, value); + } + + private StatusNotice _actionStatus = StatusNotice.Info("Prêt."); + public StatusNotice ActionStatus + { + get => _actionStatus; + set => SetProperty(ref _actionStatus, value); + } + + public ScreenCaptureViewModel(UserFilesApiClient userFiles) { if (Platform.IsScreenCaptureSupported) _captureService = Platform.CreateScreenCaptureService!(); else throw new NotSupportedException("Screen capture is not supported on this platform."); + + _userFiles = userFiles; + SelectedCaptureSource = CaptureSources[0]; } - string screencastNName = "screencast"; + + public ScreenCaptureViewModel() : this(null!) { } + + [ObservableProperty] + public partial string ScreencastNName { get; set; } = "screencast"; private string GetTokenFilePath() => Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), App.AppName, - screencastNName+"_token.txt" + $"{SanitizeFileName(ScreencastNName)}_{SelectedCaptureSource.Source.ToString().ToLowerInvariant()}_token.txt" ); - public bool IsRecording => _captureService?.IsRecording ?? false; + + public bool IsRecording { get => _captureService?.IsRecording ?? false; } + + [RelayCommand] public async Task ToggleRecordingAsync() { if (_captureService.IsRecording) { - await _captureService.StopRecordingAsync(); + IsBusy = true; + bool finalized = false; + try + { + await _captureService.StopRecordingAsync(); + finalized = true; + this.OnPropertyChanged(nameof(IsRecording)); + this.OnPropertyChanged(nameof(CanConfigure)); + await UploadRecordingAsync(); + } + catch (Exception ex) + { + this.SetErrorStatus(finalized + ? $"La capture est finalisée localement, mais son envoi a échoué : {ex.Message}" + : $"La finalisation de la capture a échoué : {ex.Message}"); + } + finally + { + IsBusy = false; + } return; } @@ -40,11 +125,18 @@ public class ScreenCaptureViewModel : ViewModelBase ? await File.ReadAllTextAsync(tokenFilePath) : null; + string fileName = EnsureMp4Extension(SanitizeFileName(ScreencastNName)); + _outputFilePath = Path.Combine(Path.GetTempPath(), fileName); + if (File.Exists(_outputFilePath)) + File.Delete(_outputFilePath); + var options = new CaptureOptions( - OutputFilePath: Path.Combine(Path.GetTempPath(), screencastNName + ".mp4"), + OutputFilePath: _outputFilePath, Fps: 60, CaptureCursor: true, - RestoreToken: savedToken + RestoreToken: savedToken, + Source: SelectedCaptureSource.Source, + CaptureAudio: CaptureAudio ); // 2. Lancer la capture (silencieuse si le token est valide) @@ -56,13 +148,46 @@ public class ScreenCaptureViewModel : ViewModelBase Directory.CreateDirectory(Path.GetDirectoryName(tokenFilePath)!); await File.WriteAllTextAsync(tokenFilePath, _captureService.LatestRestoreToken); } + this.OnPropertyChanged(nameof(IsRecording)); + this.OnPropertyChanged(nameof(CanConfigure)); + } + + private async Task UploadRecordingAsync() + { + if (_userFiles is null) + throw new InvalidOperationException("Le client de fichiers utilisateur est indisponible."); + if (string.IsNullOrWhiteSpace(_outputFilePath) || !File.Exists(_outputFilePath)) + throw new FileNotFoundException("Le fichier vidéo finalisé est introuvable.", _outputFilePath); + if (new FileInfo(_outputFilePath).Length == 0) + throw new InvalidOperationException("Le fichier vidéo finalisé est vide."); + + this.SetInfoStatus("Envoi de la capture dans Mes fichiers / screencast..."); + var received = await _userFiles.UploadAsync("screencast", _outputFilePath, "video/mp4"); + if (received.Count != 1 || received[0].QuotaOffense) + throw new InvalidOperationException("Le quota de stockage a refusé la capture."); + + File.Delete(_outputFilePath); + _outputFilePath = null; + this.SetInfoStatus("Capture envoyée dans Mes fichiers / screencast."); + } + + private static string EnsureMp4Extension(string name) => + name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase) ? name : name + ".mp4"; + + private static string SanitizeFileName(string value) + { + string name = string.IsNullOrWhiteSpace(value) ? "screencast" : value.Trim(); + foreach (char invalid in Path.GetInvalidFileNameChars()) + name = name.Replace(invalid, '_'); + name = name.Replace('/', '_').Replace('\\', '_').Trim('.'); + return string.IsNullOrWhiteSpace(name) ? "screencast" : name; } public void StopRecordingAsync() { if (_captureService.IsRecording) { - _captureService.StopRecordingAsync().GetAwaiter().GetResult(); + ToggleRecordingAsync().GetAwaiter().GetResult(); } } diff --git a/src/PostIt/PostIt/ViewModels/Layout/HomePageViewModel.cs b/src/PostIt/PostIt/ViewModels/Layout/HomePageViewModel.cs index 8e1457237..f6ca96f96 100644 --- a/src/PostIt/PostIt/ViewModels/Layout/HomePageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/Layout/HomePageViewModel.cs @@ -13,6 +13,7 @@ using PostIt.ViewModels.Chat; using Yavsc.Abstract.Workflow; using Yavsc.Abstract.Models.Messaging; using Yavsc.Api.Client; +using PostIt.ViewModels.Capture; namespace PostIt.ViewModels; @@ -86,6 +87,13 @@ public class HomePageViewModel : ViewModelBase ?? throw new InvalidOperationException("Page podcasts indisponible."); await app.PushPageAsync(vm); }); + OpenScreenCapture = new AsyncRelayCommand(async () => + { + var app = Application.Current as App ?? throw new InvalidOperationException("Application indisponible."); + var vm = app.ServiceProvider?.GetRequiredService() + ?? throw new InvalidOperationException("Page capture d'écran indisponible."); + await app.PushPageAsync(vm); + }); } @@ -106,6 +114,8 @@ public class HomePageViewModel : ViewModelBase public IAsyncRelayCommand RefreshNotificationsCommand { get; } public IAsyncRelayCommand DismissNotificationCommand { get; } + public IAsyncRelayCommand OpenScreenCapture { get; } + public async Task DismissNotificationAsync(Notification? notification) { if (notification is null) diff --git a/src/PostIt/PostIt/Views/Layout/HomePage.axaml b/src/PostIt/PostIt/Views/Layout/HomePage.axaml index 1370b78fb..39cd6e337 100644 --- a/src/PostIt/PostIt/Views/Layout/HomePage.axaml +++ b/src/PostIt/PostIt/Views/Layout/HomePage.axaml @@ -84,6 +84,11 @@ Command="{Binding OpenSubscriptions}" IsEnabled="{Binding SessionStatus.IsLoggedIn}" Label="Mon abonnement PayPal" /> + + + + diff --git a/src/PostIt/PostIt/Views/Video/ScreenCaptureView.axaml b/src/PostIt/PostIt/Views/Video/ScreenCaptureView.axaml new file mode 100644 index 000000000..056e0074f --- /dev/null +++ b/src/PostIt/PostIt/Views/Video/ScreenCaptureView.axaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + +