Posted By

chrisaiv on 06/22/12


Tagged

googletv


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

VeXHarbinger


Javascript: Controlling video using D-Pad control


 / Published in: JavaScript
 

If you happen to have a GoogleTV and you want to control using the D-Pad, here's how you do it using a switch case and jQuery.

  1. /***************************************
  2. D-pad
  3. ***************************************/
  4. var video = $("video");
  5. $(window).bind("keydown", onKeyDownHandler );
  6. function onKeyDownHandler( e ){
  7. switch( e.keyCode ){
  8. case 227:
  9. //fast forward 10 seconds
  10. video.currentTime += 10;
  11. break;
  12. case 228:
  13. //rewind by 10 seconds
  14. video.currentTime -= 10;
  15. break;
  16. case 179:
  17. if( video.paused ) video.play();
  18. else video.pause();
  19. break;
  20. }
  21. }

Report this snippet  

You need to login to post a comment.