没有 iframe 的 Youtube 全屏
Youtube Fullscreen without Iframe
相关:YouTube iframe embed - full screen
没有iframe可以通过allowFullscreen吗?我正在为 Xamarin 开发,我正在使用一个 WebView,它只是打开嵌入 url 本身,我在这里看不到需要 iframe,但我希望有全屏的可能性......
要在 Android 的 Xamarin Forms WebView 中启用全屏支持,您可以创建自定义 fullScreen_webview。
public class FullScreenEnabledWebView : WebView
{
/// <summary>
/// Bindable property for <see cref="EnterFullScreenCommand"/>.
/// </summary>
public static readonly BindableProperty EnterFullScreenCommandProperty =
BindableProperty.Create(
nameof(EnterFullScreenCommand),
typeof(ICommand),
typeof(FullScreenEnabledWebView),
defaultValue: new Command(async (view) => await DefaultEnterAsync((View)view)));
/// <summary>
/// Bindable property for <see cref="ExitFullScreenCommand"/>.
/// </summary>
public static readonly BindableProperty ExitFullScreenCommandProperty =
BindableProperty.Create(
nameof(ExitFullScreenCommand),
typeof(ICommand),
typeof(FullScreenEnabledWebView),
defaultValue: new Command(async (view) => await DefaultExitAsync()));
/// <summary>
/// Gets or sets the command executed when the web view content requests entering full-screen.
/// The command is passed a <see cref="View"/> containing the content to display.
/// The default command displays the content as a modal page.
/// </summary>
public ICommand EnterFullScreenCommand
{
get => (ICommand)GetValue(EnterFullScreenCommandProperty);
set => SetValue(EnterFullScreenCommandProperty, value);
}
/// <summary>
/// Gets or sets the command executed when the web view content requests exiting full-screen.
/// The command is passed no parameters.
/// The default command pops a modal page off the navigation stack.
/// </summary>
public ICommand ExitFullScreenCommand
{
get => (ICommand)GetValue(ExitFullScreenCommandProperty);
set => SetValue(ExitFullScreenCommandProperty, value);
}
private static async Task DefaultEnterAsync(View view)
{
var page = new ContentPage
{
Content = view
};
await Application.Current.MainPage.Navigation.PushModalAsync(page);
}
private static async Task DefaultExitAsync()
{
await Application.Current.MainPage.Navigation.PopModalAsync();
}
}
有关在xamarin.android Webview 中启用全屏支持的更多详细信息,您可以查看此示例:
https://github.com/microsoft/CSSClientAppsXamarinSampleCode/tree/main/FullScreenWebView
可以点击右下角红框中的iframe全屏,截图:
相关:YouTube iframe embed - full screen
没有iframe可以通过allowFullscreen吗?我正在为 Xamarin 开发,我正在使用一个 WebView,它只是打开嵌入 url 本身,我在这里看不到需要 iframe,但我希望有全屏的可能性......
要在 Android 的 Xamarin Forms WebView 中启用全屏支持,您可以创建自定义 fullScreen_webview。
public class FullScreenEnabledWebView : WebView
{
/// <summary>
/// Bindable property for <see cref="EnterFullScreenCommand"/>.
/// </summary>
public static readonly BindableProperty EnterFullScreenCommandProperty =
BindableProperty.Create(
nameof(EnterFullScreenCommand),
typeof(ICommand),
typeof(FullScreenEnabledWebView),
defaultValue: new Command(async (view) => await DefaultEnterAsync((View)view)));
/// <summary>
/// Bindable property for <see cref="ExitFullScreenCommand"/>.
/// </summary>
public static readonly BindableProperty ExitFullScreenCommandProperty =
BindableProperty.Create(
nameof(ExitFullScreenCommand),
typeof(ICommand),
typeof(FullScreenEnabledWebView),
defaultValue: new Command(async (view) => await DefaultExitAsync()));
/// <summary>
/// Gets or sets the command executed when the web view content requests entering full-screen.
/// The command is passed a <see cref="View"/> containing the content to display.
/// The default command displays the content as a modal page.
/// </summary>
public ICommand EnterFullScreenCommand
{
get => (ICommand)GetValue(EnterFullScreenCommandProperty);
set => SetValue(EnterFullScreenCommandProperty, value);
}
/// <summary>
/// Gets or sets the command executed when the web view content requests exiting full-screen.
/// The command is passed no parameters.
/// The default command pops a modal page off the navigation stack.
/// </summary>
public ICommand ExitFullScreenCommand
{
get => (ICommand)GetValue(ExitFullScreenCommandProperty);
set => SetValue(ExitFullScreenCommandProperty, value);
}
private static async Task DefaultEnterAsync(View view)
{
var page = new ContentPage
{
Content = view
};
await Application.Current.MainPage.Navigation.PushModalAsync(page);
}
private static async Task DefaultExitAsync()
{
await Application.Current.MainPage.Navigation.PopModalAsync();
}
}
有关在xamarin.android Webview 中启用全屏支持的更多详细信息,您可以查看此示例:
https://github.com/microsoft/CSSClientAppsXamarinSampleCode/tree/main/FullScreenWebView
可以点击右下角红框中的iframe全屏,截图: