Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p.intitHTMLPlayer = function(v, cPath, doc, ph, video) {
- v.PlayVideo = function (elem, video) {
- if (!video) {
- video = this.videoTag;
- }
- if (!elem) {
- elem = this.btn_pause;
- }
- video.play();
- elem.style.display = 'none';
- };
- v.MuteVideo = function (elem, video) {
- if (!video) {
- video = this.videoTag;
- }
- if (!elem) {
- elem = this.btn_sound;
- }
- if (video.muted) {
- elem.src = cPath + "/scripts3/plugins/video/img/unmute_cr.png";
- elem.title = 'Выключить звук';
- }
- if (!video.muted) {
- elem.src = cPath + "/scripts3/plugins/video/img/mute_cr.png";
- elem.title = 'Включить звук';
- }
- video.muted = !video.muted;
- };
- v.doPlayer = function () {
- v.all_div = doc.createElement("div");
- v.all_div.style.width = video.width + 'px';
- v.all_div.style.height = video.height + 'px';
- v.all_div.style.position = 'fixed';
- //v.all_div.style.display = 'inline-block';
- v.all_div.style.left = 'calc(50% - ' + v.all_div.style.width + '/2)';
- v.all_div.style.top = 'calc(50% - ' + v.all_div.style.height + '/2)';
- v.videoTag = doc.createElement("video");
- v.videoTag.width = video.width || 728;
- v.videoTag.height = video.height || 600;
- v.videoTag.style.backgroundColor = 'Black';
- v.videoTag.style.zIndex = '0';
- v.videoTag.preload = 'metadata';
- v.videoTag.id = 'video_' + ph;
- v.videoTag.src = video.imageUrl.replace(/\.flv/i,'.mp4');
- v.videoTag.muted = video.autoSound > 0 ? false : true;
- v.videoTag.autoplay = video.autoPlay > 0 && !video.videoInPage && !video.videoTakeOver ? true : false;
- v.videoTag.onpause = function(){
- if (v.btn_pause) {
- v.btn_pause.style.display = '';
- }
- };
- v.videoTag.oncontextmenu = function() {
- //this.click();
- return false;
- };
- v.btn_pause = doc.createElement("img");
- v.btn_pause.src = cPath + "/scripts3/plugins/video/img/Play_cr.png"; v.btn_pause.title = 'Играть сначала';
- /*v.btn_pause.onclick = function(){
- v.PlayVideo(this, v.videoTag);
- }*/
- v.btn_pause.setAttribute('onmouseover', 'this.style.width = "96px";this.style.height = "96px";');
- v.btn_pause.setAttribute('onmouseout', 'this.style.width = "92px";this.style.height = "92px";');
- v.btn_pause.style.cursor = 'pointer';
- v.btn_pause.style.backgroundColor = '#CCD0DB';
- v.btn_pause.style.zIndex = '1';
- v.btn_pause.style.width = "96px";
- v.btn_pause.style.height = "96px";
- v.btn_pause.style.borderRadius = '8px';
- v.btn_pause.style.display = video.autoPlay > 0 && !video.videoInPage ? 'none' : '';
- v.btn_pause.style.position = 'absolute';
- v.btn_pause.style.left = 'calc(50% - ' + v.btn_pause.style.width + '/2)';
- v.btn_pause.style.top = 'calc(50% - ' + v.btn_pause.style.height + '/2)';
- v.btn_sound = doc.createElement("img");
- //v.videoTag.muted = true;
- v.btn_sound.src = cPath + "/scripts/plugins/video/img/" + (v.videoTag.muted ? '' : 'un') + "mute_cr.png";
- v.btn_sound.title = v.videoTag.muted ? 'Включить звук' : 'Выключить звук';
- /*if (cr.isWithSound && bn.IsMatchSiteFormatSound) {
- v.videoTag.muted = false;
- v.videoTag.volume = 0.3;
- v.btn_sound.src = asm.mirrorPath + "/scriptlib/video/img/unmute_cr.png";
- v.btn_sound.title = 'Âûêëþ÷èòü çâóê';
- }
- else {
- v.videoTag.muted = true;
- v.btn_sound.src = asm.mirrorPath + "/scriptlib/video/img/mute_cr.png";
- v.btn_sound.title = 'Âêëþ÷èòü çâóê';
- }
- */
- /*v.btn_sound.onclick = function(){
- v.MuteVideo(this, v.videoTag);
- } */
- v.btn_sound.setAttribute('onmouseover', 'this.style.width = "22px";this.style.height = "22px";');
- v.btn_sound.setAttribute('onmouseout', 'this.style.width = "20px";this.style.height = "20px";');
- v.btn_sound.style.cursor = 'pointer';
- v.btn_sound.style.display = 'inline';
- v.btn_sound.style.backgroundColor = '#CCD0DB';
- v.btn_sound.style.borderRadius = '2px';
- v.btn_sound.style.width = "20px";
- v.btn_sound.style.height = "20px";
- v.btn_sound.style.zIndex = '1';
- v.btn_sound.style.position = 'absolute';
- v.btn_sound.style.right = '4px';
- v.btn_sound.style.bottom = '6px';
- v.btn_sound.style.display = '';
- v.btn_close = doc.createElement("img");
- v.btn_close.src = cPath + "/scripts/plugins/video/img/close.png";
- v.btn_close.title = 'Закрыть';
- //v.btn_close.setAttribute('onclick', v + '.stopVideoAdmixer()');
- v.btn_close.style.cursor = 'pointer';
- //v.btn_close.style.display = 'none';
- v.btn_close.style.backgroundColor = '#CCD0DB';
- v.btn_close.style.borderRadius = '2px';
- v.btn_close.style.width = "20px";
- v.btn_close.style.height = "20px";
- v.btn_close.style.top = '-25px';
- v.btn_close.style.right = '5px';
- v.btn_close.style.zIndex = '1';
- v.btn_close.style.position = 'absolute';
- v.center = doc.createElement("center");
- v.center.style.cssText = 'z-index:2; position:absolute; color: Black; font-size:11px; font-family:Helvetica; cursor:pointer; background-color:#CCD0DB; width: 200px; top:5px; border-radius: 2px; padding-top: 3px; padding-bottom: 4px;';
- v.center.innerHTML = 'Перейти на сайт рекламодателя';
- v.center.style.left = 'calc(50% - ' + v.center.style.width + '/2)';
- //v.center.style.display = 'none';
- v.all_div.appendChild(v.center);
- v.all_div.appendChild(v.btn_close);
- v.all_div.appendChild(v.btn_pause);
- v.all_div.appendChild(v.btn_sound);
- v.all_div.appendChild(v.videoTag);
- return v.all_div;
- //currPh.appendChild(v.all_div);
- /*if (!isPreview) {
- v.initAdsFor(tagUrl);
- }*/
- };
- };
- p.getLocalPlayer = function(_p){
- var av = {};
- av.container = null;
- av.player = null;
- av.duration = null;
- av.complete = false;
- av.started = false;
- av.onComplete = function(){};
- av.timeupdate = function(){};
- av.prevent = admixerML.helpers.preventDefault;
- av.interval = null;
- av.canSkip = false;
- av.show = {};
- av.def = function(){
- //av.player.video.src = "";
- //av.duration = null;
- //av.trackers = {};
- //av.wasSent = {};
- av.complete = false;
- av.started = false;
- if (av.interval) {
- window.clearInterval(av.interval);
- av.interval = null;
- }
- av.canSkip = false;
- av.player.progress(0);
- //av.player.showPause();
- //av.player.showUnmute();
- };
- av.track = function(name,attr){
- if (typeof av.eventTrack === 'function') {
- av.eventTrack(name,(attr|| ''));
- }
- };
- av.init = function(params){
- av.onComplete = params.onComplete || function(){};
- av.volume = params.volume / 100 || 0.5;
- av.container = params.container;
- av.eventTrack = params.eventTrack || {};
- av.src = params.src.replace(/(\.flv)$/i,'.mp4') || '';
- av.skipTime = params.skipTime > -1 ? params.skipTime : 5;
- av.show.fullscreen = params.fullscreen === 0 ? 0 : 1;
- av.show.skip = params.skip === 1 ? 1 : 0;
- av.onClickPlay = params.onClickPlay || function(){};
- av.onClickSkip = params.onClickSkip || function(){};
- var player = av.initPlayer();
- var container = params.container;
- player.appendTo(container);
- return player;
- };
- av.initWrap = function(){
- var wrap = document.createElement("div");
- wrap.style.width = "100%";
- wrap.style.height = "100%";
- wrap.style.background = "black";
- wrap.style.position = "absolute";
- wrap.style.top = "0px";
- wrap.style.left = "0px";
- wrap.style.zIndex = 999999;
- wrap.style.display = "";
- wrap.onclick = function(){av.track('adClick')};
- wrap.onselectstart = function(){return false;};
- return wrap;
- };
- av.initVideo = function(){
- var video = document.createElement("video");
- video.src = av.src;
- video.style.width = "100%";
- video.style.height = "100%";
- video.autoplay = false;
- video.controls = false;
- video.volume = av.volume;
- video.muted = true;
- video.oncontextmenu = function(){return false;};
- video.addEventListener("loadedmetadata",function(){
- av.duration = video.duration;
- });
- av.timeupdate = function(){
- var current = video.currentTime;
- var percent = (current / av.duration) * 100;
- if (percent >= 100) {
- av.complete = true;
- av.track("adVastEvent",100);
- if (av.interval) {
- window.clearInterval(av.interval);
- av.interval = null;
- }
- av.player.video.currentTime = 0;
- av.player.progress(0);
- av.player.pause();
- //av.player.hide();
- av.onComplete();
- return false;
- }
- else if (percent >= 75) {
- av.track("adVastEvent",75);
- }
- else if (percent >= 50) {
- av.track("adVastEvent",50);
- }
- else if (percent >= 25) {
- av.track("adVastEvent",25);
- } else {
- av.track("adPlay");
- }
- av.player.progress(percent);
- var time = current > av.skipTime ? "" : parseInt(av.skipTime - current) + 1;
- av.player.skipText("skip " + time);
- if (time === "" && current > 0) {
- av.canSkip = true;
- }
- };
- /*video.addEventListener("play",function(){
- if (!av.started) {
- av.started = true;
- av.interval = setInterval(av.timeupdate,1000 / 60);
- }
- });*/
- return video;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement