我想弄清楚如何从正在进行的现场表演的 YouTube 流中获取更高比特率的视频。我正在使用 dotnet maui 中的媒体元素播放它。现在它是非常低质量的视频,我不知道如何改进它。我正在使用 Youtube Explode 软件包。我用来获取流的函数是 GetHttpLiveStreamUrlAsync()。这是我能够在 maui 的媒体元素中播放任何视频的唯一方法。
xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Class="NerdNewsNavigator2.View.LivePage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:viewmodel="clr-namespace:NerdNewsNavigator2.ViewModel"
Title=""
x:DataType="viewmodel:LiveViewModel"
Loaded="ContentPage_Loaded"
Unloaded="ContentPage_Unloaded"
Shell.NavBarIsVisible="False">
<Shell.BackButtonBehavior>
<BackButtonBehavior IsEnabled="True" IsVisible="False" />
</Shell.BackButtonBehavior>
<Grid>
<toolkit:MediaElement
x:Name="mediaElement"
ShouldAutoPlay="True"
ShouldShowPlaybackControls="True" />
</Grid>
</ContentPage>
显示视频的代码:
private void ContentPage_Loaded(object? sender, EventArgs e)
{
if (sender is null)
{
return;
}
_ = LoadVideo();
SetFullScreen();
}
private async Task LoadVideo()
{
var youtube = new YoutubeClient();
mediaElement.Source = await youtube.Videos.Streams.GetHttpLiveStreamUrlAsync("F2NreNEmMy4");
mediaElement.Play();
}
这是缩写代码,显示了我用来显示它的方法。我正在寻找替代方法或改进当前代码以获得更好的视频。