When I am listening to music on iTunes, the music is automatically paused when a Skype call is made. I recently switch to Spotify for my music resource. Can I have the same pausing functionality with Spotify, as with iTunes?
2 Answers
There are multiple ways of achieving this. Here are two possible solutions:
Python. This has been answered on this Stack Overflow question already.
Simplify. One of Simplify's features is auto-pausing on Skype calls:
If you're are using Mac OS (OS X) try this AppleScript I quickly bashed up, (please note I'm not really an OS X developer and my knowledge of AppleScript is, to say the least, 'intermediate')
https://github.com/jhuseinovic/skype-spotify-ctrl
(*
This script was developed by John Huseinovic (john@huseinovic.net)
The purpose of the script is to pause any playing track in Spotify when there is a active/incoming call in skype and resume playing after the call is finished.
The script will only monitor if the both Skype and Spotify are running!
*)
set spotify_status to null
set notificationTitle to "Skype-Spotify Controller"
set call_started to false
set music_was_playing to false
repeat
if application "Skype" is running and application "Spotify" is running then
tell application "Skype"
set calls to «event sendskap» given «class cmnd»:"SEARCH ACTIVECALLS", «class scrp»:"AnsweringScript"
set callID to last word of calls
if callID is not "CALLS" then
using terms from application "Spotify"
set spotify_status to the player state of application "Spotify" as string
end using terms from
set status to «event sendskap» given «class cmnd»:"GET CALL " & callID & " STATUS", «class scrp»:"AnsweringScript"
set caller to «event sendskap» given «class cmnd»:"GET CALL " & callID & " PARTNER_HANDLE", «class scrp»:"AnsweringScript"
set call_started to true
#log "set call_started to " & call_started
if spotify_status = "playing" then
set music_was_playing to true
display notification "Active call with " & last word of caller & "! Spotify was " & spotify_status & ", going to pause it." with title notificationTitle
tell application "Spotify" to pause
end if
else
#log "call_started is " & call_started
if call_started is true and music_was_playing is true then
display notification "Detected terminated Skype call, resuming Spotify! Enjoy =)" with title notificationTitle
tell application "Spotify" to play
end if
set call_started to false
end if
end tell
delay 1
else
delay 10
end if
end repeat