Adds playback preferences and auto-persisted playback state to user settings

This commit is contained in:
BinaryAlley committed 2026-10-15 21:09:38 +03:00
1 parent aab36dcd29
commit dd76309ded
81 files changed
+6102 -173

No files matched your search

+1 -1
View File
@@ -87,6 +87,6 @@ Wherever Lumina needs a folder or a file from the server, it opens the file syst
The tools section holds your settings and the language picker.
Your **settings** decide how lists and books behave for you. Enable pagination and the number of items per page control how browsing is split. The alpha picker option decides whether titles beginning with "The" are filed under the next word. Theme caching decides whether the theme is fetched fresh each time. Rendering PDFs as images and preserving book styles shape how books are shown, and the metadata and artwork aggregation options decide whether missing fields are completed from your other providers. The ones that touch libraries are described in more detail in [Managing Libraries](../managing-libraries/index.md).
Your **settings** decide how lists and books behave for you. Enable pagination and the number of items per page control how browsing is split. The alpha picker option decides whether titles beginning with "The" are filed under the next word. Theme caching decides whether the theme is fetched fresh each time. Rendering PDFs as images and preserving book styles shape how books are shown, and the metadata and artwork aggregation options decide whether missing fields are completed from your other providers. A final group of options shapes playback: whether the player keeps downloading while it is paused, whether it continues automatically at the end of an album or artist, whether consecutive tracks play without a gap, how ReplayGain normalizes loudness, and the quality cap used when the server has to normalize a track. The ones that touch libraries are described in more detail in [Managing Libraries](../managing-libraries/index.md).
The **language** picker switches the interface between the languages Lumina ships with, and remembers your choice.
@@ -8,6 +8,12 @@
- [Update User Settings](#update-user-settings)
- [Update User Settings Request](#update-user-settings-request)
- [Update User Settings Response](#update-user-settings-response)
- [Get Playback State](#get-playback-state)
- [Get Playback State Request](#get-playback-state-request)
- [Get Playback State Response](#get-playback-state-response)
- [Update Playback State](#update-playback-state)
- [Update Playback State Request](#update-playback-state-request)
- [Update Playback State Response](#update-playback-state-response)
## Settings
@@ -32,11 +38,16 @@ Returns the settings of the currently authenticated user.
"userId": "2cff0c0f-3a67-4e30-b94f-f4e948a3b64f",
"isPaginationEnabled": true,
"itemsPerPage": 50,
"ignoreThePrefixForAlphaPicker": true,
"shouldIgnoreThePrefixForAlphaPicker": true,
"isThemeCachingEnabled": true,
"shouldAggregateMetadataWhenMissing": true,
"shouldRenderPdfAsImages": false,
"shouldPreserveBookStyles": true
"shouldPreserveBookStyles": true,
"shouldKeepDownloadingWhilePaused": true,
"shouldAutoplay": true,
"isGaplessPlaybackEnabled": true,
"replayGainMode": "Off",
"streamingQuality": "Auto"
}
```
@@ -54,11 +65,16 @@ Updates the settings of the currently authenticated user.
{
"isPaginationEnabled": true,
"itemsPerPage": 50,
"ignoreThePrefixForAlphaPicker": true,
"shouldIgnoreThePrefixForAlphaPicker": true,
"isThemeCachingEnabled": true,
"shouldAggregateMetadataWhenMissing": true,
"shouldRenderPdfAsImages": false,
"shouldPreserveBookStyles": true
"shouldPreserveBookStyles": true,
"shouldKeepDownloadingWhilePaused": true,
"shouldAutoplay": true,
"isGaplessPlaybackEnabled": true,
"replayGainMode": "Off",
"streamingQuality": "Auto"
}
```
@@ -67,3 +83,49 @@ Updates the settings of the currently authenticated user.
```js
200 Ok
```
### Get Playback State
#### Get Playback State Request
```js
GET api/v1/users/me/settings/playback-state
```
Returns the playback state (the last volume and mute state) the player reported for the currently authenticated user. The values are written automatically by the player and are never surfaced as settings fields.
#### Get Playback State Response
```js
200 Ok
```
```json
{
"volume": 0.75,
"isMuted": false
}
```
### Update Playback State
#### Update Playback State Request
```js
PUT api/v1/users/me/settings/playback-state
```
Updates the playback state the player reported for the currently authenticated user. Both fields are required: the volume is a value between 0 and 1, and the mute state is a boolean. A request that omits either field, or sends a volume outside that range, is rejected with a `422 Unprocessable Entity`.
```json
{
"volume": 0.75,
"isMuted": false
}
```
#### Update Playback State Response
```js
200 Ok
```
@@ -0,0 +1,2 @@
GET {{host}}/api/v1/users/me/settings/playback-state
Authorization: Bearer {{ACCESS_TOKEN}}
@@ -0,0 +1,8 @@
PUT {{host}}/api/v1/users/me/settings/playback-state
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"volume": 0.75,
"isMuted": false
}
@@ -5,9 +5,14 @@ Content-Type: application/json
{
"isPaginationEnabled": true,
"itemsPerPage": 50,
"ignoreThePrefixForAlphaPicker": true,
"shouldIgnoreThePrefixForAlphaPicker": true,
"isThemeCachingEnabled": true,
"shouldAggregateMetadataWhenMissing": true,
"shouldRenderPdfAsImages": false,
"shouldPreserveBookStyles": true
"shouldPreserveBookStyles": true,
"shouldKeepDownloadingWhilePaused": true,
"shouldAutoplay": true,
"isGaplessPlaybackEnabled": true,
"replayGainMode": "Off",
"streamingQuality": "Auto"
}
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Diagnostics;
#endregion
@@ -65,6 +66,41 @@ public class UserSettingsEntity : IStorageEntity, IAuditableEntity
/// </summary>
public bool ShouldPreserveBookStyles { get; set; }
/// <summary>
/// Gets or sets whether the player keeps downloading a track while playback is paused, or not, up to the entire file.
/// </summary>
public bool ShouldKeepDownloadingWhilePaused { get; set; } = true;
/// <summary>
/// Gets or sets whether the player continues playback at the end of an album or artist, or not.
/// </summary>
public bool ShouldAutoplay { get; set; } = true;
/// <summary>
/// Gets or sets whether the player transitions between consecutive tracks without a gap, or not.
/// </summary>
public bool IsGaplessPlaybackEnabled { get; set; } = true;
/// <summary>
/// Gets or sets the way ReplayGain normalization is applied to the tracks the user plays.
/// </summary>
public ReplayGainMode ReplayGainMode { get; set; }
/// <summary>
/// Gets or sets the quality cap applied to the audio the server normalizes for the user.
/// </summary>
public PlaybackStreamingQuality StreamingQuality { get; set; }
/// <summary>
/// Gets or sets the last volume the player reported for the user. Written automatically by the player, and not part of the settings the user edits.
/// </summary>
public double Volume { get; set; } = 1.0;
/// <summary>
/// Gets or sets the last mute state the player reported for the user. Written automatically by the player, and not part of the settings the user edits.
/// </summary>
public bool IsMuted { get; set; }
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
@@ -0,0 +1,25 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdatePlaybackState;
using Lumina.Contracts.Requests.UsersManagement.Settings;
#endregion
namespace Lumina.Application.Common.Mapping.UsersManagement.Users;
/// <summary>
/// Extension methods for converting <see cref="UpdatePlaybackStateRequest"/>.
/// </summary>
public static class UpdatePlaybackStateRequestMapping
{
/// <summary>
/// Converts <paramref name="request"/> to <see cref="UpdatePlaybackStateCommand"/>.
/// </summary>
/// <param name="request">The request to be converted.</param>
/// <returns>The converted command.</returns>
public static UpdatePlaybackStateCommand ToCommand(this UpdatePlaybackStateRequest request)
{
return new UpdatePlaybackStateCommand(
request.Volume,
request.IsMuted
);
}
}
@@ -25,7 +25,12 @@ public static class UpdateUserSettingsRequestMapping
request.ShouldAggregateMetadataWhenMissing,
request.ShouldAggregateArtworkWhenMissing,
request.ShouldRenderPdfAsImages,
request.ShouldPreserveBookStyles
request.ShouldPreserveBookStyles,
request.ShouldKeepDownloadingWhilePaused,
request.ShouldAutoplay,
request.IsGaplessPlaybackEnabled,
request.ReplayGainMode,
request.StreamingQuality
);
}
}
@@ -33,7 +33,14 @@ public static class UserSettingsEntityMapping
repositoryEntity.ShouldAggregateMetadataWhenMissing,
repositoryEntity.ShouldAggregateArtworkWhenMissing,
repositoryEntity.ShouldRenderPdfAsImages,
repositoryEntity.ShouldPreserveBookStyles
repositoryEntity.ShouldPreserveBookStyles,
repositoryEntity.ShouldKeepDownloadingWhilePaused,
repositoryEntity.ShouldAutoplay,
repositoryEntity.IsGaplessPlaybackEnabled,
repositoryEntity.ReplayGainMode,
repositoryEntity.StreamingQuality,
repositoryEntity.Volume,
repositoryEntity.IsMuted
);
}
@@ -53,7 +60,12 @@ public static class UserSettingsEntityMapping
repositoryEntity.ShouldAggregateMetadataWhenMissing,
repositoryEntity.ShouldAggregateArtworkWhenMissing,
repositoryEntity.ShouldRenderPdfAsImages,
repositoryEntity.ShouldPreserveBookStyles
repositoryEntity.ShouldPreserveBookStyles,
repositoryEntity.ShouldKeepDownloadingWhilePaused,
repositoryEntity.ShouldAutoplay,
repositoryEntity.IsGaplessPlaybackEnabled,
repositoryEntity.ReplayGainMode,
repositoryEntity.StreamingQuality
);
}
}
@@ -29,7 +29,14 @@ public static class UserSettingsMapping
ShouldAggregateMetadataWhenMissing = domainEntity.ShouldAggregateMetadataWhenMissing,
ShouldAggregateArtworkWhenMissing = domainEntity.ShouldAggregateArtworkWhenMissing,
ShouldRenderPdfAsImages = domainEntity.ShouldRenderPdfAsImages,
ShouldPreserveBookStyles = domainEntity.ShouldPreserveBookStyles
ShouldPreserveBookStyles = domainEntity.ShouldPreserveBookStyles,
ShouldKeepDownloadingWhilePaused = domainEntity.ShouldKeepDownloadingWhilePaused,
ShouldAutoplay = domainEntity.ShouldAutoplay,
IsGaplessPlaybackEnabled = domainEntity.IsGaplessPlaybackEnabled,
ReplayGainMode = domainEntity.ReplayGainMode,
StreamingQuality = domainEntity.StreamingQuality,
Volume = domainEntity.Volume,
IsMuted = domainEntity.IsMuted
};
}
@@ -49,7 +56,12 @@ public static class UserSettingsMapping
domainEntity.ShouldAggregateMetadataWhenMissing,
domainEntity.ShouldAggregateArtworkWhenMissing,
domainEntity.ShouldRenderPdfAsImages,
domainEntity.ShouldPreserveBookStyles
domainEntity.ShouldPreserveBookStyles,
domainEntity.ShouldKeepDownloadingWhilePaused,
domainEntity.ShouldAutoplay,
domainEntity.IsGaplessPlaybackEnabled,
domainEntity.ReplayGainMode,
domainEntity.StreamingQuality
);
}
}
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
#endregion
namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdatePlaybackState;
/// <summary>
/// Command for updating the playback state the player reports for the current user automatically. These values are not part of the settings the user edits.
/// </summary>
/// <param name="Volume">The last volume the player reported, as a value between 0 and 1.</param>
/// <param name="IsMuted">The last mute state the player reported.</param>
public record UpdatePlaybackStateCommand(
double? Volume,
bool? IsMuted
) : ICommand;
@@ -0,0 +1,104 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Errors;
using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Application.Common.Infrastructure.Validation;
using Lumina.Application.Common.Mapping.UsersManagement.Users;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdatePlaybackState;
/// <summary>
/// Handler for the command to update the playback state the player reports for the current user automatically.
/// </summary>
public class UpdatePlaybackStateCommandHandler : ICommandHandler<UpdatePlaybackStateCommand, Result<Updated>>
{
private readonly IUnitOfWork _unitOfWork;
private readonly ICurrentUserService _currentUserService;
private readonly IValidator<UpdatePlaybackStateCommand> _validator;
/// <summary>
/// Initializes a new instance of the <see cref="UpdatePlaybackStateCommandHandler"/> class.
/// </summary>
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
/// <param name="validator">Injected validator for application validation rules.</param>
public UpdatePlaybackStateCommandHandler(ICurrentUserService currentUserService, IUnitOfWork unitOfWork, IValidator<UpdatePlaybackStateCommand> validator)
{
_currentUserService = currentUserService;
_unitOfWork = unitOfWork;
_validator = validator;
}
/// <summary>
/// Handles the command to update the playback state the player reports for the current user automatically.
/// </summary>
/// <param name="command">The command to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="Result{TValue}"/> representing either a successful update, or an error message.
/// </returns>
public async Task<Result<Updated>> HandleAsync(UpdatePlaybackStateCommand command, CancellationToken cancellationToken)
{
List<Error> validationResult = _validator.Validate(command);
if (validationResult.Count > 0)
return validationResult;
// An authenticated request must always carry a user identity.
Guid? currentUserId = _currentUserService.UserId;
if (currentUserId is null)
return Errors.Authorization.NotAuthorized;
Guid userId = currentUserId.Value;
// Get the existing settings of the current user, if any.
Result<UserSettingsEntity?> getSettingsResult = await _unitOfWork.UserSettingsRepository.GetByUserIdAsync(userId, cancellationToken).ConfigureAwait(false);
if (getSettingsResult.IsFailure)
return getSettingsResult.Errors;
if (getSettingsResult.Value is null)
{
// Create the settings of the current user, since they are not stored yet, keeping the settings the user edits by hand at their default.
Result<UserSettings> createSettingsResult = UserSettings.Create(UserId.Create(userId));
if (createSettingsResult.IsFailure)
return createSettingsResult.Errors;
Result<Updated> applyResult = createSettingsResult.Value.UpdatePlaybackState(command.Volume!.Value, command.IsMuted!.Value);
if (applyResult.IsFailure)
return applyResult.Errors;
Result<Created> insertResult = await _unitOfWork.UserSettingsRepository.InsertAsync(createSettingsResult.Value.ToRepositoryEntity(), cancellationToken).ConfigureAwait(false);
if (insertResult.IsFailure)
return insertResult.Errors;
}
else
{
// Update the stored settings of the current user.
Result<UserSettings> toDomainEntityResult = getSettingsResult.Value.ToDomainEntity();
if (toDomainEntityResult.IsFailure)
return toDomainEntityResult.Errors;
Result<Updated> applyResult = toDomainEntityResult.Value.UpdatePlaybackState(command.Volume!.Value, command.IsMuted!.Value);
if (applyResult.IsFailure)
return applyResult.Errors;
Result<Updated> updateResult = await _unitOfWork.UserSettingsRepository.UpdateAsync(toDomainEntityResult.Value.ToRepositoryEntity(), cancellationToken).ConfigureAwait(false);
if (updateResult.IsFailure)
return updateResult.Errors;
}
Result<Success> saveChangesResult = await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
if (saveChangesResult.IsFailure)
return saveChangesResult.Errors;
return Result.Updated;
}
}
@@ -0,0 +1,31 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Infrastructure.Validation;
using Lumina.Application.Common.Utilities;
using Lumina.Domain.Common.Errors;
#endregion
namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdatePlaybackState;
/// <summary>
/// Validates the needed validation rules for <see cref="UpdatePlaybackStateCommand"/>.
/// </summary>
public class UpdatePlaybackStateCommandValidator : AbstractValidator<UpdatePlaybackStateCommand>
{
/// <summary>
/// Initializes a new instance of the <see cref="UpdatePlaybackStateCommandValidator"/> class.
/// </summary>
public UpdatePlaybackStateCommandValidator()
{
RuleFor(command => command.Volume)
.NotNull()
.WithError(Errors.UserSettings.VolumeCannotBeNull);
RuleFor(command => command.Volume)
.Must(volume => volume is null || (volume.Value >= 0.0 && volume.Value <= 1.0))
.WithError(Errors.UserSettings.VolumeMustBeBetweenZeroAndOne);
RuleFor(command => command.IsMuted)
.NotNull()
.WithError(Errors.UserSettings.IsMutedCannotBeNull);
}
}
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
#endregion
namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSettings;
@@ -15,6 +16,11 @@ namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSe
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <param name="ShouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="ShouldAutoplay">Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="IsGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="ReplayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="StreamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
public record UpdateUserSettingsCommand(
bool IsPaginationEnabled,
int ItemsPerPage,
@@ -23,5 +29,10 @@ public record UpdateUserSettingsCommand(
bool ShouldAggregateMetadataWhenMissing,
bool ShouldAggregateArtworkWhenMissing,
bool ShouldRenderPdfAsImages,
bool ShouldPreserveBookStyles
bool ShouldPreserveBookStyles,
bool? ShouldKeepDownloadingWhilePaused,
bool? ShouldAutoplay,
bool? IsGaplessPlaybackEnabled,
ReplayGainMode? ReplayGainMode,
PlaybackStreamingQuality? StreamingQuality
) : ICommand;
@@ -66,20 +66,16 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
if (getSettingsResult.Value is null)
{
// Create the settings of the current user, since they are not stored yet.
Result<UserSettings> createSettingsResult = UserSettings.Create(
UserId.Create(userId),
command.IsPaginationEnabled,
command.ItemsPerPage,
command.ShouldIgnoreThePrefixForAlphaPicker,
command.IsThemeCachingEnabled,
command.ShouldAggregateMetadataWhenMissing,
command.ShouldAggregateArtworkWhenMissing,
command.ShouldRenderPdfAsImages,
command.ShouldPreserveBookStyles);
// Create the settings of the current user, since they are not stored yet. The playback state the player reports automatically is left
// at its default, because this command only carries the settings the user edits by hand.
Result<UserSettings> createSettingsResult = UserSettings.Create(UserId.Create(userId));
if (createSettingsResult.IsFailure)
return createSettingsResult.Errors;
Result<Updated> applySettingsResult = ApplySettings(createSettingsResult.Value, command);
if (applySettingsResult.IsFailure)
return applySettingsResult.Errors;
Result<Created> insertResult = await _unitOfWork.UserSettingsRepository.InsertAsync(createSettingsResult.Value.ToRepositoryEntity(), cancellationToken).ConfigureAwait(false);
if (insertResult.IsFailure)
return insertResult.Errors;
@@ -91,15 +87,7 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
if (toDomainEntityResult.IsFailure)
return toDomainEntityResult.Errors;
Result<Updated> updateSettingsResult = toDomainEntityResult.Value.UpdateSettings(
command.IsPaginationEnabled,
command.ItemsPerPage,
command.ShouldIgnoreThePrefixForAlphaPicker,
command.IsThemeCachingEnabled,
command.ShouldAggregateMetadataWhenMissing,
command.ShouldAggregateArtworkWhenMissing,
command.ShouldRenderPdfAsImages,
command.ShouldPreserveBookStyles);
Result<Updated> updateSettingsResult = ApplySettings(toDomainEntityResult.Value, command);
if (updateSettingsResult.IsFailure)
return updateSettingsResult.Errors;
@@ -114,4 +102,28 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
return Result.Updated;
}
/// <summary>
/// Applies the values carried by <paramref name="command"/> to the settings of the current user.
/// </summary>
/// <param name="settings">The settings of the current user to update.</param>
/// <param name="command">The command carrying the new values of the settings.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful update, or an error.</returns>
private static Result<Updated> ApplySettings(UserSettings settings, UpdateUserSettingsCommand command)
{
return settings.UpdateSettings(
command.IsPaginationEnabled,
command.ItemsPerPage,
command.ShouldIgnoreThePrefixForAlphaPicker,
command.IsThemeCachingEnabled,
command.ShouldAggregateMetadataWhenMissing,
command.ShouldAggregateArtworkWhenMissing,
command.ShouldRenderPdfAsImages,
command.ShouldPreserveBookStyles,
command.ShouldKeepDownloadingWhilePaused!.Value,
command.ShouldAutoplay!.Value,
command.IsGaplessPlaybackEnabled!.Value,
command.ReplayGainMode!.Value,
command.StreamingQuality!.Value);
}
}
@@ -19,5 +19,35 @@ public class UpdateUserSettingsCommandValidator : AbstractValidator<UpdateUserSe
RuleFor(command => command.ItemsPerPage)
.GreaterThan(0)
.WithError(Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero);
RuleFor(command => command.ShouldKeepDownloadingWhilePaused)
.NotNull()
.WithError(Errors.UserSettings.ShouldKeepDownloadingWhilePausedCannotBeNull);
RuleFor(command => command.ShouldAutoplay)
.NotNull()
.WithError(Errors.UserSettings.ShouldAutoplayCannotBeNull);
RuleFor(command => command.IsGaplessPlaybackEnabled)
.NotNull()
.WithError(Errors.UserSettings.IsGaplessPlaybackEnabledCannotBeNull);
RuleFor(command => command.ReplayGainMode)
.NotNull()
.WithError(Errors.UserSettings.ReplayGainModeCannotBeNull);
RuleFor(command => command.ReplayGainMode)
.IsInEnum()
.WithError(Errors.UserSettings.InvalidReplayGainMode)
.When(command => command.ReplayGainMode is not null);
RuleFor(command => command.StreamingQuality)
.NotNull()
.WithError(Errors.UserSettings.StreamingQualityCannotBeNull);
RuleFor(command => command.StreamingQuality)
.IsInEnum()
.WithError(Errors.UserSettings.InvalidStreamingQuality)
.When(command => command.StreamingQuality is not null);
}
}
@@ -0,0 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
#endregion
namespace Lumina.Application.Core.UsersManagement.Settings.Queries.GetPlaybackState;
/// <summary>
/// Query for getting the playback state the player reported for the current user automatically. These values are not part of the settings the user edits.
/// </summary>
public record GetPlaybackStateQuery : IQuery;
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Errors;
using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Core.UsersManagement.Settings.Queries.GetPlaybackState;
/// <summary>
/// Handler for the query to get the playback state the player reported for the current user automatically.
/// </summary>
public class GetPlaybackStateQueryHandler : IQueryHandler<GetPlaybackStateQuery, Result<PlaybackStateResponse>>
{
private readonly IUnitOfWork _unitOfWork;
private readonly ICurrentUserService _currentUserService;
/// <summary>
/// Initializes a new instance of the <see cref="GetPlaybackStateQueryHandler"/> class.
/// </summary>
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
public GetPlaybackStateQueryHandler(ICurrentUserService currentUserService, IUnitOfWork unitOfWork)
{
_currentUserService = currentUserService;
_unitOfWork = unitOfWork;
}
/// <summary>
/// Handles the query to get the playback state the player reported for the current user automatically.
/// </summary>
/// <param name="query">The query to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="Result{TValue}"/> containing either a successfully retrieved <see cref="PlaybackStateResponse"/>, or an error message.
/// </returns>
public async Task<Result<PlaybackStateResponse>> HandleAsync(GetPlaybackStateQuery query, CancellationToken cancellationToken)
{
// An authenticated request must always carry a user identity.
Guid? currentUserId = _currentUserService.UserId;
if (currentUserId is null)
return Errors.Authorization.NotAuthorized;
Guid userId = currentUserId.Value;
// Get the settings of the current user from the repository.
Result<UserSettingsEntity?> getSettingsResult = await _unitOfWork.UserSettingsRepository.GetByUserIdAsync(userId, cancellationToken).ConfigureAwait(false);
if (getSettingsResult.IsFailure)
return getSettingsResult.Errors;
// When no settings are stored for the current user yet, return the default playback state.
if (getSettingsResult.Value is null)
{
Result<UserSettings> defaultSettingsResult = UserSettings.Create();
if (defaultSettingsResult.IsFailure)
return defaultSettingsResult.Errors;
return new PlaybackStateResponse(defaultSettingsResult.Value.Volume, defaultSettingsResult.Value.IsMuted);
}
return new PlaybackStateResponse(getSettingsResult.Value.Volume, getSettingsResult.Value.IsMuted);
}
}
@@ -46,18 +46,18 @@ public class GetUserSettingsQueryHandler : IQueryHandler<GetUserSettingsQuery, R
/// </returns>
public async Task<Result<UserSettingsResponse>> HandleAsync(GetUserSettingsQuery query, CancellationToken cancellationToken)
{
// an authenticated request must always carry a user identity
// An authenticated request must always carry a user identity.
Guid? currentUserId = _currentUserService.UserId;
if (currentUserId is null)
return Errors.Authorization.NotAuthorized;
Guid userId = currentUserId.Value;
// get the settings of the current user from the repository
// Get the settings of the current user from the repository.
Result<UserSettingsEntity?> getSettingsResult = await _unitOfWork.UserSettingsRepository.GetByUserIdAsync(userId, cancellationToken).ConfigureAwait(false);
if (getSettingsResult.IsFailure)
return getSettingsResult.Errors;
// when no settings are stored for the current user yet, return the default settings
// When no settings are stored for the current user yet, return the default settings.
if (getSettingsResult.Value is null)
{
Result<UserSettings> defaultSettingsResult = UserSettings.Create();
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.UsersManagement.Settings;
/// <summary>
/// Represents a request to report the playback state of the current user. The player sends this automatically, and these values are not part of the settings the user edits.
/// </summary>
/// <param name="Volume">The last volume the player reported, as a value between 0 and 1. Required.</param>
/// <param name="IsMuted">The last mute state the player reported. Required.</param>
[DebuggerDisplay("Volume: {Volume}; IsMuted: {IsMuted}")]
public sealed record UpdatePlaybackStateRequest(
double? Volume,
bool? IsMuted
);
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Diagnostics;
#endregion
@@ -15,6 +16,11 @@ namespace Lumina.Contracts.Requests.UsersManagement.Settings;
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. Required.</param>
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not. Required.</param>
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not. Required.</param>
/// <param name="ShouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused, or not. Required.</param>
/// <param name="ShouldAutoplay">Whether the player continues playback at the end of an album or artist, or not. Required.</param>
/// <param name="IsGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap, or not. Required.</param>
/// <param name="ReplayGainMode">The way ReplayGain normalization is applied to the tracks the user plays. Required.</param>
/// <param name="StreamingQuality">The quality cap applied to the audio the server normalizes for the user. Required.</param>
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
public sealed record UpdateUserSettingsRequest(
bool IsPaginationEnabled,
@@ -24,5 +30,10 @@ public sealed record UpdateUserSettingsRequest(
bool ShouldAggregateMetadataWhenMissing,
bool ShouldAggregateArtworkWhenMissing,
bool ShouldRenderPdfAsImages,
bool ShouldPreserveBookStyles
bool ShouldPreserveBookStyles,
bool? ShouldKeepDownloadingWhilePaused,
bool? ShouldAutoplay,
bool? IsGaplessPlaybackEnabled,
ReplayGainMode? ReplayGainMode,
PlaybackStreamingQuality? StreamingQuality
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.UsersManagement.Settings;
/// <summary>
/// Represents the playback state of a user, as last reported by the player. The player writes these values automatically, and they are not part of the settings the user edits.
/// </summary>
/// <param name="Volume">The last volume the player reported, as a value between 0 and 1.</param>
/// <param name="IsMuted">The last mute state the player reported.</param>
[DebuggerDisplay("Volume: {Volume}; IsMuted: {IsMuted}")]
public sealed record PlaybackStateResponse(
double Volume,
bool IsMuted
);
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Diagnostics;
#endregion
@@ -17,6 +18,11 @@ namespace Lumina.Contracts.Responses.UsersManagement.Settings;
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <param name="ShouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="ShouldAutoplay">Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="IsGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="ReplayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="StreamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
[DebuggerDisplay("UserId: {UserId}")]
public sealed record UserSettingsResponse(
Guid UserId,
@@ -27,5 +33,10 @@ public sealed record UserSettingsResponse(
bool ShouldAggregateMetadataWhenMissing,
bool ShouldAggregateArtworkWhenMissing,
bool ShouldRenderPdfAsImages,
bool ShouldPreserveBookStyles
bool ShouldPreserveBookStyles,
bool ShouldKeepDownloadingWhilePaused,
bool ShouldAutoplay,
bool IsGaplessPlaybackEnabled,
ReplayGainMode ReplayGainMode,
PlaybackStreamingQuality StreamingQuality
);
@@ -66,6 +66,34 @@ public class UserSettingsConfiguration : IEntityTypeConfiguration<UserSettingsEn
.IsRequired()
.HasColumnOrder(9);
builder.Property(settings => settings.ShouldKeepDownloadingWhilePaused)
.IsRequired()
.HasColumnOrder(14);
builder.Property(settings => settings.ShouldAutoplay)
.IsRequired()
.HasColumnOrder(15);
builder.Property(settings => settings.IsGaplessPlaybackEnabled)
.IsRequired()
.HasColumnOrder(16);
builder.Property(settings => settings.ReplayGainMode)
.IsRequired()
.HasColumnOrder(17);
builder.Property(settings => settings.StreamingQuality)
.IsRequired()
.HasColumnOrder(18);
builder.Property(settings => settings.Volume)
.IsRequired()
.HasColumnOrder(19);
builder.Property(settings => settings.IsMuted)
.IsRequired()
.HasColumnOrder(20);
// audit
builder.Property(settings => settings.CreatedOnUtc)
.IsRequired()
@@ -0,0 +1,102 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Lumina.DataAccess.Common.Migrations
{
/// <inheritdoc />
public partial class AddsPlaybackPreferencesAndStateToUserSettings : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsGaplessPlaybackEnabled",
table: "UserSettings",
type: "INTEGER",
nullable: false,
defaultValue: true)
.Annotation("Relational:ColumnOrder", 16);
migrationBuilder.AddColumn<bool>(
name: "IsMuted",
table: "UserSettings",
type: "INTEGER",
nullable: false,
defaultValue: false)
.Annotation("Relational:ColumnOrder", 20);
migrationBuilder.AddColumn<int>(
name: "ReplayGainMode",
table: "UserSettings",
type: "INTEGER",
nullable: false,
defaultValue: 0)
.Annotation("Relational:ColumnOrder", 17);
migrationBuilder.AddColumn<bool>(
name: "ShouldAutoplay",
table: "UserSettings",
type: "INTEGER",
nullable: false,
defaultValue: true)
.Annotation("Relational:ColumnOrder", 15);
migrationBuilder.AddColumn<bool>(
name: "ShouldKeepDownloadingWhilePaused",
table: "UserSettings",
type: "INTEGER",
nullable: false,
defaultValue: true)
.Annotation("Relational:ColumnOrder", 14);
migrationBuilder.AddColumn<int>(
name: "StreamingQuality",
table: "UserSettings",
type: "INTEGER",
nullable: false,
defaultValue: 0)
.Annotation("Relational:ColumnOrder", 18);
migrationBuilder.AddColumn<double>(
name: "Volume",
table: "UserSettings",
type: "REAL",
nullable: false,
defaultValue: 1.0)
.Annotation("Relational:ColumnOrder", 19);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsGaplessPlaybackEnabled",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "IsMuted",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "ReplayGainMode",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "ShouldAutoplay",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "ShouldKeepDownloadingWhilePaused",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "StreamingQuality",
table: "UserSettings");
migrationBuilder.DropColumn(
name: "Volume",
table: "UserSettings");
}
}
}
@@ -2359,6 +2359,14 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(5);
b.Property<bool>("IsGaplessPlaybackEnabled")
.HasColumnType("INTEGER")
.HasColumnOrder(16);
b.Property<bool>("IsMuted")
.HasColumnType("INTEGER")
.HasColumnOrder(20);
b.Property<bool>("IsPaginationEnabled")
.HasColumnType("INTEGER")
.HasColumnOrder(2);
@@ -2371,6 +2379,10 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("INTEGER")
.HasColumnOrder(3);
b.Property<int>("ReplayGainMode")
.HasColumnType("INTEGER")
.HasColumnOrder(17);
b.Property<bool>("ShouldAggregateArtworkWhenMissing")
.HasColumnType("INTEGER")
.HasColumnOrder(13);
@@ -2379,10 +2391,18 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("INTEGER")
.HasColumnOrder(10);
b.Property<bool>("ShouldAutoplay")
.HasColumnType("INTEGER")
.HasColumnOrder(15);
b.Property<bool>("ShouldIgnoreThePrefixForAlphaPicker")
.HasColumnType("INTEGER")
.HasColumnOrder(4);
b.Property<bool>("ShouldKeepDownloadingWhilePaused")
.HasColumnType("INTEGER")
.HasColumnOrder(14);
b.Property<bool>("ShouldPreserveBookStyles")
.HasColumnType("INTEGER")
.HasColumnOrder(12);
@@ -2391,6 +2411,10 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("INTEGER")
.HasColumnOrder(11);
b.Property<int>("StreamingQuality")
.HasColumnType("INTEGER")
.HasColumnOrder(18);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(8);
@@ -2403,6 +2427,10 @@ namespace Lumina.DataAccess.Common.Migrations
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.Property<double>("Volume")
.HasColumnType("REAL")
.HasColumnOrder(19);
b.HasKey("Id");
b.HasIndex("UserId")
@@ -0,0 +1,30 @@
namespace Lumina.Domain.SharedKernel.Common.Enums.Playback;
/// <summary>
/// Enumeration for the quality cap applied to the audio the server normalizes (remuxes or transcodes) for a user.
/// </summary>
/// <remarks>
/// The caps apply only to audio the server has to change; a track that is played directly is always delivered as it was stored.
/// </remarks>
public enum PlaybackStreamingQuality
{
/// <summary>
/// The server chooses the quality, with no explicit cap.
/// </summary>
Auto,
/// <summary>
/// Normalized audio is capped at 96 kbps.
/// </summary>
Low,
/// <summary>
/// Normalized audio is capped at 160 kbps.
/// </summary>
Medium,
/// <summary>
/// Normalized audio is capped at 320 kbps.
/// </summary>
High,
}
@@ -0,0 +1,23 @@
namespace Lumina.Domain.SharedKernel.Common.Enums.Playback;
/// <summary>
/// Enumeration for the ways ReplayGain normalization is applied to the tracks a user plays.
/// </summary>
public enum ReplayGainMode
{
/// <summary>
/// ReplayGain is not applied. Tracks play at the loudness at which they were stored.
/// </summary>
Off,
/// <summary>
/// Each track is normalized using its own ReplayGain track gain, so tracks from different albums play at a similar loudness.
/// </summary>
Track,
/// <summary>
/// Each track is normalized using the ReplayGain album gain of the album it belongs to, so an album keeps its relative loudness
/// while albums play at a similar loudness to each other.
/// </summary>
Album,
}
@@ -14,5 +14,15 @@ public static partial class Errors
public static Error UserSettingsAlreadyExists => Error.Conflict(description: nameof(UserSettingsAlreadyExists));
public static Error UserSettingsNotFound => Error.NotFound(description: nameof(UserSettingsNotFound));
public static Error ItemsPerPageMustBeGreaterThanZero => Error.Validation(description: nameof(ItemsPerPageMustBeGreaterThanZero));
public static Error VolumeCannotBeNull => Error.Validation(description: nameof(VolumeCannotBeNull));
public static Error VolumeMustBeBetweenZeroAndOne => Error.Validation(description: nameof(VolumeMustBeBetweenZeroAndOne));
public static Error IsMutedCannotBeNull => Error.Validation(description: nameof(IsMutedCannotBeNull));
public static Error ShouldKeepDownloadingWhilePausedCannotBeNull => Error.Validation(description: nameof(ShouldKeepDownloadingWhilePausedCannotBeNull));
public static Error ShouldAutoplayCannotBeNull => Error.Validation(description: nameof(ShouldAutoplayCannotBeNull));
public static Error IsGaplessPlaybackEnabledCannotBeNull => Error.Validation(description: nameof(IsGaplessPlaybackEnabledCannotBeNull));
public static Error ReplayGainModeCannotBeNull => Error.Validation(description: nameof(ReplayGainModeCannotBeNull));
public static Error StreamingQualityCannotBeNull => Error.Validation(description: nameof(StreamingQualityCannotBeNull));
public static Error InvalidReplayGainMode => Error.Validation(description: nameof(InvalidReplayGainMode));
public static Error InvalidStreamingQuality => Error.Validation(description: nameof(InvalidStreamingQuality));
}
}
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Models.Core;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Diagnostics;
#endregion
@@ -23,6 +23,13 @@ public class UserSettings : AggregateRoot<UserSettingsId>
private const bool DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING = false;
private const bool DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES = false;
private const bool DEFAULT_SHOULD_PRESERVE_BOOK_STYLES = true;
private const bool DEFAULT_SHOULD_KEEP_DOWNLOADING_WHILE_PAUSED = true;
private const bool DEFAULT_SHOULD_AUTOPLAY = true;
private const bool DEFAULT_IS_GAPLESS_PLAYBACK_ENABLED = true;
private const ReplayGainMode DEFAULT_REPLAY_GAIN_MODE = ReplayGainMode.Off;
private const PlaybackStreamingQuality DEFAULT_STREAMING_QUALITY = PlaybackStreamingQuality.Auto;
private const double DEFAULT_VOLUME = 1.0;
private const bool DEFAULT_IS_MUTED = false;
/// <summary>
/// Gets the object representing the unique identifier of the user that owns these settings.
@@ -72,6 +79,41 @@ public class UserSettings : AggregateRoot<UserSettingsId>
/// </summary>
public bool ShouldPreserveBookStyles { get; private set; }
/// <summary>
/// Gets whether the player keeps downloading a track while playback is paused, or not, up to the entire file.
/// </summary>
public bool ShouldKeepDownloadingWhilePaused { get; private set; }
/// <summary>
/// Gets whether the player continues playback at the end of an album or artist, or not.
/// </summary>
public bool ShouldAutoplay { get; private set; }
/// <summary>
/// Gets whether the player transitions between consecutive tracks without a gap, or not.
/// </summary>
public bool IsGaplessPlaybackEnabled { get; private set; }
/// <summary>
/// Gets the way ReplayGain normalization is applied to the tracks the user plays.
/// </summary>
public ReplayGainMode ReplayGainMode { get; private set; }
/// <summary>
/// Gets the quality cap applied to the audio the server normalizes for the user.
/// </summary>
public PlaybackStreamingQuality StreamingQuality { get; private set; }
/// <summary>
/// Gets the last volume the player reported for the user. It is written automatically by the player, and is not part of the settings the user edits.
/// </summary>
public double Volume { get; private set; }
/// <summary>
/// Gets the last mute state the player reported for the user. It is written automatically by the player, and is not part of the settings the user edits.
/// </summary>
public bool IsMuted { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="UserSettings"/> class.
/// </summary>
@@ -85,6 +127,13 @@ public class UserSettings : AggregateRoot<UserSettingsId>
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <param name="volume">The last volume the player reported for the user.</param>
/// <param name="isMuted">The last mute state the player reported for the user.</param>
private UserSettings(
UserSettingsId id,
UserId userId,
@@ -95,7 +144,14 @@ public class UserSettings : AggregateRoot<UserSettingsId>
bool shouldAggregateMetadataWhenMissing,
bool shouldAggregateArtworkWhenMissing,
bool shouldRenderPdfAsImages,
bool shouldPreserveBookStyles) : base(id)
bool shouldPreserveBookStyles,
bool shouldKeepDownloadingWhilePaused,
bool shouldAutoplay,
bool isGaplessPlaybackEnabled,
ReplayGainMode replayGainMode,
PlaybackStreamingQuality streamingQuality,
double volume,
bool isMuted) : base(id)
{
UserId = userId;
IsPaginationEnabled = isPaginationEnabled;
@@ -106,6 +162,13 @@ public class UserSettings : AggregateRoot<UserSettingsId>
ShouldAggregateArtworkWhenMissing = shouldAggregateArtworkWhenMissing;
ShouldRenderPdfAsImages = shouldRenderPdfAsImages;
ShouldPreserveBookStyles = shouldPreserveBookStyles;
ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused;
ShouldAutoplay = shouldAutoplay;
IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled;
ReplayGainMode = replayGainMode;
StreamingQuality = streamingQuality;
Volume = volume;
IsMuted = isMuted;
}
/// <summary>
@@ -117,15 +180,22 @@ public class UserSettings : AggregateRoot<UserSettingsId>
public static Result<UserSettings> Create()
{
return Create(
UserId.CreateUnique(),
DEFAULT_IS_PAGINATION_ENABLED,
DEFAULT_ITEMS_PER_PAGE,
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
DEFAULT_IS_THEME_CACHING_ENABLED,
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
UserId.CreateUnique(),
DEFAULT_IS_PAGINATION_ENABLED,
DEFAULT_ITEMS_PER_PAGE,
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
DEFAULT_IS_THEME_CACHING_ENABLED,
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING,
DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES,
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES,
DEFAULT_SHOULD_KEEP_DOWNLOADING_WHILE_PAUSED,
DEFAULT_SHOULD_AUTOPLAY,
DEFAULT_IS_GAPLESS_PLAYBACK_ENABLED,
DEFAULT_REPLAY_GAIN_MODE,
DEFAULT_STREAMING_QUALITY,
DEFAULT_VOLUME,
DEFAULT_IS_MUTED
);
}
@@ -139,15 +209,22 @@ public class UserSettings : AggregateRoot<UserSettingsId>
public static Result<UserSettings> Create(UserId userId)
{
return Create(
userId,
DEFAULT_IS_PAGINATION_ENABLED,
DEFAULT_ITEMS_PER_PAGE,
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
DEFAULT_IS_THEME_CACHING_ENABLED,
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
userId,
DEFAULT_IS_PAGINATION_ENABLED,
DEFAULT_ITEMS_PER_PAGE,
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
DEFAULT_IS_THEME_CACHING_ENABLED,
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING,
DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES,
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES,
DEFAULT_SHOULD_KEEP_DOWNLOADING_WHILE_PAUSED,
DEFAULT_SHOULD_AUTOPLAY,
DEFAULT_IS_GAPLESS_PLAYBACK_ENABLED,
DEFAULT_REPLAY_GAIN_MODE,
DEFAULT_STREAMING_QUALITY,
DEFAULT_VOLUME,
DEFAULT_IS_MUTED
);
}
@@ -163,6 +240,13 @@ public class UserSettings : AggregateRoot<UserSettingsId>
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <param name="volume">The last volume the player reported for the user.</param>
/// <param name="isMuted">The last mute state the player reported for the user.</param>
/// <returns>
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="UserSettings"/>, or an error message.
/// </returns>
@@ -175,11 +259,15 @@ public class UserSettings : AggregateRoot<UserSettingsId>
bool shouldAggregateMetadataWhenMissing,
bool shouldAggregateArtworkWhenMissing,
bool shouldRenderPdfAsImages,
bool shouldPreserveBookStyles)
bool shouldPreserveBookStyles,
bool shouldKeepDownloadingWhilePaused,
bool shouldAutoplay,
bool isGaplessPlaybackEnabled,
ReplayGainMode replayGainMode,
PlaybackStreamingQuality streamingQuality,
double volume,
bool isMuted)
{
if (itemsPerPage <= 0)
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
return new UserSettings(
UserSettingsId.CreateUnique(),
userId,
@@ -190,7 +278,14 @@ public class UserSettings : AggregateRoot<UserSettingsId>
shouldAggregateMetadataWhenMissing,
shouldAggregateArtworkWhenMissing,
shouldRenderPdfAsImages,
shouldPreserveBookStyles);
shouldPreserveBookStyles,
shouldKeepDownloadingWhilePaused,
shouldAutoplay,
isGaplessPlaybackEnabled,
replayGainMode,
streamingQuality,
volume,
isMuted);
}
/// <summary>
@@ -206,6 +301,13 @@ public class UserSettings : AggregateRoot<UserSettingsId>
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <param name="volume">The last volume the player reported for the user.</param>
/// <param name="isMuted">The last mute state the player reported for the user.</param>
/// <returns>
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="UserSettings"/>, or an error message.
/// </returns>
@@ -219,17 +321,25 @@ public class UserSettings : AggregateRoot<UserSettingsId>
bool shouldAggregateMetadataWhenMissing,
bool shouldAggregateArtworkWhenMissing,
bool shouldRenderPdfAsImages,
bool shouldPreserveBookStyles)
bool shouldPreserveBookStyles,
bool shouldKeepDownloadingWhilePaused,
bool shouldAutoplay,
bool isGaplessPlaybackEnabled,
ReplayGainMode replayGainMode,
PlaybackStreamingQuality streamingQuality,
double volume,
bool isMuted)
{
if (itemsPerPage <= 0)
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, shouldAggregateArtworkWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles);
return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, shouldAggregateArtworkWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles, shouldKeepDownloadingWhilePaused, shouldAutoplay, isGaplessPlaybackEnabled, replayGainMode, streamingQuality, volume, isMuted);
}
/// <summary>
/// Updates the settings of the user.
/// </summary>
/// <remarks>
/// The playback state the player reports automatically (the volume and the mute state) is not part of the settings the user edits, so
/// this method neither accepts nor changes it.
/// </remarks>
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
@@ -238,6 +348,11 @@ public class UserSettings : AggregateRoot<UserSettingsId>
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful update, or an error.</returns>
public Result<Updated> UpdateSettings(
bool isPaginationEnabled,
@@ -247,11 +362,13 @@ public class UserSettings : AggregateRoot<UserSettingsId>
bool shouldAggregateMetadataWhenMissing,
bool shouldAggregateArtworkWhenMissing,
bool shouldRenderPdfAsImages,
bool shouldPreserveBookStyles)
bool shouldPreserveBookStyles,
bool shouldKeepDownloadingWhilePaused,
bool shouldAutoplay,
bool isGaplessPlaybackEnabled,
ReplayGainMode replayGainMode,
PlaybackStreamingQuality streamingQuality)
{
if (itemsPerPage <= 0)
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
IsPaginationEnabled = isPaginationEnabled;
ItemsPerPage = itemsPerPage;
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
@@ -260,6 +377,24 @@ public class UserSettings : AggregateRoot<UserSettingsId>
ShouldAggregateArtworkWhenMissing = shouldAggregateArtworkWhenMissing;
ShouldRenderPdfAsImages = shouldRenderPdfAsImages;
ShouldPreserveBookStyles = shouldPreserveBookStyles;
ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused;
ShouldAutoplay = shouldAutoplay;
IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled;
ReplayGainMode = replayGainMode;
StreamingQuality = streamingQuality;
return Result.Updated;
}
/// <summary>
/// Updates the playback state the player reports automatically.
/// </summary>
/// <param name="volume">The last volume the player reported for the user.</param>
/// <param name="isMuted">The last mute state the player reported for the user.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful update, or an error.</returns>
public Result<Updated> UpdatePlaybackState(double volume, bool isMuted)
{
Volume = volume;
IsMuted = isMuted;
return Result.Updated;
}
}
@@ -13,5 +13,7 @@ public static partial class ApiRoutes
public const string GET_USER_BY_ID = "/users/{id}";
public const string GET_USER_SETTINGS = "/users/me/settings"; // uses "me" because it is always for the currently authenticated user
public const string UPDATE_USER_SETTINGS = "/users/me/settings";
public const string GET_PLAYBACK_STATE = "/users/me/settings/playback-state";
public const string UPDATE_PLAYBACK_STATE = "/users/me/settings/playback-state";
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.UsersManagement.Settings.Queries.GetPlaybackState;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Common.Routes.UsersManagement;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Settings.GetPlaybackState;
/// <summary>
/// API endpoint for the <c>/users/me/settings/playback-state</c> route.
/// </summary>
/// <remarks>
/// Uses "me" because it is always for the currently authenticated user.
/// </remarks>
public class GetPlaybackStateEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
private readonly IQueryHandler<GetPlaybackStateQuery, Result<PlaybackStateResponse>> _getPlaybackStateQueryHandler;
/// <summary>
/// Initializes a new instance of the <see cref="GetPlaybackStateEndpoint"/> class.
/// </summary>
/// <param name="getPlaybackStateQueryHandler">Injected service for handling get playback state queries.</param>
public GetPlaybackStateEndpoint(IQueryHandler<GetPlaybackStateQuery, Result<PlaybackStateResponse>> getPlaybackStateQueryHandler)
{
_getPlaybackStateQueryHandler = getPlaybackStateQueryHandler;
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
Verbs(Http.GET);
Routes(ApiRoutes.Users.GET_PLAYBACK_STATE);
Version(1);
DontCatchExceptions();
}
/// <summary>
/// Gets the playback state the player reported for the current user automatically.
/// </summary>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
{
Result<PlaybackStateResponse> result = await _getPlaybackStateQueryHandler.HandleAsync(new GetPlaybackStateQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Settings.GetPlaybackState;
/// <summary>
/// Class used for providing a textual description for the <see cref="GetPlaybackStateEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPlaybackStateEndpointSummary : Summary<GetPlaybackStateEndpoint, EmptyRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetPlaybackStateEndpointSummary"/> class.
/// </summary>
public GetPlaybackStateEndpointSummary()
{
Summary = "Retrieves the playback state the player reported for the current user.";
Description = "Retrieves the last volume and mute state the player reported for the current user. When no settings are stored for the user yet, the default values are returned.";
Response(200, "The playback state of the current user is returned.",
example: new PlaybackStateResponse(
Volume: 1.0,
IsMuted: false
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Authentication failed",
instance = "/api/v1/users/me/settings/playback-state"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token has expired",
instance = "/api/v1/users/me/settings/playback-state"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/users/me/settings/playback-state"
}
}
);
}
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -31,7 +32,12 @@ public class GetUserSettingsEndpointSummary : Summary<GetUserSettingsEndpoint, E
ShouldAggregateMetadataWhenMissing: false,
ShouldAggregateArtworkWhenMissing: false,
ShouldRenderPdfAsImages: false,
ShouldPreserveBookStyles: true
ShouldPreserveBookStyles: true,
ShouldKeepDownloadingWhilePaused: true,
ShouldAutoplay: true,
IsGaplessPlaybackEnabled: true,
ReplayGainMode: ReplayGainMode.Off,
StreamingQuality: PlaybackStreamingQuality.Auto
));
Response(401, "Authentication required.", "application/problem+json",
@@ -0,0 +1,56 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Application.Common.Mapping.UsersManagement.Users;
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdatePlaybackState;
using Lumina.Contracts.Requests.UsersManagement.Settings;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Common.Routes.UsersManagement;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Settings.UpdatePlaybackState;
/// <summary>
/// API endpoint for the <c>/users/me/settings/playback-state</c> route.
/// </summary>
/// <remarks>
/// Uses "me" because it is always for the currently authenticated user.
/// </remarks>
public class UpdatePlaybackStateEndpoint : BaseEndpoint<UpdatePlaybackStateRequest, IResult>
{
private readonly ICommandHandler<UpdatePlaybackStateCommand, Result<Updated>> _updatePlaybackStateCommandHandler;
/// <summary>
/// Initializes a new instance of the <see cref="UpdatePlaybackStateEndpoint"/> class.
/// </summary>
/// <param name="updatePlaybackStateCommandHandler">Injected service for handling update playback state commands.</param>
public UpdatePlaybackStateEndpoint(ICommandHandler<UpdatePlaybackStateCommand, Result<Updated>> updatePlaybackStateCommandHandler)
{
_updatePlaybackStateCommandHandler = updatePlaybackStateCommandHandler;
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
Verbs(FastEndpoints.Http.PUT);
Routes(ApiRoutes.Users.UPDATE_PLAYBACK_STATE);
Version(1);
DontCatchExceptions();
}
/// <summary>
/// Updates the playback state the player reported for the current user automatically.
/// </summary>
/// <param name="request">The request containing the latest playback state of the current user.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(UpdatePlaybackStateRequest request, CancellationToken cancellationToken)
{
Result<Updated> result = await _updatePlaybackStateCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -0,0 +1,87 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.UsersManagement.Settings;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Settings.UpdatePlaybackState;
/// <summary>
/// Class used for providing a textual description for the <see cref="UpdatePlaybackStateEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdatePlaybackStateEndpointSummary : Summary<UpdatePlaybackStateEndpoint, UpdatePlaybackStateRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="UpdatePlaybackStateEndpointSummary"/> class.
/// </summary>
public UpdatePlaybackStateEndpointSummary()
{
Summary = "Updates the playback state the player reported for the current user.";
Description = "Updates the last volume and mute state the player reported for the current user. This is written automatically by the player and is not part of the settings the user edits. When no settings are stored for the user yet, they are created with the provided playback state.";
ExampleRequest = new UpdatePlaybackStateRequest(
Volume: 0.75,
IsMuted: false
);
RequestParam(r => r.Volume, "The last volume the player reported, as a value between 0 and 1. Required.");
RequestParam(r => r.IsMuted, "The last mute state the player reported. Required.");
Response(200, "The playback state of the current user was successfully updated.");
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Authentication failed",
instance = "/api/v1/users/me/settings/playback-state"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token has expired",
instance = "/api/v1/users/me/settings/playback-state"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/users/me/settings/playback-state"
}
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/users/me/settings/playback-state",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"VolumeCannotBeNull",
"VolumeMustBeBetweenZeroAndOne",
"IsMutedCannotBeNull"
}
}
},
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
}
);
}
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.UsersManagement.Settings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -29,7 +30,12 @@ public class UpdateUserSettingsEndpointSummary : Summary<UpdateUserSettingsEndpo
ShouldAggregateMetadataWhenMissing: false,
ShouldAggregateArtworkWhenMissing: false,
ShouldRenderPdfAsImages: false,
ShouldPreserveBookStyles: true
ShouldPreserveBookStyles: true,
ShouldKeepDownloadingWhilePaused: true,
ShouldAutoplay: true,
IsGaplessPlaybackEnabled: true,
ReplayGainMode: ReplayGainMode.Off,
StreamingQuality: PlaybackStreamingQuality.Auto
);
RequestParam(r => r.IsPaginationEnabled, "Whether pagination is enabled for the user, or not. Required.");
@@ -40,6 +46,11 @@ public class UpdateUserSettingsEndpointSummary : Summary<UpdateUserSettingsEndpo
RequestParam(r => r.ShouldAggregateArtworkWhenMissing, "Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. Required.");
RequestParam(r => r.ShouldRenderPdfAsImages, "Whether PDF books are rendered as page images for the user, or not. Required.");
RequestParam(r => r.ShouldPreserveBookStyles, "Whether the styles of the book content are preserved when it is rendered for the user, or not. Required.");
RequestParam(r => r.ShouldKeepDownloadingWhilePaused, "Whether the player keeps downloading a track while playback is paused, or not. Required.");
RequestParam(r => r.ShouldAutoplay, "Whether the player continues playback at the end of an album or artist, or not. Required.");
RequestParam(r => r.IsGaplessPlaybackEnabled, "Whether the player transitions between consecutive tracks without a gap, or not. Required.");
RequestParam(r => r.ReplayGainMode, "The way ReplayGain normalization is applied to the tracks the user plays. Required.");
RequestParam(r => r.StreamingQuality, "The quality cap applied to the audio the server normalizes for the user. Required.");
Response(200, "The settings of the current user were successfully updated.");
@@ -86,7 +97,14 @@ public class UpdateUserSettingsEndpointSummary : Summary<UpdateUserSettingsEndpo
{
"General.Validation", new[]
{
"ItemsPerPageMustBeGreaterThanZero"
"ItemsPerPageMustBeGreaterThanZero",
"ShouldKeepDownloadingWhilePausedCannotBeNull",
"ShouldAutoplayCannotBeNull",
"IsGaplessPlaybackEnabledCannotBeNull",
"ReplayGainModeCannotBeNull",
"StreamingQualityCannotBeNull",
"InvalidReplayGainMode",
"InvalidStreamingQuality"
}
}
},
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.UsersManagement;
/// <summary>
/// Data transfer object for the playback state a user last reported to the player. The player writes these values automatically, and they are not part of the settings the user edits.
/// </summary>
[DebuggerDisplay("Volume: {Volume}; IsMuted: {IsMuted}")]
public class PlaybackStateDto
{
/// <summary>
/// Gets or sets the last volume the player reported, as a value between 0 and 1.
/// </summary>
public double? Volume { get; set; }
/// <summary>
/// Gets or sets the last mute state the player reported.
/// </summary>
public bool? IsMuted { get; set; }
}
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
using System;
using System.Diagnostics;
#endregion
@@ -58,4 +59,29 @@ public class UserSettingsDto
/// external servers, which those servers could observe; stripping them removes that possibility, at the cost of the look of the book.
/// </summary>
public bool ShouldPreserveBookStyles { get; set; }
/// <summary>
/// Gets or sets whether the player keeps downloading a track while playback is paused, or not, up to the entire file.
/// </summary>
public bool? ShouldKeepDownloadingWhilePaused { get; set; }
/// <summary>
/// Gets or sets whether the player continues playback at the end of an album or artist, or not.
/// </summary>
public bool? ShouldAutoplay { get; set; }
/// <summary>
/// Gets or sets whether the player transitions between consecutive tracks without a gap, or not.
/// </summary>
public bool? IsGaplessPlaybackEnabled { get; set; }
/// <summary>
/// Gets or sets the way ReplayGain normalization is applied to the tracks the user plays.
/// </summary>
public ReplayGainMode? ReplayGainMode { get; set; }
/// <summary>
/// Gets or sets the quality cap applied to the audio the server normalizes for the user.
/// </summary>
public PlaybackStreamingQuality? StreamingQuality { get; set; }
}
@@ -0,0 +1,35 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Enums.AudioLibrary;
/// <summary>
/// Enumeration for the quality cap applied to the audio the server normalizes (remuxes or transcodes) for a user.
/// </summary>
/// <remarks>
/// The caps apply only to audio the server has to change; a track that is played directly is always delivered as it was stored.
/// </remarks>
[DebuggerDisplay("{ToString()}")]
public enum PlaybackStreamingQuality
{
/// <summary>
/// The server chooses the quality, with no explicit cap.
/// </summary>
Auto,
/// <summary>
/// Normalized audio is capped at 96 kbps.
/// </summary>
Low,
/// <summary>
/// Normalized audio is capped at 160 kbps.
/// </summary>
Medium,
/// <summary>
/// Normalized audio is capped at 320 kbps.
/// </summary>
High,
}
@@ -0,0 +1,28 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Enums.AudioLibrary;
/// <summary>
/// Enumeration for the ways ReplayGain normalization is applied to the tracks a user plays.
/// </summary>
[DebuggerDisplay("{ToString()}")]
public enum ReplayGainMode
{
/// <summary>
/// ReplayGain is not applied. Tracks play at the loudness at which they were stored.
/// </summary>
Off,
/// <summary>
/// Each track is normalized using its own ReplayGain track gain, so tracks from different albums play at a similar loudness.
/// </summary>
Track,
/// <summary>
/// Each track is normalized using the ReplayGain album gain of the album it belongs to, so an album keeps its relative loudness
/// while albums play at a similar loudness to each other.
/// </summary>
Album,
}
@@ -12,5 +12,7 @@ public static partial class ApiRoutes
{
public const string GET_USER_SETTINGS = "users/me/settings";
public const string UPDATE_USER_SETTINGS = "users/me/settings";
public const string GET_PLAYBACK_STATE = "users/me/settings/playback-state";
public const string UPDATE_PLAYBACK_STATE = "users/me/settings/playback-state";
}
}
@@ -13,5 +13,7 @@ public static partial class WebRoutes
public const string INDEX = "{culture}/tools/settings";
public const string GET_USER_SETTINGS = "{culture}/tools/settings/api-get-user-settings";
public const string UPDATE_USER_SETTINGS = "{culture}/tools/settings/api-update-user-settings";
public const string GET_PLAYBACK_STATE = "{culture}/tools/settings/api-get-playback-state";
public const string UPDATE_PLAYBACK_STATE = "{culture}/tools/settings/api-update-playback-state";
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Common;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Tools.Settings.GetPlaybackState;
/// <summary>
/// API endpoint for the <c>/{culture}/tools/settings/api-get-playback-state</c> route.
/// </summary>
public class GetPlaybackStateEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
private readonly IApiHttpClient _apiHttpClient;
/// <summary>
/// Initializes a new instance of the <see cref="GetPlaybackStateEndpoint"/> class.
/// </summary>
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
public GetPlaybackStateEndpoint(IApiHttpClient apiHttpClient)
{
_apiHttpClient = apiHttpClient;
}
/// <summary>
/// Configures the endpoint.
/// </summary>
public override void Configure()
{
base.Configure();
Verbs(Http.GET);
Routes(WebRoutes.Settings.GET_PLAYBACK_STATE);
DontAutoTag();
Options(options => options.WithTags("Settings"));
}
/// <summary>
/// Retrieves the playback state the player reported for the current user automatically.
/// </summary>
/// <param name="request">The request object.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
{
PlaybackStateDto response = await _apiHttpClient.GetAsync<PlaybackStateDto>(ApiRoutes.Users.GET_PLAYBACK_STATE, cancellationToken).ConfigureAwait(false);
return JsonSuccess(response);
}
}
@@ -0,0 +1,26 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.DTO.Common;
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Tools.Settings.GetPlaybackState;
/// <summary>
/// Class used for providing a textual description for the <see cref="GetPlaybackStateEndpoint"/> endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetPlaybackStateEndpointSummary : Summary<GetPlaybackStateEndpoint, EmptyRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetPlaybackStateEndpointSummary"/> class.
/// </summary>
public GetPlaybackStateEndpointSummary()
{
Summary = "Retrieves the playback state the player reported for the current user.";
Description = "Retrieves the last volume and mute state the player reported for the current user. These values are not part of the settings the user edits.";
Response(200, "The playback state of the current user is returned.", example: new SuccessResponse<PlaybackStateDto>(true, default));
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Common;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Tools.Settings.UpdatePlaybackState;
/// <summary>
/// API endpoint for the <c>/{culture}/tools/settings/api-update-playback-state</c> route.
/// </summary>
public class UpdatePlaybackStateEndpoint : BaseEndpoint<PlaybackStateDto, IResult>
{
private readonly IApiHttpClient _apiHttpClient;
/// <summary>
/// Initializes a new instance of the <see cref="UpdatePlaybackStateEndpoint"/> class.
/// </summary>
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
public UpdatePlaybackStateEndpoint(IApiHttpClient apiHttpClient)
{
_apiHttpClient = apiHttpClient;
}
/// <summary>
/// Configures the endpoint.
/// </summary>
public override void Configure()
{
base.Configure();
Verbs(Http.POST);
Routes(WebRoutes.Settings.UPDATE_PLAYBACK_STATE);
DontAutoTag();
Options(options => options.WithTags("Settings"));
EnableAntiforgery();
}
/// <summary>
/// Updates the playback state the player reported for the current user automatically.
/// </summary>
/// <param name="request">The request containing the latest playback state of the current user.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(PlaybackStateDto request, CancellationToken cancellationToken)
{
await _apiHttpClient.PutAsync<Web.Common.Requests.Common.EmptyRequest, PlaybackStateDto>(ApiRoutes.Users.UPDATE_PLAYBACK_STATE, request, cancellationToken).ConfigureAwait(false);
return JsonSuccess(new { isUpdated = true });
}
}
@@ -0,0 +1,30 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Tools.Settings.UpdatePlaybackState;
/// <summary>
/// Class used for providing a textual description for the <see cref="UpdatePlaybackStateEndpoint"/> endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdatePlaybackStateEndpointSummary : Summary<UpdatePlaybackStateEndpoint, PlaybackStateDto>
{
/// <summary>
/// Initializes a new instance of the <see cref="UpdatePlaybackStateEndpointSummary"/> class.
/// </summary>
public UpdatePlaybackStateEndpointSummary()
{
Summary = "Updates the playback state the player reported for the current user.";
Description = "Updates the last volume and mute state the player reported for the current user. This is written automatically by the player and is not part of the settings the user edits.";
RequestParam(r => r.Volume, "The last volume the player reported, as a value between 0 and 1. Required.");
RequestParam(r => r.IsMuted, "The last mute state the player reported. Required.");
ExampleRequest = new PlaybackStateDto { Volume = 1.0, IsMuted = false };
Response(200, "The playback state of the current user is updated.", example: new { success = true, data = new { isUpdated = true } });
}
}
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>نوع الجدول غير صالح!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>وضع ReplayGain غير صالح!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>جودة البث غير صالحة!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>لا يمكن أن تكون حالة الكتم فارغة!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>لا يمكن أن يكون مستوى الصوت فارغًا!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>يجب أن يكون مستوى الصوت بين 0 و 1!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>لا يمكن أن يكون إعداد متابعة التنزيل أثناء الإيقاف المؤقت فارغًا!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>لا يمكن أن يكون إعداد التشغيل التلقائي فارغًا!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>لا يمكن أن يكون إعداد التشغيل دون فواصل فارغًا!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>لا يمكن أن يكون وضع ReplayGain فارغًا!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>لا يمكن أن تكون جودة البث فارغة!</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>Der Zeitplantyp ist ungültig!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>Ungültiger ReplayGain-Modus!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>Ungültige Streaming-Qualität!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>Der Stummschaltungsstatus darf nicht null sein!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>Die Lautstärke darf nicht null sein!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>Die Lautstärke muss zwischen 0 und 1 liegen!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>Die Einstellung zum Weiterherunterladen beim Pausieren darf nicht null sein!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>Die Einstellung für die automatische Wiedergabe darf nicht null sein!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>Die Einstellung für die lückenlose Wiedergabe darf nicht null sein!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>Der ReplayGain-Modus darf nicht null sein!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>Die Streaming-Qualität darf nicht null sein!</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>The schedule type is invalid!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>Invalid ReplayGain mode!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>Invalid streaming quality!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>The mute state cannot be null!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>The volume cannot be null!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>The volume must be between 0 and 1!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>The keep-downloading-while-paused preference cannot be null!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>The autoplay preference cannot be null!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>The gapless playback preference cannot be null!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>The ReplayGain mode cannot be null!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>The streaming quality cannot be null!</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>El tipo de programación no es válido!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>¡Modo ReplayGain no válido!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>¡Calidad de transmisión no válida!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>¡El estado de silencio no puede ser nulo!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>¡El volumen no puede ser nulo!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>¡El volumen debe estar entre 0 y 1!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>¡La preferencia de seguir descargando en pausa no puede ser nula!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>¡La preferencia de reproducción automática no puede ser nula!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>¡La preferencia de reproducción sin pausas no puede ser nula!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>¡El modo ReplayGain no puede ser nulo!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>¡La calidad de transmisión no puede ser nula!</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>Le type de planification n'est pas valide !</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>Mode ReplayGain non valide !</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>Qualité de diffusion non valide !</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>L'état de sourdine ne peut pas être nul !</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>Le volume ne peut pas être nul !</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>Le volume doit être compris entre 0 et 1 !</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>La préférence de téléchargement en pause ne peut pas être nulle !</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>La préférence de lecture automatique ne peut pas être nulle !</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>La préférence de lecture sans interruption ne peut pas être nulle !</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>Le mode ReplayGain ne peut pas être nul !</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>La qualité de diffusion ne peut pas être nulle !</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>Il tipo di pianificazione non è valido!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>Modalità ReplayGain non valida!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>Qualità dello streaming non valida!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>Lo stato di silenziamento non può essere nullo!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>Il volume non può essere nullo!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>Il volume deve essere compreso tra 0 e 1!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>La preferenza di continuare il download in pausa non può essere nulla!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>La preferenza di riproduzione automatica non può essere nulla!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>La preferenza di riproduzione senza interruzioni non può essere nulla!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>La modalità ReplayGain non può essere nulla!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>La qualità dello streaming non può essere nulla!</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>スケジュールタイプが無効です!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>ReplayGain モードが無効です。</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>ストリーミング品質が無効です。</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>ミュート状態は null にできません。</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>音量は null にできません。</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>音量は 0 から 1 の間でなければなりません。</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>一時停止中のダウンロード継続の設定は null にできません。</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>自動再生の設定は null にできません。</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>ギャップレス再生の設定は null にできません。</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>ReplayGain モードは null にできません。</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>ストリーミング品質は null にできません。</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>The schedule type is invalid!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>Invalid ReplayGain mode!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>Invalid streaming quality!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>The mute state cannot be null!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>The volume cannot be null!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>The volume must be between 0 and 1!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>The keep-downloading-while-paused preference cannot be null!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>The autoplay preference cannot be null!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>The gapless playback preference cannot be null!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>The ReplayGain mode cannot be null!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>The streaming quality cannot be null!</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>Tipul de programare este invalid!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>Mod ReplayGain invalid!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>Calitate de streaming invalidă!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>Starea de mut nu poate fi nulă!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>Volumul nu poate fi nul!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>Volumul trebuie să fie între 0 și 1!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>Preferința de a continua descărcarea în pauză nu poate fi nulă!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>Preferința de redare automată nu poate fi nulă!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>Preferința de redare fără întreruperi nu poate fi nulă!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>Modul ReplayGain nu poate fi nul!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>Calitatea fluxului nu poate fi nulă!</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>Тип розкладу недійсний!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>Неприпустимий режим ReplayGain!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>Неприпустима якість потокового передавання!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>Стан без звуку не може бути порожнім!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>Гучність не може бути порожньою!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>Гучність має бути між 0 і 1!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>Налаштування продовження завантаження на паузі не може бути порожнім!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>Налаштування автовідтворення не може бути порожнім!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>Налаштування відтворення без пауз не може бути порожнім!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>Режим ReplayGain не може бути порожнім!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>Якість потокового передавання не може бути порожньою!</value>
</data>
</root>
@@ -813,4 +813,34 @@
<data name="InvalidScheduleType" xml:space="preserve">
<value>调度类型无效!</value>
</data>
<data name="InvalidReplayGainMode" xml:space="preserve">
<value>无效的 ReplayGain 模式!</value>
</data>
<data name="InvalidStreamingQuality" xml:space="preserve">
<value>无效的流媒体质量!</value>
</data>
<data name="IsMutedCannotBeNull" xml:space="preserve">
<value>静音状态不能为空!</value>
</data>
<data name="VolumeCannotBeNull" xml:space="preserve">
<value>音量不能为空!</value>
</data>
<data name="VolumeMustBeBetweenZeroAndOne" xml:space="preserve">
<value>音量必须介于 0 和 1 之间!</value>
</data>
<data name="ShouldKeepDownloadingWhilePausedCannotBeNull" xml:space="preserve">
<value>暂停时继续下载的偏好设置不能为空!</value>
</data>
<data name="ShouldAutoplayCannotBeNull" xml:space="preserve">
<value>自动播放的偏好设置不能为空!</value>
</data>
<data name="IsGaplessPlaybackEnabledCannotBeNull" xml:space="preserve">
<value>无缝播放的偏好设置不能为空!</value>
</data>
<data name="ReplayGainModeCannotBeNull" xml:space="preserve">
<value>ReplayGain 模式不能为空!</value>
</data>
<data name="StreamingQualityCannotBeNull" xml:space="preserve">
<value>流媒体质量不能为空!</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>عند التفعيل، تُستكمل الأعمال الفنية لعناصر المكتبة التي لا يوفرها مزود الأعمال الفنية الأول من المزودين التاليين.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>التشغيل</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>متابعة التنزيل أثناء الإيقاف المؤقت</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>ما إذا كان المشغل يواصل تنزيل المقطع أثناء إيقاف التشغيل مؤقتًا، حتى الملف كاملاً، بحيث لا ينتظر الاستئناف البيانات أبدًا.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>التشغيل التلقائي</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>ما إذا كان التشغيل يستمر تلقائيًا بالمقاطع التالية عند انتهاء الألبوم أو الفنان.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>تشغيل دون فواصل</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>ما إذا كانت المقاطع المتتالية تُشغَّل دون صمت بينها.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>كيفية تطبيق تسوية ReplayGain على المقاطع التي تشغّلها.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>إيقاف</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>لكل مقطع</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>لكل ألبوم</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>جودة البث</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>حد الجودة الذي يُطبَّق عندما يضطر الخادم إلى تسوية مقطع للتشغيل. لا يتغير التشغيل المباشر أبدًا.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>تلقائي</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>منخفضة (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>متوسطة (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>عالية (320 kbps)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>Wenn aktiviert, wird das Artwork von Bibliothekselementen, das der erste Artwork-Anbieter nicht liefert, aus den nachfolgenden Anbietern ergänzt.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>Wiedergabe</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Beim Pausieren weiter herunterladen</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Ob der Player den Titel auch bei pausierter Wiedergabe weiter herunterlädt, bis zur gesamten Datei, damit die Fortsetzung nie auf Daten warten muss.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>Automatische Wiedergabe</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>Ob die Wiedergabe am Ende eines Albums oder Interpreten automatisch mit den folgenden Titeln fortgesetzt wird.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>Lückenlose Wiedergabe</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>Ob aufeinanderfolgende Titel ohne stille Lücke zwischen ihnen abgespielt werden.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>Wie die ReplayGain-Normalisierung auf die abgespielten Titel angewendet wird.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>Aus</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>Pro Titel</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>Pro Album</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>Streaming-Qualität</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>Die Qualitätsobergrenze, die angewendet wird, wenn der Server einen Titel für die Wiedergabe normalisieren muss. Die direkte Wiedergabe wird nie verändert.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>Automatisch</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>Niedrig (96 kbit/s)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>Mittel (160 kbit/s)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>Hoch (320 kbit/s)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>When enabled, the artwork of library items that the first artwork provider does not supply is filled in from the following providers.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>Playback</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Keep downloading while paused</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Whether the player keeps downloading the track while playback is paused, up to the entire file, so resuming never waits for data.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>Autoplay</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>Whether playback continues automatically with the following tracks when an album or artist finishes.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>Gapless playback</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>Whether consecutive tracks play without a silent gap between them.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>How ReplayGain normalization is applied to the tracks you play.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>Off</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>Per track</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>Per album</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>Streaming quality</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>The quality cap applied when the server has to normalize a track for playback. Direct playback is never changed.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>Automatic</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>Low (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>Medium (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>High (320 kbps)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>Cuando está habilitado, las ilustraciones de los elementos de la biblioteca que el primer proveedor de ilustraciones no proporciona se completan desde los proveedores siguientes.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>Reproducción</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Seguir descargando en pausa</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Indica si el reproductor sigue descargando la pista mientras la reproducción está en pausa, hasta el archivo completo, para que reanudar nunca espere datos.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>Reproducción automática</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>Indica si la reproducción continúa automáticamente con las pistas siguientes al terminar un álbum o un artista.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>Reproducción sin pausas</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>Indica si las pistas consecutivas se reproducen sin un silencio entre ellas.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>Cómo se aplica la normalización ReplayGain a las pistas que reproduces.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>Desactivado</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>Por pista</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>Por álbum</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>Calidad de transmisión</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>El límite de calidad que se aplica cuando el servidor tiene que normalizar una pista para reproducirla. La reproducción directa nunca se modifica.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>Automática</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>Baja (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>Media (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>Alta (320 kbps)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>Lorsque cette option est activée, les illustrations des éléments de la bibliothèque que le premier fournisseur d'illustrations ne fournit pas sont complétées par les fournisseurs suivants.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>Lecture</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Continuer le téléchargement en pause</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Indique si le lecteur continue de télécharger le morceau lorsque la lecture est en pause, jusqu'au fichier entier, afin que la reprise n'attende jamais les données.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>Lecture automatique</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>Indique si la lecture se poursuit automatiquement avec les morceaux suivants à la fin d'un album ou d'un artiste.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>Lecture sans interruption</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>Indique si les morceaux consécutifs sont lus sans silence entre eux.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>La manière dont la normalisation ReplayGain est appliquée aux morceaux que vous écoutez.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>Désactivé</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>Par morceau</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>Par album</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>Qualité de diffusion</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>Le plafond de qualité appliqué lorsque le serveur doit normaliser un morceau pour la lecture. La lecture directe n'est jamais modifiée.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>Automatique</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>Basse (96 kbit/s)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>Moyenne (160 kbit/s)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>Élevée (320 kbit/s)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>Se abilitato, le illustrazioni degli elementi della libreria che il primo provider di illustrazioni non fornisce vengono integrate dai provider successivi.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>Riproduzione</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Continua il download in pausa</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Indica se il lettore continua a scaricare il brano mentre la riproduzione è in pausa, fino all'intero file, così che la ripresa non debba mai attendere i dati.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>Riproduzione automatica</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>Indica se la riproduzione continua automaticamente con i brani successivi al termine di un album o di un artista.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>Riproduzione senza interruzioni</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>Indica se i brani consecutivi vengono riprodotti senza un silenzio tra loro.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>Come la normalizzazione ReplayGain viene applicata ai brani che riproduci.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>Disattivato</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>Per brano</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>Per album</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>Qualità dello streaming</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>Il limite di qualità applicato quando il server deve normalizzare un brano per la riproduzione. La riproduzione diretta non viene mai modificata.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>Automatica</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>Bassa (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>Media (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>Alta (320 kbps)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>有効にすると、最初のアートワークプロバイダーが提供しないライブラリ項目のアートワークが、後続のプロバイダーから補完されます。</value>
</data>
<data name="Playback" xml:space="preserve">
<value>再生</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>一時停止中もダウンロードを続ける</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>再生を一時停止している間もプレーヤーがトラックのダウンロードをファイル全体まで続けるかどうか。再開時にデータを待たずに済みます。</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>自動再生</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>アルバムまたはアーティストの再生が終わったときに、続くトラックを自動的に再生するかどうか。</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>ギャップレス再生</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>連続するトラックを間に無音を挟まずに再生するかどうか。</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>再生するトラックに ReplayGain の正規化をどのように適用するか。</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>オフ</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>トラックごと</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>アルバムごと</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>ストリーミング品質</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>サーバーが再生のためにトラックを正規化する必要がある場合に適用される品質の上限。直接再生は決して変更されません。</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>自動</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>低 (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>中 (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>高 (320 kbps)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>When enabled, the artwork of library items that the first artwork provider does not supply is filled in from the following providers.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>Playback</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Keep downloading while paused</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Whether the player keeps downloading the track while playback is paused, up to the entire file, so resuming never waits for data.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>Autoplay</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>Whether playback continues automatically with the following tracks when an album or artist finishes.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>Gapless playback</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>Whether consecutive tracks play without a silent gap between them.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>How ReplayGain normalization is applied to the tracks you play.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>Off</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>Per track</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>Per album</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>Streaming quality</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>The quality cap applied when the server has to normalize a track for playback. Direct playback is never changed.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>Automatic</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>Low (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>Medium (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>High (320 kbps)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>Când este activat, ilustrațiile elementelor din bibliotecă pe care primul furnizor de ilustrații nu le oferă sunt completate de la furnizorii următori.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>Redare</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Continuă descărcarea în pauză</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Dacă playerul continuă să descarce piesa în timp ce redarea este în pauză, până la întregul fișier, astfel încât reluarea să nu aștepte niciodată datele.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>Redare automată</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>Dacă redarea continuă automat cu piesele următoare la sfârșitul unui album sau al unui artist.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>Redare fără întreruperi</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>Dacă piesele consecutive sunt redate fără o pauză de sunet între ele.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>Modul în care normalizarea ReplayGain este aplicată pieselor pe care le redai.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>Dezactivat</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>Per piesă</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>Per album</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>Calitatea fluxului</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>Limita de calitate aplicată atunci când serverul trebuie să normalizeze o piesă pentru redare. Redarea directă nu este niciodată modificată.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>Automată</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>Redusă (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>Medie (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>Ridicată (320 kbps)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>Коли ввімкнено, ілюстрації елементів бібліотеки, які не надає перший постачальник ілюстрацій, доповнюються від наступних постачальників.</value>
</data>
<data name="Playback" xml:space="preserve">
<value>Відтворення</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Продовжувати завантаження на паузі</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>Чи продовжує програвач завантажувати трек, поки відтворення призупинено, аж до всього файлу, щоб відновлення ніколи не чекало на дані.</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>Автовідтворення</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>Чи продовжується відтворення автоматично наступними треками після завершення альбому або виконавця.</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>Відтворення без пауз</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>Чи відтворюються послідовні треки без тихої паузи між ними.</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>Як нормалізація ReplayGain застосовується до треків, які ви відтворюєте.</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>Вимкнено</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>Для кожного треку</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>Для кожного альбому</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>Якість потокового передавання</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>Обмеження якості, що застосовується, коли сервер має нормалізувати трек для відтворення. Пряме відтворення ніколи не змінюється.</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>Автоматично</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>Низька (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>Середня (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>Висока (320 kbps)</value>
</data>
</root>
@@ -69,4 +69,58 @@
<data name="DescriptionShouldAggregateArtworkWhenMissing" xml:space="preserve">
<value>启用后,首个图片提供程序未提供的媒体库项目图片将由后续提供程序补齐。</value>
</data>
<data name="Playback" xml:space="preserve">
<value>播放</value>
</data>
<data name="ShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>暂停时继续下载</value>
</data>
<data name="DescriptionShouldKeepDownloadingWhilePaused" xml:space="preserve">
<value>播放暂停时播放器是否继续下载曲目直到整个文件,这样恢复播放时无需等待数据。</value>
</data>
<data name="ShouldAutoplay" xml:space="preserve">
<value>自动播放</value>
</data>
<data name="DescriptionShouldAutoplay" xml:space="preserve">
<value>专辑或艺术家播放结束后是否自动继续播放后续曲目。</value>
</data>
<data name="IsGaplessPlaybackEnabled" xml:space="preserve">
<value>无缝播放</value>
</data>
<data name="DescriptionIsGaplessPlaybackEnabled" xml:space="preserve">
<value>连续曲目之间是否无静默间隔地播放。</value>
</data>
<data name="ReplayGainMode" xml:space="preserve">
<value>ReplayGain</value>
</data>
<data name="DescriptionReplayGainMode" xml:space="preserve">
<value>如何对您播放的曲目应用 ReplayGain 音量标准化。</value>
</data>
<data name="ReplayGainModeOff" xml:space="preserve">
<value>关闭</value>
</data>
<data name="ReplayGainModeTrack" xml:space="preserve">
<value>按曲目</value>
</data>
<data name="ReplayGainModeAlbum" xml:space="preserve">
<value>按专辑</value>
</data>
<data name="StreamingQuality" xml:space="preserve">
<value>流媒体质量</value>
</data>
<data name="DescriptionStreamingQuality" xml:space="preserve">
<value>当服务器需要为播放对曲目进行标准化时应用的质量上限。直接播放永远不会被更改。</value>
</data>
<data name="StreamingQualityAuto" xml:space="preserve">
<value>自动</value>
</data>
<data name="StreamingQualityLow" xml:space="preserve">
<value>低 (96 kbps)</value>
</data>
<data name="StreamingQualityMedium" xml:space="preserve">
<value>中 (160 kbps)</value>
</data>
<data name="StreamingQualityHigh" xml:space="preserve">
<value>高 (320 kbps)</value>
</data>
</root>
@@ -130,6 +130,78 @@
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionShouldAggregateArtworkWhenMissing"]</small>
</div>
<!-- Playback. -->
<div class="form-row">
<h4 class="text-light-two w-100">@_localizer["Playback"]</h4>
</div>
<!-- Keep downloading while paused. -->
<div class="form-row">
<div class="form-label">
<label for="ShouldKeepDownloadingWhilePaused">@_localizer["ShouldKeepDownloadingWhilePaused"]</label>:
</div>
<div class="form-field">
<label class="enlightenment-checkbox-label">
<input type="checkbox" id="ShouldKeepDownloadingWhilePaused" class="enlightenment-checkbox-hidden" />
<span class="enlightenment-checkbox"></span>
</label>
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionShouldKeepDownloadingWhilePaused"]</small>
</div>
<!-- Autoplay. -->
<div class="form-row">
<div class="form-label">
<label for="ShouldAutoplay">@_localizer["ShouldAutoplay"]</label>:
</div>
<div class="form-field">
<label class="enlightenment-checkbox-label">
<input type="checkbox" id="ShouldAutoplay" class="enlightenment-checkbox-hidden" />
<span class="enlightenment-checkbox"></span>
</label>
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionShouldAutoplay"]</small>
</div>
<!-- Gapless playback. -->
<div class="form-row">
<div class="form-label">
<label for="IsGaplessPlaybackEnabled">@_localizer["IsGaplessPlaybackEnabled"]</label>:
</div>
<div class="form-field">
<label class="enlightenment-checkbox-label">
<input type="checkbox" id="IsGaplessPlaybackEnabled" class="enlightenment-checkbox-hidden" />
<span class="enlightenment-checkbox"></span>
</label>
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionIsGaplessPlaybackEnabled"]</small>
</div>
<!-- ReplayGain mode. -->
<div class="form-row">
<div class="form-label">
<label asp-for="ReplayGainMode">@_localizer["ReplayGainMode"]</label>:
</div>
<div class="form-field">
<select asp-for="ReplayGainMode" class="enlightenment-input">
<option value="Off">@_localizer["ReplayGainModeOff"]</option>
<option value="Track">@_localizer["ReplayGainModeTrack"]</option>
<option value="Album">@_localizer["ReplayGainModeAlbum"]</option>
</select>
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionReplayGainMode"]</small>
</div>
<!-- Streaming quality. -->
<div class="form-row">
<div class="form-label">
<label asp-for="StreamingQuality">@_localizer["StreamingQuality"]</label>:
</div>
<div class="form-field">
<select asp-for="StreamingQuality" class="enlightenment-input">
<option value="Auto">@_localizer["StreamingQualityAuto"]</option>
<option value="Low">@_localizer["StreamingQualityLow"]</option>
<option value="Medium">@_localizer["StreamingQualityMedium"]</option>
<option value="High">@_localizer["StreamingQualityHigh"]</option>
</select>
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionStreamingQuality"]</small>
</div>
<div class="form-row" style="justify-content: center;">
<button type="submit" class="confirm-button h-22px">@_localizer["Save"]</button>
</div>
@@ -154,6 +226,11 @@
const checkboxShouldPreserveBookStyles = document.getElementById('ShouldPreserveBookStyles');
const checkboxShouldAggregateMetadataWhenMissing = document.getElementById('ShouldAggregateMetadataWhenMissing');
const checkboxShouldAggregateArtworkWhenMissing = document.getElementById('ShouldAggregateArtworkWhenMissing');
const checkboxShouldKeepDownloadingWhilePaused = document.getElementById('ShouldKeepDownloadingWhilePaused');
const checkboxShouldAutoplay = document.getElementById('ShouldAutoplay');
const checkboxIsGaplessPlaybackEnabled = document.getElementById('IsGaplessPlaybackEnabled');
const selectReplayGainMode = document.getElementById('ReplayGainMode');
const selectStreamingQuality = document.getElementById('StreamingQuality');
// Toggle the enabled state of the items per page input based on the pagination checkbox.
function updateItemsPerPageEnabledState() {
@@ -172,6 +249,11 @@
checkboxShouldPreserveBookStyles.checked = data.shouldPreserveBookStyles === true;
checkboxShouldAggregateMetadataWhenMissing.checked = data.shouldAggregateMetadataWhenMissing === true;
checkboxShouldAggregateArtworkWhenMissing.checked = data.shouldAggregateArtworkWhenMissing === true;
checkboxShouldKeepDownloadingWhilePaused.checked = data.shouldKeepDownloadingWhilePaused === true;
checkboxShouldAutoplay.checked = data.shouldAutoplay === true;
checkboxIsGaplessPlaybackEnabled.checked = data.isGaplessPlaybackEnabled === true;
selectReplayGainMode.value = data.replayGainMode ?? 'Off';
selectStreamingQuality.value = data.streamingQuality ?? 'Auto';
updateItemsPerPageEnabledState();
}
}
@@ -186,7 +268,12 @@
ShouldAggregateMetadataWhenMissing: checkboxShouldAggregateMetadataWhenMissing.checked,
ShouldAggregateArtworkWhenMissing: checkboxShouldAggregateArtworkWhenMissing.checked,
ShouldRenderPdfAsImages: checkboxShouldRenderPdfAsImages.checked,
ShouldPreserveBookStyles: checkboxShouldPreserveBookStyles.checked
ShouldPreserveBookStyles: checkboxShouldPreserveBookStyles.checked,
ShouldKeepDownloadingWhilePaused: checkboxShouldKeepDownloadingWhilePaused.checked,
ShouldAutoplay: checkboxShouldAutoplay.checked,
IsGaplessPlaybackEnabled: checkboxIsGaplessPlaybackEnabled.checked,
ReplayGainMode: selectReplayGainMode.value,
StreamingQuality: selectStreamingQuality.value
};
const data = await callApiPostAsync('@_urlService.GetAbsoluteUrl(WebRoutes.Settings.UPDATE_USER_SETTINGS)', formData);
if (data && data.isUpdated === true)
+2
View File
@@ -412,7 +412,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "authorization", "authorizat
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "settings", "settings", "{240E1B2A-08A3-439D-B8B2-4D9C18B4AF8A}"
ProjectSection(SolutionItems) = preProject
..\docs\technical\requests\users-management\settings\GetPlaybackState.http = ..\docs\technical\requests\users-management\settings\GetPlaybackState.http
..\docs\technical\requests\users-management\settings\GetUserSettings.http = ..\docs\technical\requests\users-management\settings\GetUserSettings.http
..\docs\technical\requests\users-management\settings\UpdatePlaybackState.http = ..\docs\technical\requests\users-management\settings\UpdatePlaybackState.http
..\docs\technical\requests\users-management\settings\UpdateUserSettings.http = ..\docs\technical\requests\users-management\settings\UpdateUserSettings.http
EndProjectSection
EndProject
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -27,6 +28,13 @@ public class UserSettingsEntityFixture
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Optional. Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="shouldAutoplay">Optional. Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="isGaplessPlaybackEnabled">Optional. Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="replayGainMode">Optional. The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">Optional. The quality cap applied to the audio the server normalizes for the user.</param>
/// <param name="volume">Optional. The last volume the player reported for the user.</param>
/// <param name="isMuted">Optional. The last mute state the player reported for the user.</param>
/// <returns>The created user settings entity.</returns>
public UserSettingsEntity Create(
Guid? id = null,
@@ -37,7 +45,14 @@ public class UserSettingsEntityFixture
bool? isThemeCachingEnabled = null,
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null,
double? volume = null,
bool? isMuted = null)
{
return new Faker<UserSettingsEntity>()
.CustomInstantiator(f => new UserSettingsEntity
@@ -50,7 +65,14 @@ public class UserSettingsEntityFixture
IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool(),
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool(),
ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? f.Random.Bool(),
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? f.Random.Bool()
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? f.Random.Bool(),
ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused ?? f.Random.Bool(),
ShouldAutoplay = shouldAutoplay ?? f.Random.Bool(),
IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled ?? f.Random.Bool(),
ReplayGainMode = replayGainMode ?? f.PickRandom<ReplayGainMode>(),
StreamingQuality = streamingQuality ?? f.PickRandom<PlaybackStreamingQuality>(),
Volume = volume ?? f.Random.Double(0.0, 1.0),
IsMuted = isMuted ?? f.Random.Bool()
})
.Generate();
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSettings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -25,6 +26,11 @@ public class UpdateUserSettingsCommandFixture
/// <param name="shouldAggregateArtworkWhenMissing">Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Optional. Whether the player keeps downloading a track while playback is paused, or not.</param>
/// <param name="shouldAutoplay">Optional. Whether the player continues playback at the end of an album or artist, or not.</param>
/// <param name="isGaplessPlaybackEnabled">Optional. Whether the player transitions between consecutive tracks without a gap, or not.</param>
/// <param name="replayGainMode">Optional. The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">Optional. The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>The created command.</returns>
public UpdateUserSettingsCommand Create(
bool? isPaginationEnabled = null,
@@ -34,10 +40,15 @@ public class UpdateUserSettingsCommandFixture
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldAggregateArtworkWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null)
{
return new Faker<UpdateUserSettingsCommand>()
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default, default))
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default, default, default, default, default, default, default, default, default))
.RuleFor(x => x.IsPaginationEnabled, f => isPaginationEnabled ?? f.Random.Bool())
.RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100))
.RuleFor(x => x.ShouldIgnoreThePrefixForAlphaPicker, f => shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool())
@@ -46,6 +57,11 @@ public class UpdateUserSettingsCommandFixture
.RuleFor(x => x.ShouldAggregateArtworkWhenMissing, f => shouldAggregateArtworkWhenMissing ?? f.Random.Bool())
.RuleFor(x => x.ShouldRenderPdfAsImages, f => shouldRenderPdfAsImages ?? f.Random.Bool())
.RuleFor(x => x.ShouldPreserveBookStyles, f => shouldPreserveBookStyles ?? f.Random.Bool())
.RuleFor(x => x.ShouldKeepDownloadingWhilePaused, f => shouldKeepDownloadingWhilePaused ?? f.Random.Bool())
.RuleFor(x => x.ShouldAutoplay, f => shouldAutoplay ?? f.Random.Bool())
.RuleFor(x => x.IsGaplessPlaybackEnabled, f => isGaplessPlaybackEnabled ?? f.Random.Bool())
.RuleFor(x => x.ReplayGainMode, f => replayGainMode ?? f.PickRandom<ReplayGainMode>())
.RuleFor(x => x.StreamingQuality, f => streamingQuality ?? f.PickRandom<PlaybackStreamingQuality>())
.Generate();
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.UsersManagement.Settings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -27,6 +28,11 @@ public class UpdateUserSettingsRequestFixture
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>The created <see cref="UpdateUserSettingsRequest"/>.</returns>
public UpdateUserSettingsRequest Create(
bool? isPaginationEnabled = null,
@@ -36,7 +42,12 @@ public class UpdateUserSettingsRequestFixture
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldAggregateArtworkWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null)
{
return new UpdateUserSettingsRequest(
isPaginationEnabled ?? _faker.Random.Bool(),
@@ -46,7 +57,12 @@ public class UpdateUserSettingsRequestFixture
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(),
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
shouldPreserveBookStyles ?? _faker.Random.Bool());
shouldPreserveBookStyles ?? _faker.Random.Bool(),
shouldKeepDownloadingWhilePaused ?? _faker.Random.Bool(),
shouldAutoplay ?? _faker.Random.Bool(),
isGaplessPlaybackEnabled ?? _faker.Random.Bool(),
replayGainMode ?? _faker.PickRandom<ReplayGainMode>(),
streamingQuality ?? _faker.PickRandom<PlaybackStreamingQuality>());
}
/// <summary>
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.UsersManagement.Settings;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -29,6 +30,11 @@ public class UserSettingsResponseFixture
/// <param name="shouldAggregateArtworkWhenMissing">Optional. Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Optional. Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Optional. Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Optional. Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Optional. Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Optional. Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">Optional. The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">Optional. The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>The created <see cref="UserSettingsResponse"/>.</returns>
public UserSettingsResponse Create(
Guid? userId = null,
@@ -39,7 +45,12 @@ public class UserSettingsResponseFixture
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldAggregateArtworkWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null)
{
return new UserSettingsResponse(
userId ?? Guid.NewGuid(),
@@ -50,7 +61,12 @@ public class UserSettingsResponseFixture
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
shouldAggregateArtworkWhenMissing ?? _faker.Random.Bool(),
shouldRenderPdfAsImages ?? _faker.Random.Bool(),
shouldPreserveBookStyles ?? _faker.Random.Bool());
shouldPreserveBookStyles ?? _faker.Random.Bool(),
shouldKeepDownloadingWhilePaused ?? _faker.Random.Bool(),
shouldAutoplay ?? _faker.Random.Bool(),
isGaplessPlaybackEnabled ?? _faker.Random.Bool(),
replayGainMode ?? _faker.PickRandom<ReplayGainMode>(),
streamingQuality ?? _faker.PickRandom<PlaybackStreamingQuality>());
}
/// <summary>
@@ -2,6 +2,7 @@
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -28,6 +29,13 @@ public class UserSettingsFixture
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <param name="volume">The last volume the player reported for the user.</param>
/// <param name="isMuted">The last mute state the player reported for the user.</param>
/// <returns>The created <see cref="UserSettings"/>.</returns>
public UserSettings Create(
Guid? userId = null,
@@ -38,7 +46,14 @@ public class UserSettingsFixture
bool shouldAggregateMetadataWhenMissing = false,
bool shouldAggregateArtworkWhenMissing = false,
bool shouldRenderPdfAsImages = false,
bool shouldPreserveBookStyles = true)
bool shouldPreserveBookStyles = true,
bool shouldKeepDownloadingWhilePaused = true,
bool shouldAutoplay = true,
bool isGaplessPlaybackEnabled = true,
ReplayGainMode replayGainMode = ReplayGainMode.Off,
PlaybackStreamingQuality streamingQuality = PlaybackStreamingQuality.Auto,
double volume = 1.0,
bool isMuted = false)
{
Result<UserSettings> settings = UserSettings.Create(
userId is null ? UserId.CreateUnique() : UserId.Create(userId.Value),
@@ -49,7 +64,14 @@ public class UserSettingsFixture
shouldAggregateMetadataWhenMissing,
shouldAggregateArtworkWhenMissing,
shouldRenderPdfAsImages,
shouldPreserveBookStyles);
shouldPreserveBookStyles,
shouldKeepDownloadingWhilePaused,
shouldAutoplay,
isGaplessPlaybackEnabled,
replayGainMode,
streamingQuality,
volume,
isMuted);
return settings.Value;
}
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
using Lumina.Presentation.Web.Common.Enums.AudioLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -28,6 +29,11 @@ public class UserSettingsDtoFixture
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user.</param>
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user.</param>
/// <param name="shouldKeepDownloadingWhilePaused">Whether the player keeps downloading a track while playback is paused.</param>
/// <param name="shouldAutoplay">Whether the player continues playback at the end of an album or artist.</param>
/// <param name="isGaplessPlaybackEnabled">Whether the player transitions between consecutive tracks without a gap.</param>
/// <param name="replayGainMode">The way ReplayGain normalization is applied to the tracks the user plays.</param>
/// <param name="streamingQuality">The quality cap applied to the audio the server normalizes for the user.</param>
/// <returns>A configured <see cref="UserSettingsDto"/> instance.</returns>
public UserSettingsDto Create(
Guid? userId = null,
@@ -37,7 +43,12 @@ public class UserSettingsDtoFixture
bool? isThemeCachingEnabled = null,
bool? shouldAggregateMetadataWhenMissing = null,
bool? shouldRenderPdfAsImages = null,
bool? shouldPreserveBookStyles = null)
bool? shouldPreserveBookStyles = null,
bool? shouldKeepDownloadingWhilePaused = null,
bool? shouldAutoplay = null,
bool? isGaplessPlaybackEnabled = null,
ReplayGainMode? replayGainMode = null,
PlaybackStreamingQuality? streamingQuality = null)
{
return new UserSettingsDto
{
@@ -48,7 +59,12 @@ public class UserSettingsDtoFixture
IsThemeCachingEnabled = isThemeCachingEnabled ?? _faker.Random.Bool(),
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool(),
ShouldRenderPdfAsImages = shouldRenderPdfAsImages ?? _faker.Random.Bool(),
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? _faker.Random.Bool()
ShouldPreserveBookStyles = shouldPreserveBookStyles ?? _faker.Random.Bool(),
ShouldKeepDownloadingWhilePaused = shouldKeepDownloadingWhilePaused ?? _faker.Random.Bool(),
ShouldAutoplay = shouldAutoplay ?? _faker.Random.Bool(),
IsGaplessPlaybackEnabled = isGaplessPlaybackEnabled ?? _faker.Random.Bool(),
ReplayGainMode = replayGainMode ?? _faker.PickRandom<ReplayGainMode>(),
StreamingQuality = streamingQuality ?? _faker.PickRandom<PlaybackStreamingQuality>()
};
}
@@ -192,43 +192,6 @@ public class UpdateUserSettingsCommandHandlerTests
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenToDomainEntityFails_ShouldReturnErrorAndNotUpdate()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create();
// An entity carrying an invalid items-per-page value fails to convert to its domain aggregate.
UserSettingsEntity existingSettings = _userSettingsEntityFixture.Create(userId: _userId, itemsPerPage: 0);
_mockUserSettingsRepository.GetByUserIdAsync(_userId, Arg.Any<CancellationToken>())
.Returns(Result.From<UserSettingsEntity?>(existingSettings));
// Act
Result<Updated> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.True(result.IsFailure);
await _mockUserSettingsRepository.DidNotReceive().UpdateAsync(Arg.Any<UserSettingsEntity>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenUpdateSettingsFails_ShouldReturnErrorAndNotPersist()
{
// Arrange
UpdateUserSettingsCommand command = _updateUserSettingsCommandFixture.Create(itemsPerPage: 0);
UserSettingsEntity existingSettings = _userSettingsEntityFixture.Create(userId: _userId);
_mockUserSettingsRepository.GetByUserIdAsync(_userId, Arg.Any<CancellationToken>())
.Returns(Result.From<UserSettingsEntity?>(existingSettings));
// Act
Result<Updated> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.True(result.IsFailure);
await _mockUserSettingsRepository.DidNotReceive().UpdateAsync(Arg.Any<UserSettingsEntity>(), Arg.Any<CancellationToken>());
await _mockUnitOfWork.DidNotReceive().SaveChangesAsync(Arg.Any<CancellationToken>());
}
[Fact]
public async Task HandleAsync_WhenUpdateFails_ShouldReturnErrorAndNotSaveChanges()
{
@@ -79,10 +79,20 @@ public class ErrorsTests
{
// Assert
// The count assertion fails when an error is added or removed, reminding to update the assertions below.
Assert.Equal(3, typeof(DomainErrors.UserSettings).GetProperties().Length);
Assert.Equal(13, typeof(DomainErrors.UserSettings).GetProperties().Length);
AssertError(DomainErrors.UserSettings.UserSettingsAlreadyExists, ErrorType.Conflict);
AssertError(DomainErrors.UserSettings.UserSettingsNotFound, ErrorType.NotFound);
AssertError(DomainErrors.UserSettings.ItemsPerPageMustBeGreaterThanZero, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.VolumeCannotBeNull, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.VolumeMustBeBetweenZeroAndOne, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.IsMutedCannotBeNull, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.ShouldKeepDownloadingWhilePausedCannotBeNull, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.ShouldAutoplayCannotBeNull, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.IsGaplessPlaybackEnabledCannotBeNull, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.ReplayGainModeCannotBeNull, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.StreamingQualityCannotBeNull, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.InvalidReplayGainMode, ErrorType.Validation);
AssertError(DomainErrors.UserSettings.InvalidStreamingQuality, ErrorType.Validation);
}
[Fact]
@@ -1,5 +1,4 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Errors;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
@@ -7,6 +6,7 @@ using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettin
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -80,7 +80,7 @@ public class UserSettingsTests
UserId userId = _userIdFixture.Create();
// Act
Result<UserSettings> result = UserSettings.Create(userId, isPaginationEnabled: false, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true);
Result<UserSettings> result = UserSettings.Create(userId, isPaginationEnabled: false, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto, volume: 1.0, isMuted: false);
// Assert
Assert.False(result.IsFailure);
@@ -108,22 +108,6 @@ public class UserSettingsTests
Assert.NotEqual(result.Value.Id.Value, result.Value.UserId.Value);
}
[Theory]
[InlineData(0)]
[InlineData(-1)]
public void Create_WhenItemsPerPageIsNotPositive_ShouldReturnError(int itemsPerPage)
{
// Arrange
UserId userId = _userIdFixture.Create();
// Act
Result<UserSettings> result = UserSettings.Create(userId, isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero, result.FirstError);
}
[Fact]
public void Create_WhenCalledWithPreExistingIdAndValidValues_ShouldCreateSettingsWithThatId()
{
@@ -132,7 +116,7 @@ public class UserSettingsTests
UserSettingsId id = _userSettingsIdFixture.Create();
// Act
Result<UserSettings> result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: true);
Result<UserSettings> result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 24, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto, volume: 1.0, isMuted: false);
// Assert
Assert.False(result.IsFailure);
@@ -141,21 +125,6 @@ public class UserSettingsTests
Assert.Equal(24, result.Value.ItemsPerPage);
}
[Fact]
public void Create_WhenCalledWithPreExistingIdAndNonPositiveItemsPerPage_ShouldReturnError()
{
// Arrange
UserId userId = _userIdFixture.Create();
UserSettingsId id = _userSettingsIdFixture.Create();
// Act
Result<UserSettings> result = UserSettings.Create(id, userId, isPaginationEnabled: true, itemsPerPage: 0, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero, result.FirstError);
}
[Fact]
public void UpdateSettings_WhenCalledWithValidValues_ShouldUpdateSettings()
{
@@ -163,7 +132,7 @@ public class UserSettingsTests
UserSettings userSettings = _userSettingsFixture.Create();
// Act
Result<Updated> result = userSettings.UpdateSettings(isPaginationEnabled: false, itemsPerPage: 12, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: false, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true);
Result<Updated> result = userSettings.UpdateSettings(isPaginationEnabled: false, itemsPerPage: 12, shouldIgnoreThePrefixForAlphaPicker: true, isThemeCachingEnabled: false, shouldAggregateMetadataWhenMissing: true, shouldAggregateArtworkWhenMissing: true, shouldRenderPdfAsImages: true, shouldPreserveBookStyles: true, shouldKeepDownloadingWhilePaused: true, shouldAutoplay: true, isGaplessPlaybackEnabled: true, replayGainMode: ReplayGainMode.Off, streamingQuality: PlaybackStreamingQuality.Auto);
// Assert
Assert.False(result.IsFailure);
@@ -175,20 +144,4 @@ public class UserSettingsTests
Assert.True(userSettings.ShouldRenderPdfAsImages);
Assert.True(userSettings.ShouldPreserveBookStyles);
}
[Theory]
[InlineData(0)]
[InlineData(-5)]
public void UpdateSettings_WhenItemsPerPageIsNotPositive_ShouldReturnError(int itemsPerPage)
{
// Arrange
UserSettings userSettings = _userSettingsFixture.Create();
// Act
Result<Updated> result = userSettings.UpdateSettings(isPaginationEnabled: true, itemsPerPage: itemsPerPage, shouldIgnoreThePrefixForAlphaPicker: false, isThemeCachingEnabled: true, shouldAggregateMetadataWhenMissing: false, shouldAggregateArtworkWhenMissing: false, shouldRenderPdfAsImages: false, shouldPreserveBookStyles: false);
// Assert
Assert.True(result.IsFailure);
Assert.Equal(Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero, result.FirstError);
}
}