Skip to content

Instantly share code, notes, and snippets.

@nbogie
Last active February 13, 2017 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbogie/c9f934927dc3d307192634462c1aaab4 to your computer and use it in GitHub Desktop.
Save nbogie/c9f934927dc3d307192634462c1aaab4 to your computer and use it in GitHub Desktop.
applescript and js for midipipe to play/pause youtube video in chrome via a midi event.
on runme(message)
tell application "Google Chrome"
if (item 1 of message = 191) then
# Play or pause a video.
repeat with t in tabs of windows
tell t
if URL starts with "http://www.youtube.com/watch" or URL starts with "https://www.youtube.com/watch" then
if (item 1 of message = 191) and (item 2 of message = 117) and (item 3 of message > 0) then
execute javascript "
var v = document.querySelector('video');
if (v.paused) {
v.play();
}
else {
v.pause();
}
"
exit repeat
end if
end if
end tell
end repeat
end if
end tell
end runme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment