Last active
February 13, 2017 22:32
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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