问题
I am loading a YouTube video in my app using web-view. But the full screen option is not working. How can i achieve the full screen.
My Code
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Player.MainPage">
<StackLayout>
<Label Text="Hello"/>
<WebView x:Name="browser" Source="https://www.youtube.com/watch?v=fDrTbLXHKu8" HeightRequest="500"/>
</StackLayout>
</ContentPage>
Screenshot
The youtube fullscreen is not working.
回答1:
You need a custom renderer for your WebView
. This repo will help you.
More details about this issue can be found here and here.
Just checked your code with this WebView
renderer and it's showing fullscreen video after tapping expand control.
回答2:
simply replace your stack layout with Grid,as following
<Grid>
<WebView x:Name="browser" Source="https://www.youtube.com/watch?v=fDrTbLXHKu8" />
</Grid>
来源:https://stackoverflow.com/questions/61156563/webview-video-fullscreen