【发布时间】:2020-01-04 00:48:49
【问题描述】:
标题说得差不多了,我正在推送一个包含 VideoSource 的 WebView 女巫有一个 youtube 视频嵌入 HTML 代码。 一旦它被推动,我需要强制它进入全屏模式。 这是我正在使用的一段代码,如果您有任何其他/更好的方法,请回答
我是新手,所以请放轻松:)
我在这个主题上搜索了一下,但无论如何我都找不到在推送时仅在 1 页上旋转屏幕。
public partial class MainScreen : TabbedPage
{
public HtmlWebViewSource VideoSource { get; set; }
private const string PlayerHTML = @"<html>
<body>
<iframe style='position: absolute; top: 0; left: 0; width: 100%; height: 100%;'
src='https://www.youtube.com/embed/6e7qKcVigQo?rel=0?autoplay=1?modestbranding=1'
frameborder='0'
allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture'
allowfullscreen>
</iframe>
</body>
</html>";
private async void ImageButton_Clicked(object sender, EventArgs e)
{
VideoSource = new HtmlWebViewSource
{
Html = PlayerHTML
};
var a = new ContentPage
{
Content = new WebView()
{
Source = VideoSource
}
};
NavigationPage.SetHasNavigationBar(a, false);
await Navigation.PushAsync(a);
//make the screen rotate SOMEHOW
}
}
我期望有两种解决方案;
- Xamarin 相关解决方案,例如通过到达 MainActivity.cs 来旋转屏幕
- HTML/YouTube 嵌入解决方案,例如视频链接中的内容,可强制全屏播放视频...
【问题讨论】:
标签: c# xamarin xamarin.forms youtube youtube-api