android支持html5 video标签,实现在线播放吗
展开全部
z 可以实现在线播放的
不过你要调用系统的播放器才可以,你自己看吧 我也被这个整了好久
如下代码:
//html
<video autoplay="autoplay" controls="controls" id="youku-html5-player-video" onclick="playVideo('IP/player/getRealM3U8/vid/XNDE4NjIwOTI0/type//video.m3u8');" preload="" src="IP/player/getRealM3U8/vid/XNDE4NjIwOTI0/type//video.m3u8" width="100%" x-webkit-airplay="allow">
Your browser does not support the video tag.</video>
<script>
function playVideo(video){
window.JSInterface.startVideo(video);
}
</script>
//java
JavaScriptInterface jsInterface = new JavaScriptInterface(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(jsInterface, "JSInterface");
public class JavaScriptInterface {
private Activity activity;
public JavaScriptInterface(Activity activiy) {
this.activity = activiy;
}
public void startVideo(String videoAddress){
//调用播放器(这里看你自己怎么写了)
Bundle bundle = new Bundle();
bundle.putString("path", address);
MyIntent.startIntent(WebViewActivity.this, MyIntent.VIDEO, bundle);
}
}
不过你要调用系统的播放器才可以,你自己看吧 我也被这个整了好久
如下代码:
//html
<video autoplay="autoplay" controls="controls" id="youku-html5-player-video" onclick="playVideo('IP/player/getRealM3U8/vid/XNDE4NjIwOTI0/type//video.m3u8');" preload="" src="IP/player/getRealM3U8/vid/XNDE4NjIwOTI0/type//video.m3u8" width="100%" x-webkit-airplay="allow">
Your browser does not support the video tag.</video>
<script>
function playVideo(video){
window.JSInterface.startVideo(video);
}
</script>
//java
JavaScriptInterface jsInterface = new JavaScriptInterface(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(jsInterface, "JSInterface");
public class JavaScriptInterface {
private Activity activity;
public JavaScriptInterface(Activity activiy) {
this.activity = activiy;
}
public void startVideo(String videoAddress){
//调用播放器(这里看你自己怎么写了)
Bundle bundle = new Bundle();
bundle.putString("path", address);
MyIntent.startIntent(WebViewActivity.this, MyIntent.VIDEO, bundle);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询