newvideo.js 5.1 KB

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