视频暂停播放

引入:(里面含videojs)

暂停点:

videoPos: [

    {starPos: 2},

    {starPos: 4},

    {starPos: 9.5},

    {starPos: 16},

],

开始:

queIndex: 0,//0开始

js:

videoObj = videojs('video');

videoObj.onerror = function () {

    videoObj.load();

    videoObj.play()

};

videoObj.ready(function () {

    videoObj.on("loadedmetadata", function () {

        //视频源加载完成

        /*console.log(444444444);

        setTimeout(function () {

            if (!app.page.question) {

                app.pageShow('question');

                app.close();

                // app.popTwoClose();

                setTimeout(function () {

                    question.update();

                    question.slideTo(0, 0);

                }, 100)

            }

        }, 500)*/

 

 

    })

    videoObj.on("play", function () {

        setTimeout(function () {

            if (!app.page.question) {

                app.pageShow('question');

                app.close();

                // app.popTwoClose();

                setTimeout(function () {

                    question.update();

                    question.slideTo(0, 0);

                }, 100)

            }

        }, 500)

 

 

    });

    videoObj.on("timeupdate", function () {

        var currentTime = videoObj.currentTime()

        if (app.queIndex > 0) {

            if (app.myAnswerIndex == null && currentTime < app.videoPos[app.queIndex - 1].starPos) {

                videoObj.play()

            }

        }

 

 

        if (typeof(app.queIndex) == "string") {

            if ((app.videoPos[(app.queIndex)].starPos) - currentTime > .5 && (app.videoPos[app.queIndex].starPos) - currentTime > 0) {

                videoObj.play()

            }

            return;

        }

 

 

        if (currentTime - (app.videoPos[app.queIndex].starPos) > .5 && currentTime - app.videoPos[(app.queIndex)].starPos > 0) {

            if (app.queIndex == app.videoPos.length - 1) {

                app.popShow('gameEnd');

                return;

            }

            app.queIndex = String(app.queIndex)

            videoObj.pause();

        }

    })

})

 

你可能感兴趣的:(web)