From 17bc877a4dcd6f3f57cbe808a798930aa8bd9fa5 Mon Sep 17 00:00:00 2001 From: Efrain Date: Sun, 12 Dec 2021 18:01:13 -0500 Subject: [PATCH] [CastIt.Server.ClientApp] Updated client app with the new setting --- .../YoutubeMediaRequestGenerator.cs | 7 +++++-- .../src/components/player/player_settings.tsx | 19 +++++++++++++++++++ CastIt.Server/ClientApp/src/enums/index.ts | 1 + .../src/enums/web_video_quality.enum.ts | 8 ++++++++ .../src/models/server_app_settings.model.ts | 1 + .../ClientApp/src/services/translations.ts | 3 +++ 6 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 CastIt.Server/ClientApp/src/enums/web_video_quality.enum.ts diff --git a/CastIt.GoogleCast.Youtube/YoutubeMediaRequestGenerator.cs b/CastIt.GoogleCast.Youtube/YoutubeMediaRequestGenerator.cs index ae32bafc..69eb1966 100644 --- a/CastIt.GoogleCast.Youtube/YoutubeMediaRequestGenerator.cs +++ b/CastIt.GoogleCast.Youtube/YoutubeMediaRequestGenerator.cs @@ -66,8 +66,8 @@ public async Task BuildRequest( throw new FileNotSupportedException(msg); } var basicInfo = await _decoder.ParseBasicInfo(file.Path, cancellationToken); - //TODO: THIS 1080 - var ytMedia = await _decoder.Parse(basicInfo, 1080 /*file.CurrentFileQuality*/, cancellationToken); + int desiredQuality = fileOptionsChanged ? file.CurrentFileQuality : (int)settings.WebVideoQuality; + var ytMedia = await _decoder.Parse(basicInfo, desiredQuality, cancellationToken); if (ytMedia.IsHls) { return await BuildRequestFromHls( @@ -149,6 +149,7 @@ private async Task BuildRequestFromFormats( }; await SetSubtitlesIfAny(file, settings, request, cancellationToken); + file.SetQualitiesStreams(ytMedia.SelectedQuality, ytMedia.Qualities); return request; } @@ -204,6 +205,7 @@ private async Task BuildRequestFromAdaptiveFormats( }; request.MediaInfo.Duration = fileInfo.Format?.Duration ?? -1; await SetSubtitlesIfAny(file, settings, request, cancellationToken); + file.SetQualitiesStreams(ytMedia.SelectedQuality, ytMedia.Qualities); return request; } @@ -282,6 +284,7 @@ private async Task BuildRequestFromHls( AudioStreamIndex = audioStreamIndex, }; await SetSubtitlesIfAny(file, settings, request, cancellationToken); + file.SetQualitiesStreams(closestQuality, ytMedia.Qualities); return request; } } diff --git a/CastIt.Server/ClientApp/src/components/player/player_settings.tsx b/CastIt.Server/ClientApp/src/components/player/player_settings.tsx index 1e42d366..a55883df 100644 --- a/CastIt.Server/ClientApp/src/components/player/player_settings.tsx +++ b/CastIt.Server/ClientApp/src/components/player/player_settings.tsx @@ -27,6 +27,7 @@ import { TextTrackFontStyle, TextTrackFontGenericFamily, AppLanguage, + WebVideoQuality, } from '../../enums'; import { IServerAppSettings } from '../../models'; import { onPlayerSettingsChanged } from '../../services/castithub.service'; @@ -117,6 +118,10 @@ function PlayerSettings() { } }).map(generateSelectOption); + const supportedWebVideoQualities = mapEnum(WebVideoQuality, (val) => { + return { text: `${val}p`, value: val }; + }).map(generateSelectOption); + const subsBgColorOptions = mapEnum(SubtitleBgColor, (val) => ({ text: translations.default, value: val })).map(generateSelectOption); const subsFgColorOptions = mapEnum(SubtitleFgColor, (val) => { @@ -255,6 +260,20 @@ function PlayerSettings() { {videoScaleOptions} + + {translations.webVideoQuality} + + {translations.options} diff --git a/CastIt.Server/ClientApp/src/enums/index.ts b/CastIt.Server/ClientApp/src/enums/index.ts index 086c6ee9..3e054fea 100644 --- a/CastIt.Server/ClientApp/src/enums/index.ts +++ b/CastIt.Server/ClientApp/src/enums/index.ts @@ -8,3 +8,4 @@ export { AppFile } from './app_file.enum'; export { SortMode } from './sort_mode.enum'; export { AppMessage } from './app_message.enum'; export { AppLanguage } from './app_language.enum'; +export { WebVideoQuality } from './web_video_quality.enum'; diff --git a/CastIt.Server/ClientApp/src/enums/web_video_quality.enum.ts b/CastIt.Server/ClientApp/src/enums/web_video_quality.enum.ts new file mode 100644 index 00000000..1d5ce3fa --- /dev/null +++ b/CastIt.Server/ClientApp/src/enums/web_video_quality.enum.ts @@ -0,0 +1,8 @@ +export enum WebVideoQuality { + ultraLow = 144, + low = 240, + traditional = 360, + standard = 480, + hd = 720, + fullHd = 1080, +} diff --git a/CastIt.Server/ClientApp/src/models/server_app_settings.model.ts b/CastIt.Server/ClientApp/src/models/server_app_settings.model.ts index aae7f8dc..2fcb233a 100644 --- a/CastIt.Server/ClientApp/src/models/server_app_settings.model.ts +++ b/CastIt.Server/ClientApp/src/models/server_app_settings.model.ts @@ -14,6 +14,7 @@ export interface IServerAppSettings { forceAudioTranscode: boolean; videoScale: VideoScale; enableHardwareAcceleration: boolean; + webVideoQuality: number; currentSubtitleFgColor: SubtitleFgColor; currentSubtitleBgColor: SubtitleBgColor; diff --git a/CastIt.Server/ClientApp/src/services/translations.ts b/CastIt.Server/ClientApp/src/services/translations.ts index c34ec32d..ab7a28e0 100644 --- a/CastIt.Server/ClientApp/src/services/translations.ts +++ b/CastIt.Server/ClientApp/src/services/translations.ts @@ -93,6 +93,7 @@ interface ITranslations { retry: string; sort: string; copyPath: string; + webVideoQuality: string; errorCodes: IAppMessageTranslations; } @@ -168,6 +169,7 @@ const enTrans: ITranslations = { retry: 'Retry', sort: 'Sort', copyPath: 'Copy path', + webVideoQuality: 'Web video quality', errorCodes: { unknownErrorOccurred: 'Unknown error occurred', invalidRequest: 'Invalid request', @@ -261,6 +263,7 @@ const esTrans: ITranslations = { retry: 'Reintentar', sort: 'Ordenar', copyPath: 'Copiar ruta', + webVideoQuality: 'Calidad de video web', errorCodes: { unknownErrorOccurred: 'Un error inesperado ha ocurrido', invalidRequest: 'Petición no válida',