diff --git a/HyPlayer.PlayCore.Abstraction/Interfaces/Playback/IPlaybackQualitySelector.cs b/HyPlayer.PlayCore.Abstraction/Interfaces/Playback/IPlaybackQualitySelector.cs new file mode 100644 index 0000000..c20c167 --- /dev/null +++ b/HyPlayer.PlayCore.Abstraction/Interfaces/Playback/IPlaybackQualitySelector.cs @@ -0,0 +1,9 @@ +using HyPlayer.PlayCore.Abstraction.Models.Resources; +using HyPlayer.PlayCore.Abstraction.Models.SingleItems; + +namespace HyPlayer.PlayCore.Abstraction.Interfaces.Playback; + +public interface IPlaybackQualitySelector +{ + ResourceQualityTag? GetPlaybackQualityTag(SingleSongBase song); +} diff --git a/HyPlayer.PlayCore.Abstraction/Interfaces/Playback/IPlaybackResourceResolver.cs b/HyPlayer.PlayCore.Abstraction/Interfaces/Playback/IPlaybackResourceResolver.cs new file mode 100644 index 0000000..5ab6f28 --- /dev/null +++ b/HyPlayer.PlayCore.Abstraction/Interfaces/Playback/IPlaybackResourceResolver.cs @@ -0,0 +1,14 @@ +using HyPlayer.PlayCore.Abstraction.Interfaces.Provider; +using HyPlayer.PlayCore.Abstraction.Models.Resources; +using HyPlayer.PlayCore.Abstraction.Models.SingleItems; + +namespace HyPlayer.PlayCore.Abstraction.Interfaces.Playback; + +public interface IPlaybackResourceResolver +{ + Task ResolvePlaybackResourceAsync( + SingleSongBase song, + IMusicResourceProvidable provider, + ResourceQualityTag? qualityTag, + CancellationToken ctk = default); +} diff --git a/HyPlayer.PlayCore.Abstraction/Interfaces/Provider/IProvidableItemCommentPageTokenProvidable.cs b/HyPlayer.PlayCore.Abstraction/Interfaces/Provider/IProvidableItemCommentPageTokenProvidable.cs new file mode 100644 index 0000000..343e3d5 --- /dev/null +++ b/HyPlayer.PlayCore.Abstraction/Interfaces/Provider/IProvidableItemCommentPageTokenProvidable.cs @@ -0,0 +1,11 @@ +using HyPlayer.PlayCore.Abstraction.Models; +using HyPlayer.PlayCore.Abstraction.Models.SingleItems; + +namespace HyPlayer.PlayCore.Abstraction.Interfaces.Provider; + +public interface IProvidableItemCommentPageTokenProvidable : IProvider +{ + public Task> GetCommentsPageAsync(string itemId, string typeId, string? pageToken, int count, int sortType = 1, CancellationToken ctk = new()); + + public Task> GetThreadedCommentsPageAsync(string itemId, string typeId, string commentId, string? pageToken, int count, CancellationToken ctk = new()); +} diff --git a/HyPlayer.PlayCore.Abstraction/Models/ProviderPageResult.cs b/HyPlayer.PlayCore.Abstraction/Models/ProviderPageResult.cs index 0d2df6c..0138904 100644 --- a/HyPlayer.PlayCore.Abstraction/Models/ProviderPageResult.cs +++ b/HyPlayer.PlayCore.Abstraction/Models/ProviderPageResult.cs @@ -21,6 +21,8 @@ public sealed class ProviderPageResult /// public int? NextOffset { get; set; } + public string? NextPageToken { get; set; } + /// /// Gets or sets the total item count when the provider exposes one. /// diff --git a/HyPlayer.PlayCore.Abstraction/Models/Resources/IAudioTrialMetadata.cs b/HyPlayer.PlayCore.Abstraction/Models/Resources/IAudioTrialMetadata.cs new file mode 100644 index 0000000..166f1bd --- /dev/null +++ b/HyPlayer.PlayCore.Abstraction/Models/Resources/IAudioTrialMetadata.cs @@ -0,0 +1,6 @@ +namespace HyPlayer.PlayCore.Abstraction.Models.Resources; + +public interface IAudioTrialMetadata +{ + bool IsTrial { get; } +} diff --git a/HyPlayer.PlayCore/PlayCoreComponents/PlayCore.PlayerModification.cs b/HyPlayer.PlayCore/PlayCoreComponents/PlayCore.PlayerModification.cs index 27c57c7..2337623 100644 --- a/HyPlayer.PlayCore/PlayCoreComponents/PlayCore.PlayerModification.cs +++ b/HyPlayer.PlayCore/PlayCoreComponents/PlayCore.PlayerModification.cs @@ -1,5 +1,6 @@ using Depository.Abstraction.Interfaces; using HyPlayer.PlayCore.Abstraction.Interfaces.AudioServices; +using HyPlayer.PlayCore.Abstraction.Interfaces.Playback; using HyPlayer.PlayCore.Abstraction.Interfaces.Provider; using HyPlayer.PlayCore.Abstraction; using HyPlayer.PlayCore.Abstraction.Models.AudioServiceComponents; @@ -112,7 +113,12 @@ private async Task DisposeCurrentPlayingTicketAsync(bool stopTicket, Cancellatio if (provider is null) return null; - return await provider.GetMusicResourceAsync(song, null, ctk).ConfigureAwait(false); + var qualityTag = ResolveOptional(typeof(IPlaybackQualitySelector)) + ?.GetPlaybackQualityTag(song); + if (ResolveOptional(typeof(IPlaybackResourceResolver)) is { } resolver) + return await resolver.ResolvePlaybackResourceAsync(song, provider, qualityTag, ctk).ConfigureAwait(false); + + return await provider.GetMusicResourceAsync(song, qualityTag, ctk).ConfigureAwait(false); } private Task PublishPlaybackFailureAsync(SingleSongBase? song, string reason, Exception? exception, CancellationToken ctk) diff --git a/HyPlayer.PlayCore/PlayListControllers/DefaultPlayListManager.cs b/HyPlayer.PlayCore/PlayListControllers/DefaultPlayListManager.cs index 7894fe1..a73e539 100644 --- a/HyPlayer.PlayCore/PlayListControllers/DefaultPlayListManager.cs +++ b/HyPlayer.PlayCore/PlayListControllers/DefaultPlayListManager.cs @@ -51,10 +51,13 @@ private async Task AppendSongContainerToList( (hasMore, var progressiveList) = await progressiveLoadingContainer.GetProgressiveItemsListAsync( start, progressiveLoadingContainer.MaxProgressiveCount, ctk); + if (progressiveList.Count == 0) + break; + var resultList = progressiveList.OfType().ToList(); list.AddRange(resultList); _list.AddRange(resultList); - start += progressiveLoadingContainer.MaxProgressiveCount; + start += progressiveList.Count; await _notificationHub.PublishNotificationAsync(new InnerPlayListProgressiveAddedNotification { AddedSongs = resultList