Skip to content

Commit

Permalink
[CastIt.Server.ClientApp] Updated client app with the new setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Dec 12, 2021
1 parent e14e3a9 commit 17bc877
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CastIt.GoogleCast.Youtube/YoutubeMediaRequestGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public async Task<PlayMediaRequest> 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(
Expand Down Expand Up @@ -149,6 +149,7 @@ private async Task<YoutubePlayMediaRequest> BuildRequestFromFormats(
};

await SetSubtitlesIfAny(file, settings, request, cancellationToken);
file.SetQualitiesStreams(ytMedia.SelectedQuality, ytMedia.Qualities);
return request;
}

Expand Down Expand Up @@ -204,6 +205,7 @@ private async Task<YoutubePlayMediaRequest> BuildRequestFromAdaptiveFormats(
};
request.MediaInfo.Duration = fileInfo.Format?.Duration ?? -1;
await SetSubtitlesIfAny(file, settings, request, cancellationToken);
file.SetQualitiesStreams(ytMedia.SelectedQuality, ytMedia.Qualities);
return request;
}

Expand Down Expand Up @@ -282,6 +284,7 @@ private async Task<YoutubePlayMediaRequest> BuildRequestFromHls(
AudioStreamIndex = audioStreamIndex,
};
await SetSubtitlesIfAny(file, settings, request, cancellationToken);
file.SetQualitiesStreams(closestQuality, ytMedia.Qualities);
return request;
}
}
Expand Down
19 changes: 19 additions & 0 deletions CastIt.Server/ClientApp/src/components/player/player_settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
TextTrackFontStyle,
TextTrackFontGenericFamily,
AppLanguage,
WebVideoQuality,
} from '../../enums';
import { IServerAppSettings } from '../../models';
import { onPlayerSettingsChanged } from '../../services/castithub.service';
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -255,6 +260,20 @@ function PlayerSettings() {
{videoScaleOptions}
</Select>
</FormControl>
<FormControl className={classes.formControl}>
<InputLabel htmlFor="supported-video-qualities">{translations.webVideoQuality}</InputLabel>
<Select
native
value={state.settings.webVideoQuality}
onChange={(e) => handleSettingsChange('webVideoQuality', e.target.value)}
inputProps={{
name: 'supported-video-qualities',
id: 'supported-video-qualities',
}}
>
{supportedWebVideoQualities}
</Select>
</FormControl>
</Grid>
<Grid item xs={12} className={classes.gridItemMargin}>
<Typography color="textSecondary">{translations.options}</Typography>
Expand Down
1 change: 1 addition & 0 deletions CastIt.Server/ClientApp/src/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
8 changes: 8 additions & 0 deletions CastIt.Server/ClientApp/src/enums/web_video_quality.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum WebVideoQuality {
ultraLow = 144,
low = 240,
traditional = 360,
standard = 480,
hd = 720,
fullHd = 1080,
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IServerAppSettings {
forceAudioTranscode: boolean;
videoScale: VideoScale;
enableHardwareAcceleration: boolean;
webVideoQuality: number;

currentSubtitleFgColor: SubtitleFgColor;
currentSubtitleBgColor: SubtitleBgColor;
Expand Down
3 changes: 3 additions & 0 deletions CastIt.Server/ClientApp/src/services/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ interface ITranslations {
retry: string;
sort: string;
copyPath: string;
webVideoQuality: string;
errorCodes: IAppMessageTranslations;
}

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 17bc877

Please sign in to comment.