我正在尝试在我的应用程序中显示视频。我想在 YouTube 上显示它。
我正在 xaml 中创建 MediaElement
:
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
<toolkit:MediaElement Grid.Row="1"
x:Name="mediaElement"
ShouldAutoPlay="True"
ShouldShowPlaybackControls="True"
Margin="10,10,10,10"/>
但我无法将网址放入我的视频。我可以显示其他网站的视频,但不能显示来自 YouTube 的视频。我了解到,通过提供来自 YT 的链接无法直接显示它。我不太知道如何解决它。我尝试使用外部库来提取流,但失败了。
我尝试创建一个 WebView 控件,但在其中我只能显示 yt 的整个页面,而不能显示视频。
<WebView x:Name="webView" Grid.Row="1" Margin="10,10,10,10"/>.
最佳答案
解决方案:使用 WebView 和 youtube url 嵌入
<WebView Source="https://www.youtube.com/embed/<yourMovieId>"/>
关于c# - 如何在 MAUI 中显示 YT 视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76281476/