video html5 操作,HTML5 Video 操作

这段代码实现了一个视频播放器的逻辑,包括视频加载、播放、重播和广告插入等功能。当视频结束时,会根据预设的视频源自动切换到下一个视频或显示后贴片内容。视频的音量、分享、重播操作也被处理。此外,还有一个显示倒计时并跳转至下一视频的定时器功能。
摘要由CSDN通过智能技术生成

//html5 video

var Html5Page={};

Html5Page.Html5Video = new function () {

var _this = this;

var nextvideoobj;

this.onVideoPageLoad = function () {

var $video = $('video');

var $vid = $video.get(0);

if ($vid) {

$video.bind("ended", function () {

_this.nextStartVideo();

});

$vid.volume = 0.8;

}

if ($("#shareAction")) {

$("#shareAction").bind("click", function () {

Msn.VideoPlayer.ShowShareOverlay();

});

}

if ($("#RepalyAction")) {

$("#RepalyAction").bind("click", function () {

_this.Replay();

});

}

};

this.nextStartVideo = function () {

if (v_ad != '') {

if (v_video2 != '') {

this.playVideos('video2');

}

else if (v_main != '') {

this.playVideos('main');

}

else {

this.showPostroll();

}

}

else {

if (v_video2 != '') {

if (v_main != '') {

this.playVideos('main');

}

else {

this.showPostroll();

}

}

else {

this.showPostroll();

}

}

};

this.playVideos = function (type) {

var $video = $('video');

var $vid = $video.get(0);

$video.unbind("ended");

if (type == 'ad') {

$vid.src = v_ad;

$vid.load();

$vid.play();

if (v_video2 != '') {

$video.bind("ended", function () {

_this.playVideos('video2');

});

}

else if (v_main != '') {

$video.bind("ended", function () {

_this.playVideos('main');

});

}

else {

$video.bind("ended", function () {

_this.showPostroll();

});

}

}

else if (type == 'video2') {

$vid.src = v_video2;

$vid.load();

$vid.play();

if (v_main != '') {

$video.bind("ended", function () {

_this.playVideos('main');

});

}

else {

$video.bind("ended", function () {

_this.showPostroll();

});

}

}

else if (type == 'main') {

$vid.src = v_main;

$vid.load();

$vid.play();

$video.bind("ended", function () {

_this.showPostroll();

});

}

};

this.Replay = function () {

var $video = $('video');

var $endScreen = $('#episodesPostBox');

$endScreen.hide();

$video.show();

$video.css({ display: 'block' })

if (v_video2 != '') {

this.playVideos('video2');

}

else if (v_ad != '') {

this.playVideos('ad');

}

else if (v_main != '') {

this.playVideos('main');

}

};

var stop = null;

this.showPostroll = function () {

var $video = $('video');

$video.attr("width", 618);

$video.attr("height", 348);

$video.hide();

var $endScreen = $('#episodesPostBox');

nextvideoobj = (get next video url)//

//set the next video content

$("#imgnextvideo").attr("src", nextvideoobj.imageUrl);

$("#imgnextvideo").attr("imgUrl", nextvideoobj.imageUrl);

$("#nextvideoTitle").text(nextvideoobj.title);

$("#nextvideotext").text(nextvideoobj.text);

$("#nextvideolink").attr("href", "/" + nextvideoobj.linkUrl);

$endScreen.show();        stop = window.setInterval(function () {            _this.showTime();        }, 1000);    };    this.showTime = function () {        var labletime = $('#lbTime');        if (labletime.text() == "0") {            window.clearInterval(stop);            window.location.href = v_baseurl + nextvideoobj.linkUrl;            return false;        }        else {            labletime.text(parseInt(labletime.text()) * 1 - 1);        }    }};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值