Xamarin Forms Webview 不播放视频 [英] Xamarin Forms Webview not playing video

查看:19
本文介绍了Xamarin Forms Webview 不播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Xamarin Forms Xaml 中声明的 webview.无论我是在代码后面还是在 Xaml 中设置源,视频控件都可以很好地呈现,但是当您单击播放图标时,它不会播放.我可以通过点击呈现的底部搜索栏来向前和向后跳过.视频会向前跳过并冻结在一个帧上,但在点击播放时仍然不会播放.我正在将 webview 的源设置为 html5 视频标签,因为它是我最接近获取要呈现的视频的标签.我应该提一下,视频是使用 Azure 媒体服务进行流式处理的,所以这应该不是问题.

I have a webview declared in Xamarin Forms Xaml. Whether I set the source in code behind or in Xaml, the video control renders fine, but when you click the play icon it does not play. I can skip ahead and back by tapping the bottom seek bar that renders. The video will skip ahead and freeze on a frame, but still wont play when tapping play. I'm setting the source of the webview to an html5 video tag as its the closest I could get to getting a video to render. I should mention that the video is formatted for streaming using Azure Media Services, so that shouldn't be the issue.

<WebView IsVisible="{Binding HasVideo}" Margin="10,0,0,0" BindingContextChanged="WebView_BindingContextChanged"  HorizontalOptions="CenterAndExpand"
     VerticalOptions="CenterAndExpand" HeightRequest="350"  />

private void WebView_BindingContextChanged(object sender, EventArgs e)
{
    var webView = ((WebView)sender);

    Post post = (Post)webView.BindingContext;
    if (post.HasVideo)
    {             
        var htmlSource = new HtmlWebViewSource();
        htmlSource.Html = @"<!DOCTYPE html>
                            <html>
                            <body>
                                <video  src='" + post.MainVideoURL + @"' controls width='320' height='240' preload='metadata'   >
                            </ body >
                            </html><style>
                            video {
                                object-fit: fill;
                            }
                            </style>";
        webView.Source = htmlSource;
        }          
    }

推荐答案

这也发生在我身上,在已安装的应用程序上.一个用户报告了这个问题.

It happened for me also, on already installed app. A user reported this problem.

在安卓上:当您单击播放图标时,它不会播放.我可以通过点击底部的搜索栏来向前和向后跳转,或者通过向左/向右点击视频,它会显示不同的帧.

On Android: When you click the play icon it doesn't play. I can skip ahead and back by tapping the bottom seek bar, or by tapping left/right on the video, it shows different frames.

在 iOS 上:使用最新的更新 12.2,视频停止工作.它们显示空白背景,并且不响应任何点击.

On iOS: With the latest update 12.2, the videos stopped working. They show blank background and they don't respond to any click.

我也在使用视频标签...

I am also using video tag...

这篇关于Xamarin Forms Webview 不播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆