Guest User

Untitled

a guest
Mar 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. const cc = document.querySelector('.vjs-text-track-display');
  2. const video = document.querySelector('video.vjs-tech');
  3. const playButton = document.querySelector('.vjs-control-bar .vjs-play-control');
  4.  
  5. const isPlaying = () => Array.from(playButton.classList).includes('vjs-paused');
  6.  
  7. let play = isPlaying();
  8. const toggleCC = () => {
  9. play = !play;
  10. cc.style.display = play ? 'none' : 'inherit';
  11. }
  12.  
  13. const keyboardHandler = (event) => {
  14. if (event.keyCode === 32) toggleCC();
  15. };
  16.  
  17.  
  18. document.body.addEventListener('keydown', keyboardHandler);
  19. video.addEventListener('click', toggleCC);
  20. playButton.addEventListener('click', toggleCC);
  21. toggleCC();
Add Comment
Please, Sign In to add comment