【发布时间】:2018-06-03 23:31:54
【问题描述】:
资产文件夹中存储的视频(AndroidAsset)
Xaml:
<WebView x:Name="myWebView"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"
WidthRequest="500" HeightRequest="200"/>
背后:页面构造函数中调用的 PlayVideo 方法:
string myVideoHtml = String.Format(@"<html>
<body style='position: relative;width:
100%;height: 0;padding-bottom: 56.25%;'>
<video poster='black.jpg' style='position:
absolute; top: 0;left: 0;width: 100%;height: 100%;' autoplay controls>
<source src='{0}' type='video/mp4'/></video></body></html>",
videoUrlFilename);
var html = new HtmlWebViewSource { Html = myVideoHtml};
myWebView.Source = html;
在 android 7.0 上测试过。它就像一个魅力,但是当我在 android 4.2.2 上测试它时它不起作用;我在这里遗漏了什么吗?
【问题讨论】:
-
狂拍,可能Android 4.2.2还不支持HTML5?
-
正是我的想法。如果是这样,您知道在 android 上播放本地视频的另一种方法吗?
标签: c# android xamarin xamarin.forms cross-platform