关于webview加载html文件,vedio.play()方法无效问题

往事o烟 发布于 2015/06/27 13:52
阅读 703
收藏 0
html文件代码如下:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
function load() {
var myvideo = document.getElementById("myvideo");
myvideo.style.width = document.body.clientWidth + "px";
myvideo.style.height = document.body.clientHeight + "px";
launchFullScreen(myvideo);
var url= window.vedio.getUrl();
replace(myvideo,url);
myVid = document.getElementById("myvideo");
myVid.addEventListener("timeupdate", function () {
if (myVid.ended) {
window.vedio.finish();
}
});
}
function play() {
var myvideo = document.getElementById("myvideo");
alert("播放视频");
myvideo.play();
}
function replace(obj,url) {
obj.setAttribute("src", url);
}
function launchFullScreen(element) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen(); q
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}

</script>
<style>
* {
padding: 0;
margin: 0;
}

html, body, #myvideo {
width: 100%;
height: 100%;
}
</style>

</head>
<body onload="load()">
<video id="myvideo" src="#" controls="controls" autoplay="autoplay" preload="Auto" ></video>
</body>

</html>



其中 方法
function play() {
var myvideo = document.getElementById("myvideo");
alert("播放视频");
myvideo.play();
}
是在Java代码中调用,该方法已执行,但播放器尚未播放,跪求大神指点.ps:需要实现应用进入webview所在页面,视频自动播放
加载中
返回顶部
顶部