Android 三星S4(安卓4.4.2)版本WebView中的HTML5视频

Android 三星S4(安卓4.4.2)版本WebView中的HTML5视频,android,html,video,cordova,Android,Html,Video,Cordova,我在三星S4+Android 4.4.2上的Phonegap 3.3应用程序中播放嵌入视频标签的视频时遇到了一个奇怪的问题 我有以下HTML代码: <video id='myvideo' autoplay=1 preload='auto'></video> 视频未按预期启动 这个问题只有在从安卓4.2升级到安卓4.4.2之后才会出现。运行Android 4.4.2(如Nexus 4、5)的其他智能手机上不存在此问题。将此设置添加到您的webview设置中 webSett

我在三星S4+Android 4.4.2上的Phonegap 3.3应用程序中播放嵌入视频标签的视频时遇到了一个奇怪的问题

我有以下HTML代码:

<video id='myvideo' autoplay=1 preload='auto'></video>
视频未按预期启动


这个问题只有在从安卓4.2升级到安卓4.4.2之后才会出现。运行Android 4.4.2(如Nexus 4、5)的其他智能手机上不存在此问题。

将此设置添加到您的webview设置中

webSettings.setMediaPlaybackRequiresUserGesture(false);
这是我的js代码,可以自动播放视频并循环播放(如果只想播放一次,可以删除此部分)

// here is my code to find my video tag
var myVideo = document.getElementsByTagName('video')[0];

// if there is a video tag found ( this js is in a separate js files ) we play the video
if (typeof myVideo !== "undefined")
{
    // setInterval allow me to monitor every 40 millisecond if the video is ending or not, if true we loop the video and play it again
    setInterval(function() {


        if ( myVideo.readyState != 0)
        {
            if (myVideo.paused) {
                myVideo.currentTime = 0;
                myVideo.play();
            }
        }            
    }, 40)
}

我认为你的.mp4和.jpg是落后的。

我在某个地方读到autoplay属性不适用于移动设备你运行哪个android版本?
// here is my code to find my video tag
var myVideo = document.getElementsByTagName('video')[0];

// if there is a video tag found ( this js is in a separate js files ) we play the video
if (typeof myVideo !== "undefined")
{
    // setInterval allow me to monitor every 40 millisecond if the video is ending or not, if true we loop the video and play it again
    setInterval(function() {


        if ( myVideo.readyState != 0)
        {
            if (myVideo.paused) {
                myVideo.currentTime = 0;
                myVideo.play();
            }
        }            
    }, 40)
}