//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); } }};