Last active
April 23, 2019 14:28
-
-
Save battis/ea43e0eea00e478e2298f2828f903ea6 to your computer and use it in GitHub Desktop.
Exploit iOS autoplay-on-connect bug for greater joy
This file contains 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
property prefix : "A A " | |
property current : "Current First Play Track" | |
property next : "Next First Play Track" | |
on run | |
demoteCurrentTrack() | |
promoteNextTrack() | |
end run | |
on demoteCurrentTrack() | |
tell application "iTunes" | |
repeat with t in every track of playlist named current | |
if name of t starts with prefix then | |
set name of t to ((characters ((length of prefix) + 1) thru -1 of (name of t as string)) as string) | |
end if | |
end repeat | |
end tell | |
end demoteCurrentTrack | |
on promoteNextTrack() | |
tell application "iTunes" | |
repeat with t in every track of playlist named next | |
set name of t to (prefix & name of t) | |
end repeat | |
end tell | |
refreshPlaylist(next) | |
end promoteNextTrack | |
on refreshPlaylist(playlistName) | |
tell application "iTunes" | |
delete tracks in playlist named playlistName | |
end tell | |
end refreshPlaylist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found myself vexed by the way iOS arbitrarily chooses to play a song whenever I connect my phone to my car. Vexed because it's a dumb thing to do, and vexed because I had no control over which song got played, because it was always just the first one alphabetically.
But wait... that means that I do have control!
I created three playlists in my iTunes library. First, a playlist of songs that I might want to hear as I plugged my phone into my car:
Then a playlist that randomly selects one of those songs:
And then a playlist that shows all of my songs from that pool that have been tricked out to be alphabetically first in my library:
And then I wrote a little script that renames songs to move them between those playlists and (for completeness), scheduled cron to call that script every night: