Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function which listen for a Siri command, catch the name of the track, then play it in iTunes.Part of a Siriproxy Plugin. French speaking required.
listen_for /Mac play (.*)/i do |play|
#Only for french speaking !!!
replacements = [ ["My", "Me"], ["col", "Call"], ["radiant", "Radian"] ]
replacements.each {|replacement| play.gsub!(replacement[0], replacement[1])}
#Only for french speaking !!! [End]
itunescheck = system("osascript -e 'if application \"iTunes\" is running then return 1'");
if play==nil then
say "Viva la musica !", spoken: "Vivaa la mousiica !"
system("osascript -e 'tell application \"iTunes\" to play'");
puts '[Info - Plugin "Macintosh"] Telling iTunes to play'
request_completed
else
if itunescheck==true then
system("osascript -e 'tell application \"iTunes\" to play track \"#{play}\"'");
say "Vous écoutez : #{play}" #Currently listening at : {track name}
request_completed #always complete your request! Otherwise the phone will "spin" at the user!
else
say "Je lance la musique…"
system("osascript -e 'tell application \"iTunes\" to play track \"#{play}\"'"); #Telling iTunes to play
sleep 2
# if itunesbugtest==1 then
# say "Il semblerait que le morceau que vous avez demandé n'existe pas."
# request_completed
# else
say "Vous écoutez : #{play}" #Currently listening at : {track name}
request_completed #always complete your request! Otherwise the phone will "spin" at the user!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.