oldvideo.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. var jvideo = jQuery(this);
  2. var video = this;
  3. if (!jvideo.parent().hasClass("html5vid")) {
  4. jvideo.wrap('<div class="html5vid" style="position:relative;top:0px;left:0px;width:auto;height:auto"></div>');
  5. }
  6. var html5vid = jQuery(this).parent();
  7. // WAITING FOR META DATAS
  8. if (video.addEventListener)
  9. video.addEventListener("loadedmetadata",function() {
  10. html5vid.data('metaloaded',1);
  11. });
  12. else
  13. video.attachEvent("loadedmetadata",function() {
  14. html5vid.data('metaloaded',1);
  15. });
  16. if (!jvideo.hasClass("HasListener")) {
  17. jvideo.addClass("HasListener");
  18. if (nextcaption.data('dottedoverlay')!="none" && nextcaption.data('dottedoverlay')!=undefined)
  19. if (nextcaption.find('.tp-dottedoverlay').length!=1)
  20. html5vid.append('<div class="tp-dottedoverlay '+nextcaption.data('dottedoverlay')+'"></div>');
  21. if (jvideo.attr('control') == undefined ) {
  22. if (html5vid.find('.tp-video-play-button').length==0)
  23. html5vid.append('<div class="tp-video-play-button"><i class="revicon-right-dir"></i><div class="tp-revstop"></div></div>');
  24. html5vid.find('video, .tp-poster, .tp-video-play-button').click(function() {
  25. if (html5vid.hasClass("videoisplaying"))
  26. video.pause();
  27. else
  28. video.play();
  29. })
  30. }
  31. if (nextcaption.data('forcecover')==1 || nextcaption.hasClass('fullscreenvideo')) {
  32. if (nextcaption.data('forcecover')==1) {
  33. updateHTML5Size(html5vid,opt.container);
  34. html5vid.addClass("fullcoveredvideo");
  35. nextcaption.addClass("fullcoveredvideo");
  36. }
  37. html5vid.css({width:"100%", height:"100%"});
  38. }
  39. video.addEventListener("play",function() {
  40. html5vid.addClass("videoisplaying");
  41. punchgs.TweenLite.to(html5vid.find('.tp-poster'),0.1,{autoAlpha:0});
  42. if (nextcaption.data('volume')=="mute")
  43. video.muted=true;
  44. if (nextcaption.data('videoloop')!="loopandnoslidestop") {
  45. opt.container.trigger('stoptimer');
  46. opt.container.trigger('revolution.slide.onvideoplay');
  47. }
  48. opt.videoplaying=true;
  49. if (nextcaption.data('videoloop')=="loopandnoslidestop") {
  50. opt.videoplaying=false;
  51. opt.container.trigger('starttimer');
  52. opt.container.trigger('revolution.slide.onvideostop');
  53. }
  54. });
  55. video.addEventListener("pause",function() {
  56. html5vid.removeClass("videoisplaying");
  57. opt.videoplaying=false;
  58. opt.container.trigger('starttimer');
  59. opt.container.trigger('revolution.slide.onvideostop');
  60. });
  61. video.addEventListener("ended",function() {
  62. html5vid.removeClass("videoisplaying");
  63. opt.videoplaying=false;
  64. opt.container.trigger('starttimer');
  65. opt.container.trigger('revolution.slide.onvideostop');
  66. if (opt.nextslideatend==true)
  67. opt.container.revnext();
  68. });
  69. }
  70. punchgs.TweenLite.set(html5vid.find('.tp-poster'),{autoAlpha:1});
  71. var autoplaywason = false;
  72. if (nextcaption.data('autoplayonlyfirsttime') == true || nextcaption.data('autoplayonlyfirsttime')=="true")
  73. autoplaywason = true;
  74. clearInterval(html5vid.data('interval'));
  75. html5vid.data('interval',setInterval(function() {
  76. if (html5vid.data('metaloaded')==1 || video.duration!=NaN) {
  77. clearInterval(html5vid.data('interval'));
  78. var mediaaspect=16/9;
  79. if (nextcaption.data('aspectratio')=="4:3") mediaaspect=4/3;
  80. html5vid.data('mediaAspect',mediaaspect);
  81. if (html5vid.closest('.tp-caption').data('forcecover')==1) {
  82. updateHTML5Size(html5vid,opt.container);
  83. html5vid.addClass("fullcoveredvideo");
  84. }
  85. jvideo.css({display:"block"});
  86. opt.nextslideatend = nextcaption.data('nextslideatend');
  87. // IF VIDEO SHOULD BE AUTOPLAYED
  88. if (nextcaption.data('autoplay')==true || autoplaywason==true) {
  89. setTimeout(function(){
  90. if (nextcaption.data('videoloop')=="loopandnoslidestop") {
  91. setTimeout(function() {
  92. opt.videoplaying=false;
  93. opt.container.trigger('starttimer');
  94. opt.container.trigger('revolution.slide.onvideostop');
  95. },900);
  96. } else {
  97. opt.videoplaying=true;
  98. opt.container.trigger('stoptimer');
  99. opt.container.trigger('revolution.slide.onvideoplay');
  100. }
  101. },200);
  102. if (nextcaption.data('forcerewind')=="on" && !html5vid.hasClass("videoisplaying"))
  103. if (video.currentTime>0) video.currentTime=0;
  104. if (nextcaption.data('volume')=="mute")
  105. video.muted = true;
  106. html5vid.data('timerplay',setTimeout(function() {
  107. if (nextcaption.data('forcerewind')=="on" && !html5vid.hasClass("videoisplaying"))
  108. if (video.currentTime>0) video.currentTime=0;
  109. if (nextcaption.data('volume')=="mute")
  110. video.muted = true;
  111. setTimeout(function() {
  112. video.play();
  113. },500);
  114. },10+nextcaption.data('start')));
  115. }
  116. if (html5vid.data('ww') == undefined) html5vid.data('ww',jvideo.attr('width'));
  117. if (html5vid.data('hh') == undefined) html5vid.data('hh',jvideo.attr('height'));
  118. if (!nextcaption.hasClass("fullscreenvideo") && nextcaption.data('forcecover')==1) {
  119. try{
  120. html5vid.width(html5vid.data('ww')*opt.bw);
  121. html5vid.height(html5vid.data('hh')*opt.bh);
  122. } catch(e) {}
  123. }
  124. clearInterval(html5vid.data('interval'));
  125. }
  126. }),100);