Xamarin Forms Webview无法播放视频 [英] Xamarin Forms Webview not playing video
问题描述
我有一个Xamarin Forms Xaml中声明的webview.无论是在代码的后面还是在Xaml中设置源,视频控件都可以正常显示,但是当您单击播放图标时,它不会播放.我可以通过点按渲染的底部搜索栏来向前和向后跳过.视频将向前跳过并停在一帧上,但是在点按播放时仍无法播放.我正在将webview的源设置为html5视频标签,因为它是我能够获取的最接近的视频.我应该提到视频是使用Azure Media Services进行流媒体格式化的,所以这不应该成为问题.
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.
在Android上: 当您单击播放图标时,它不会播放.我可以通过点击底部的搜索栏来向前或向后跳过,或者在视频上向左/向右点击,它会显示不同的帧.
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屋!