Advertisement
olie480

JS Event Trigger Video

Apr 1st, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.90 KB | None | 0 0
  1. <!-- Triggers a jquery event at a certain time in a video http://jsfiddle.net/XTEWW/6/ -->
  2.  
  3. <!--
  4. HTML
  5. -->
  6. <div id = "showdiv" style="display:none" align="center">
  7.         this is the message that will pop up.
  8. </div>
  9. <video id='myVideo' align="center" margin-top="100px" class='video-js vjs-default-skin' preload='auto' data-setup='{}' width='400' height='300' controls="controls">
  10. <source src='http://www.808.dk/pics/video/gizmo.mp4' type='video/mp4'></source>
  11. </video>
  12.  
  13. <!--
  14. JQUERY
  15. -->
  16. <script>  
  17. function myHandler() {
  18.     $("#showdiv").toggle("slow");
  19. }
  20.  
  21. var runAtTime = function(handler, time) {
  22.      var wrapped = function() {
  23.          if(this.currentTime >= time) {
  24.              $(this).off('timeupdate', wrapped);
  25.              return handler.apply(this, arguments);
  26.         }
  27.      }
  28.     return wrapped;
  29. };
  30.  
  31. $('#myVideo').on('timeupdate', runAtTime(myHandler, 3));
  32.  
  33.  
  34. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement