Javascript: Controlling video using D-Pad control


/ Published in: JavaScript
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.