Skip to content

Commit

Permalink
[Server] Added a setting to change the web video quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Dec 12, 2021
1 parent 12feceb commit e14e3a9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
12 changes: 12 additions & 0 deletions CastIt.Domain/Enums/WebVideoQualityType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace CastIt.Domain.Enums
{
public enum WebVideoQualityType
{
UltraLow = 144,
Low = 240,
Traditional = 360,
Standard = 480,
Hd = 720,
FullHd = 1080
}
}
12 changes: 0 additions & 12 deletions CastIt.Server/Services/ServerCastService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ protected void FileLoaded(object sender, EventArgs e)
_server.OnFileLoaded?.Invoke(GetCurrentPlayedFile());
}

protected Task OnQualitiesLoaded(int selectedQuality, List<int> qualities)
{
CurrentPlayedFile?.SetQualitiesStreams(selectedQuality, qualities);
return Task.CompletedTask;
}

public Task PlayFile(string fileName, bool force, bool isAnAutomaticCall)
{
if (string.IsNullOrWhiteSpace(fileName))
Expand Down Expand Up @@ -327,12 +321,6 @@ public async Task PlayFile(ServerFileItem file, bool force, bool fileOptionsChan
CurrentPlayedFile.SetSubtitleStreams(localSubsPath, filename, _settings.LoadFirstSubtitleFoundAutomatically);
}

//TODO: FIGURE OUT HOW CAN I REMOVE THIS
if (request is YoutubePlayMediaRequest ytRequest)
{
await OnQualitiesLoaded(ytRequest.SelectedQuality, ytRequest.Qualities);
}

if (request.NeedsTinyCode)
{
await GenerateAndSetTinyCode(request);
Expand Down
3 changes: 3 additions & 0 deletions CastIt.Shared/Models/ServerAppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ServerAppSettings
public bool ForceAudioTranscode { get; set; }
public VideoScaleType VideoScale { get; set; }
public bool EnableHardwareAcceleration { get; set; }
public WebVideoQualityType WebVideoQuality { get; set; }

public SubtitleFgColorType CurrentSubtitleFgColor { get; set; }
public SubtitleBgColorType CurrentSubtitleBgColor { get; set; }
Expand All @@ -38,6 +39,7 @@ public ServerAppSettings Copy()
ForceAudioTranscode = ForceAudioTranscode,
VideoScale = VideoScale,
EnableHardwareAcceleration = EnableHardwareAcceleration,
WebVideoQuality = WebVideoQuality,

CurrentSubtitleFgColor = CurrentSubtitleFgColor,
CurrentSubtitleBgColor = CurrentSubtitleBgColor,
Expand All @@ -63,6 +65,7 @@ public ServerAppSettings UpdateWith(ServerAppSettings other)
ForceAudioTranscode = other.ForceAudioTranscode;
VideoScale = other.VideoScale;
EnableHardwareAcceleration = other.EnableHardwareAcceleration;
WebVideoQuality = other.WebVideoQuality;

CurrentSubtitleFgColor = other.CurrentSubtitleFgColor;
CurrentSubtitleBgColor = other.CurrentSubtitleBgColor;
Expand Down
2 changes: 1 addition & 1 deletion CastIt.Youtube/YoutubeUrlDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public async Task<YoutubeMedia> Parse(
CancellationToken cancellationToken = default)
{
desiredQuality ??= DefaultQuality;
_logger.LogInformation($"{nameof(Parse)}: Trying to parse url = {basicInfo.Url}");
_logger.LogInformation($"{nameof(Parse)}: Trying to parse url = {basicInfo.Url}. Desired quality = {desiredQuality}");

string fmt = string.Empty;
if (IsHtmlPage(basicInfo.Url))
Expand Down

0 comments on commit e14e3a9

Please sign in to comment.