html5 video on Android 4: play fullscreen then redirect to another webpage - not working

前端 未结 4 907
感动是毒
感动是毒 2021-02-13 03:42

I\'m designing an html5 page for Android 4 smartphones with a single 3gpp (or mp4) video that has to autoplay fullscreen when opened; when video ends should redirect to another

4条回答
  •  清歌不尽
    2021-02-13 03:58

    I've recently had a similar problem. After hours of searching the web, here's how i made it work:

    Before invoking the "play()" method, use the "load()" method. So in your code:

        function playVideo() {
            var video = document.getElementById("video");
            video.addEventListener('ended', videoEnd, false);
            video.webkitEnterFullScreen();
            video.load();
            video.play();
        }
    

    I;ve teste on android 2.2, 2.3 and IPhone 3 and it works. However it doesn't seem to play on android 4.0.

    P.S.

    If you want to redirect when the video finishes playing use this event:

    var video = document.getElementById("video");
    video.addEventListener("ended",doSomething,true);
    
    function doSomething() {
         //your redirect code here
    }
    

提交回复
热议问题