Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nbogie
Last active February 13, 2017 22:32
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/ba3f661aff4fc512abd5bad261eee89f to your computer and use it in GitHub Desktop.
Save nbogie/ba3f661aff4fc512abd5bad261eee89f to your computer and use it in GitHub Desktop.
midipipe midi youtube playback controller applescript. This one maps a continuous controller's value to the playback speed.
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
if (item 1 of message = 191) and (item 2 of message = 17) and (item 3 of message > 0) then
set speed to (3 * (item 3 of message) / 127)
execute javascript "
var v = document.querySelector('video');
v.playbackRate = " & speed & ";
"
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