Webview Video fullscreen

走远了吗. 提交于 2021-02-11 13:48:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!