Advertisement
artursn

Untitled

Mar 30th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.18 KB | None | 0 0
  1. p.intitHTMLPlayer = function(v, cPath, doc, ph, video) {
  2. v.PlayVideo = function (elem, video) {
  3. if (!video) {
  4. video = this.videoTag;
  5. }
  6. if (!elem) {
  7. elem = this.btn_pause;
  8. }
  9. video.play();
  10. elem.style.display = 'none';
  11. };
  12.  
  13. v.MuteVideo = function (elem, video) {
  14. if (!video) {
  15. video = this.videoTag;
  16. }
  17. if (!elem) {
  18. elem = this.btn_sound;
  19. }
  20. if (video.muted) {
  21. elem.src = cPath + "/scripts3/plugins/video/img/unmute_cr.png";
  22. elem.title = 'Выключить звук';
  23. }
  24. if (!video.muted) {
  25. elem.src = cPath + "/scripts3/plugins/video/img/mute_cr.png";
  26. elem.title = 'Включить звук';
  27. }
  28. video.muted = !video.muted;
  29. };
  30.  
  31. v.doPlayer = function () {
  32. v.all_div = doc.createElement("div");
  33. v.all_div.style.width = video.width + 'px';
  34. v.all_div.style.height = video.height + 'px';
  35. v.all_div.style.position = 'fixed';
  36. //v.all_div.style.display = 'inline-block';
  37. v.all_div.style.left = 'calc(50% - ' + v.all_div.style.width + '/2)';
  38. v.all_div.style.top = 'calc(50% - ' + v.all_div.style.height + '/2)';
  39. v.videoTag = doc.createElement("video");
  40. v.videoTag.width = video.width || 728;
  41. v.videoTag.height = video.height || 600;
  42. v.videoTag.style.backgroundColor = 'Black';
  43. v.videoTag.style.zIndex = '0';
  44. v.videoTag.preload = 'metadata';
  45. v.videoTag.id = 'video_' + ph;
  46. v.videoTag.src = video.imageUrl.replace(/\.flv/i,'.mp4');
  47. v.videoTag.muted = video.autoSound > 0 ? false : true;
  48. v.videoTag.autoplay = video.autoPlay > 0 && !video.videoInPage && !video.videoTakeOver ? true : false;
  49. v.videoTag.onpause = function(){
  50. if (v.btn_pause) {
  51. v.btn_pause.style.display = '';
  52. }
  53. };
  54. v.videoTag.oncontextmenu = function() {
  55. //this.click();
  56. return false;
  57. };
  58.  
  59. v.btn_pause = doc.createElement("img");
  60. v.btn_pause.src = cPath + "/scripts3/plugins/video/img/Play_cr.png"; v.btn_pause.title = 'Играть сначала';
  61. /*v.btn_pause.onclick = function(){
  62. v.PlayVideo(this, v.videoTag);
  63. }*/
  64. v.btn_pause.setAttribute('onmouseover', 'this.style.width = "96px";this.style.height = "96px";');
  65. v.btn_pause.setAttribute('onmouseout', 'this.style.width = "92px";this.style.height = "92px";');
  66. v.btn_pause.style.cursor = 'pointer';
  67. v.btn_pause.style.backgroundColor = '#CCD0DB';
  68. v.btn_pause.style.zIndex = '1';
  69. v.btn_pause.style.width = "96px";
  70. v.btn_pause.style.height = "96px";
  71. v.btn_pause.style.borderRadius = '8px';
  72. v.btn_pause.style.display = video.autoPlay > 0 && !video.videoInPage ? 'none' : '';
  73. v.btn_pause.style.position = 'absolute';
  74. v.btn_pause.style.left = 'calc(50% - ' + v.btn_pause.style.width + '/2)';
  75. v.btn_pause.style.top = 'calc(50% - ' + v.btn_pause.style.height + '/2)';
  76.  
  77. v.btn_sound = doc.createElement("img");
  78.  
  79. //v.videoTag.muted = true;
  80. v.btn_sound.src = cPath + "/scripts/plugins/video/img/" + (v.videoTag.muted ? '' : 'un') + "mute_cr.png";
  81. v.btn_sound.title = v.videoTag.muted ? 'Включить звук' : 'Выключить звук';
  82.  
  83.  
  84. /*if (cr.isWithSound && bn.IsMatchSiteFormatSound) {
  85. v.videoTag.muted = false;
  86. v.videoTag.volume = 0.3;
  87. v.btn_sound.src = asm.mirrorPath + "/scriptlib/video/img/unmute_cr.png";
  88. v.btn_sound.title = 'Âûêëþ÷èòü çâóê';
  89. }
  90. else {
  91. v.videoTag.muted = true;
  92. v.btn_sound.src = asm.mirrorPath + "/scriptlib/video/img/mute_cr.png";
  93. v.btn_sound.title = 'Âêëþ÷èòü çâóê';
  94. }
  95. */
  96.  
  97.  
  98. /*v.btn_sound.onclick = function(){
  99. v.MuteVideo(this, v.videoTag);
  100. } */
  101. v.btn_sound.setAttribute('onmouseover', 'this.style.width = "22px";this.style.height = "22px";');
  102. v.btn_sound.setAttribute('onmouseout', 'this.style.width = "20px";this.style.height = "20px";');
  103. v.btn_sound.style.cursor = 'pointer';
  104. v.btn_sound.style.display = 'inline';
  105. v.btn_sound.style.backgroundColor = '#CCD0DB';
  106. v.btn_sound.style.borderRadius = '2px';
  107. v.btn_sound.style.width = "20px";
  108. v.btn_sound.style.height = "20px";
  109. v.btn_sound.style.zIndex = '1';
  110. v.btn_sound.style.position = 'absolute';
  111. v.btn_sound.style.right = '4px';
  112. v.btn_sound.style.bottom = '6px';
  113. v.btn_sound.style.display = '';
  114.  
  115.  
  116. v.btn_close = doc.createElement("img");
  117. v.btn_close.src = cPath + "/scripts/plugins/video/img/close.png";
  118. v.btn_close.title = 'Закрыть';
  119. //v.btn_close.setAttribute('onclick', v + '.stopVideoAdmixer()');
  120. v.btn_close.style.cursor = 'pointer';
  121. //v.btn_close.style.display = 'none';
  122. v.btn_close.style.backgroundColor = '#CCD0DB';
  123. v.btn_close.style.borderRadius = '2px';
  124. v.btn_close.style.width = "20px";
  125. v.btn_close.style.height = "20px";
  126. v.btn_close.style.top = '-25px';
  127. v.btn_close.style.right = '5px';
  128. v.btn_close.style.zIndex = '1';
  129. v.btn_close.style.position = 'absolute';
  130.  
  131. v.center = doc.createElement("center");
  132. 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;';
  133. v.center.innerHTML = 'Перейти на сайт рекламодателя';
  134. v.center.style.left = 'calc(50% - ' + v.center.style.width + '/2)';
  135. //v.center.style.display = 'none';
  136. v.all_div.appendChild(v.center);
  137.  
  138. v.all_div.appendChild(v.btn_close);
  139. v.all_div.appendChild(v.btn_pause);
  140. v.all_div.appendChild(v.btn_sound);
  141. v.all_div.appendChild(v.videoTag);
  142.  
  143. return v.all_div;
  144. //currPh.appendChild(v.all_div);
  145.  
  146. /*if (!isPreview) {
  147. v.initAdsFor(tagUrl);
  148. }*/
  149. };
  150. };
  151. p.getLocalPlayer = function(_p){
  152. var av = {};
  153. av.container = null;
  154. av.player = null;
  155.  
  156. av.duration = null;
  157. av.complete = false;
  158. av.started = false;
  159. av.onComplete = function(){};
  160. av.timeupdate = function(){};
  161. av.prevent = admixerML.helpers.preventDefault;
  162. av.interval = null;
  163. av.canSkip = false;
  164. av.show = {};
  165. av.def = function(){
  166. //av.player.video.src = "";
  167. //av.duration = null;
  168. //av.trackers = {};
  169. //av.wasSent = {};
  170. av.complete = false;
  171. av.started = false;
  172. if (av.interval) {
  173. window.clearInterval(av.interval);
  174. av.interval = null;
  175. }
  176. av.canSkip = false;
  177. av.player.progress(0);
  178. //av.player.showPause();
  179. //av.player.showUnmute();
  180. };
  181. av.track = function(name,attr){
  182. if (typeof av.eventTrack === 'function') {
  183. av.eventTrack(name,(attr|| ''));
  184. }
  185. };
  186. av.init = function(params){
  187. av.onComplete = params.onComplete || function(){};
  188. av.volume = params.volume / 100 || 0.5;
  189. av.container = params.container;
  190. av.eventTrack = params.eventTrack || {};
  191. av.src = params.src.replace(/(\.flv)$/i,'.mp4') || '';
  192. av.skipTime = params.skipTime > -1 ? params.skipTime : 5;
  193. av.show.fullscreen = params.fullscreen === 0 ? 0 : 1;
  194. av.show.skip = params.skip === 1 ? 1 : 0;
  195. av.onClickPlay = params.onClickPlay || function(){};
  196. av.onClickSkip = params.onClickSkip || function(){};
  197. var player = av.initPlayer();
  198. var container = params.container;
  199. player.appendTo(container);
  200. return player;
  201. };
  202. av.initWrap = function(){
  203. var wrap = document.createElement("div");
  204. wrap.style.width = "100%";
  205. wrap.style.height = "100%";
  206. wrap.style.background = "black";
  207. wrap.style.position = "absolute";
  208. wrap.style.top = "0px";
  209. wrap.style.left = "0px";
  210. wrap.style.zIndex = 999999;
  211. wrap.style.display = "";
  212. wrap.onclick = function(){av.track('adClick')};
  213. wrap.onselectstart = function(){return false;};
  214. return wrap;
  215. };
  216. av.initVideo = function(){
  217. var video = document.createElement("video");
  218. video.src = av.src;
  219. video.style.width = "100%";
  220. video.style.height = "100%";
  221. video.autoplay = false;
  222. video.controls = false;
  223. video.volume = av.volume;
  224. video.muted = true;
  225. video.oncontextmenu = function(){return false;};
  226. video.addEventListener("loadedmetadata",function(){
  227. av.duration = video.duration;
  228. });
  229. av.timeupdate = function(){
  230. var current = video.currentTime;
  231. var percent = (current / av.duration) * 100;
  232. if (percent >= 100) {
  233. av.complete = true;
  234. av.track("adVastEvent",100);
  235. if (av.interval) {
  236. window.clearInterval(av.interval);
  237. av.interval = null;
  238. }
  239. av.player.video.currentTime = 0;
  240. av.player.progress(0);
  241. av.player.pause();
  242. //av.player.hide();
  243. av.onComplete();
  244. return false;
  245. }
  246. else if (percent >= 75) {
  247. av.track("adVastEvent",75);
  248. }
  249. else if (percent >= 50) {
  250. av.track("adVastEvent",50);
  251. }
  252. else if (percent >= 25) {
  253. av.track("adVastEvent",25);
  254. } else {
  255. av.track("adPlay");
  256. }
  257. av.player.progress(percent);
  258. var time = current > av.skipTime ? "" : parseInt(av.skipTime - current) + 1;
  259. av.player.skipText("skip " + time);
  260. if (time === "" && current > 0) {
  261. av.canSkip = true;
  262. }
  263. };
  264. /*video.addEventListener("play",function(){
  265. if (!av.started) {
  266. av.started = true;
  267. av.interval = setInterval(av.timeupdate,1000 / 60);
  268. }
  269. });*/
  270. return video;
  271.  
  272. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement