diff --git a/src/AmbientSounds.Uwp/Controls/SoundItemControl.xaml b/src/AmbientSounds.Uwp/Controls/SoundItemControl.xaml index f5485f203..5ee5aed2e 100644 --- a/src/AmbientSounds.Uwp/Controls/SoundItemControl.xaml +++ b/src/AmbientSounds.Uwp/Controls/SoundItemControl.xaml @@ -117,6 +117,11 @@ Command="{x:Bind ViewModel.RenameCommand, Mode=OneWay}" Icon="Rename" Visibility="{x:Bind ViewModel.IsMix, Mode=OneWay}" /> + diff --git a/src/AmbientSounds.Uwp/Services/ProtocolLaunchController.cs b/src/AmbientSounds.Uwp/Services/ProtocolLaunchController.cs index 39513de02..7c80b4bb8 100644 --- a/src/AmbientSounds.Uwp/Services/ProtocolLaunchController.cs +++ b/src/AmbientSounds.Uwp/Services/ProtocolLaunchController.cs @@ -2,12 +2,8 @@ using CommunityToolkit.Diagnostics; using System; using System.Collections.Generic; -using AmbientSounds.Constants; using JeniusApps.Common.Telemetry; -using Windows.ApplicationModel.DataTransfer; using Windows.System; -using JeniusApps.Common.Tools.Uwp; -using Microsoft.Extensions.DependencyInjection; #nullable enable @@ -19,6 +15,8 @@ public class ProtocolLaunchController private readonly IShareService _shareService; private readonly ITelemetry _telemetry; private readonly INavigator _navigator; + private readonly ISoundService _soundService; + private readonly ISoundMixService _soundMixService; private const string AutoPlayKey = "autoPlay"; @@ -26,17 +24,23 @@ public ProtocolLaunchController( IMixMediaPlayerService player, IShareService shareService, ITelemetry telemetry, - INavigator navigator) + INavigator navigator, + ISoundService soundService, + ISoundMixService soundMixService) { Guard.IsNotNull(player); Guard.IsNotNull(shareService); Guard.IsNotNull(telemetry); Guard.IsNotNull(navigator); + Guard.IsNotNull(soundService); + Guard.IsNotNull(soundMixService); _player = player; _shareService = shareService; _telemetry = telemetry; _navigator = navigator; + _soundService = soundService; + _soundMixService = soundMixService; } public void ProcessShareProtocolArguments(string arguments) @@ -52,12 +56,33 @@ public void ProcessShareProtocolArguments(string arguments) public async void ProcessAutoPlayProtocolArguments(string arguments) { bool minimize = false; - + string mixID = ""; + if (arguments.Contains("minimize")) { minimize = true; } + if (arguments.Contains("mix")) + { + int mixStart = arguments.IndexOf("mix=") + 4; + int mixEnd = arguments.IndexOf('&', mixStart); + + if (mixEnd == -1) // If there's no &, take the rest of the string (smart moment here) + { + mixID = arguments.Substring(mixStart); + } + else + { + mixID = arguments.Substring(mixStart, mixEnd - mixStart); + } + if (_player != null) { + _player.SetMixId(mixID); + _player.RemoveAll(); + await _player?.ToggleSoundsAsync(await _soundService.GetLocalSoundsAsync((await _soundService.GetLocalSoundAsync(mixID)).SoundIds), parentMixId: mixID); + } + } + _player?.Play(); if (minimize) diff --git a/src/AmbientSounds.Uwp/Strings/en-US/Resources.resw b/src/AmbientSounds.Uwp/Strings/en-US/Resources.resw index d75e705ee..4ad6e270f 100644 --- a/src/AmbientSounds.Uwp/Strings/en-US/Resources.resw +++ b/src/AmbientSounds.Uwp/Strings/en-US/Resources.resw @@ -1035,4 +1035,7 @@ Free trial available + + Copy mix ID + \ No newline at end of file diff --git a/src/AmbientSounds.Uwp/Strings/pl-PL/Resources.resw b/src/AmbientSounds.Uwp/Strings/pl-PL/Resources.resw index f63c5a09e..434223c05 100644 --- a/src/AmbientSounds.Uwp/Strings/pl-PL/Resources.resw +++ b/src/AmbientSounds.Uwp/Strings/pl-PL/Resources.resw @@ -1,5 +1,110 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx @@ -761,7 +866,7 @@ Oops! Nie mogliśmy znaleźć tego dźwięku. Zobaczymy, czy uda nam się go dodać w przyszłości - Szukać + Szukaj Szybkie wznawianie @@ -927,4 +1032,7 @@ Dostępna bezpłatna wersja próbna + + Kopiuj ID miksu + \ No newline at end of file diff --git a/src/AmbientSounds/Factories/SoundVmFactory.cs b/src/AmbientSounds/Factories/SoundVmFactory.cs index 968ee1fc0..42b2d7700 100644 --- a/src/AmbientSounds/Factories/SoundVmFactory.cs +++ b/src/AmbientSounds/Factories/SoundVmFactory.cs @@ -1,6 +1,5 @@ using AmbientSounds.Models; using AmbientSounds.Services; -using AmbientSounds.Tools; using AmbientSounds.ViewModels; using Microsoft.Extensions.DependencyInjection; using CommunityToolkit.Diagnostics; @@ -71,7 +70,8 @@ public SoundViewModel GetSoundVm(Sound s) _serviceProvider.GetRequiredService(), _serviceProvider.GetRequiredService(), _serviceProvider.GetRequiredService(), - _serviceProvider.GetRequiredService()); + _serviceProvider.GetRequiredService(), + _serviceProvider.GetRequiredService()); vm.Initialize(); return vm; } diff --git a/src/AmbientSounds/ViewModels/SoundViewModel.cs b/src/AmbientSounds/ViewModels/SoundViewModel.cs index 887a800dc..0b0052bde 100644 --- a/src/AmbientSounds/ViewModels/SoundViewModel.cs +++ b/src/AmbientSounds/ViewModels/SoundViewModel.cs @@ -35,6 +35,7 @@ public partial class SoundViewModel : ObservableObject private readonly IPresenceService _presenceService; private readonly IDispatcherQueue _dispatcherQueue; private readonly IAssetLocalizer _assetLocalizer; + private readonly IClipboard _clipboard; private Progress? _downloadProgress; [ObservableProperty] @@ -71,7 +72,8 @@ public SoundViewModel( IPresenceService presenceService, IDispatcherQueue dispatcherQueue, IOnlineSoundRepository onlineSoundRepo, - IAssetLocalizer assetLocalizer) + IAssetLocalizer assetLocalizer, + IClipboard clipboard) { _sound = s; _soundMixService = soundMixService; @@ -86,6 +88,7 @@ public SoundViewModel( _dispatcherQueue = dispatcherQueue; _onlineSoundRepo = onlineSoundRepo; _assetLocalizer = assetLocalizer; + _clipboard = clipboard; } public IAsyncRelayCommand>? MixUnavailableCommand { get; set; } @@ -237,6 +240,19 @@ private void OnProgressChanged(object sender, double e) } } + /// + /// Copies the mix ID to the clipboard. + /// + [RelayCommand] + private void CopyMixID() + { + if (IsMix) + { + _clipboard.CopyToClipboard(Id); + } + } + + /// /// Loads this sound into the player and plays it. ///