在视频播放列表之间交替

时间:2014-09-30 21:06:30

标签: jquery video playlists

我有2个视频播放列表。当第一个命中3时,我需要它清除div并运行alt1播放列表。然后当达到3的计数时,我需要它来清除它的div并返回常规函数。我真的很难过这个。

var vidCount = 0;
var halfCount = 0;

$(document).ready(function regular() {
    var videoPlayer = document.getElementById('videoStage');

    videoPlayer.addEventListener("ended", function() {

        if (vidCount == 3) {
            alt1();
        }
        else (vidCount++)
        console.log(vidCount);

        this.pause();

        var videoList = ["internal1", "internal2", "internal3", "internal4", "internal5", "internal6"],
        videoList = videoList[Math.floor(Math.random() * videoList.length)];

        $('#mp4').attr("src", "_ASSETS/_MP4/" + videoList + ".mp4");
        $('#halfAd').css('visbility', 'hidden');

        this.load();
        this.play();
    }, false);

    videoPlayer.play();
});

function alt1 () {
    var halfPlayer = document.getElementById('halfStage');

    halfPlayer.addEventListener("ended", function() {

        if (halfCount == 3) {
            regular();
        }
        else (halfCount++)
        console.log(halfCount);

        this.pause();

        var halfList = ["half1", "half2"],
        halfList = halfList[Math.floor(Math.random() * halfList.length)];

        $('#mp4').attr("src", "_ASSETS/_MP4/" + halfList + ".mp4");
        $('#halfAd').css('visbility', 'visible');

        this.load();
        this.play();
    }, false);

    halfPlayer.play();
};

也许我只是盯着这段代码太久了。任何帮助将不胜感激。一旦我开始工作,我将开始在3个播放列表之间进行随机化。呃,这似乎应该有效。

0 个答案:

没有答案