5
Skype有一個內置功能,iTunes播放暫停後會在呼叫進入時自動恢復。如果您有類似的Spotify功能,將會非常好。兩者都提供了一個Python API,因此這似乎是明顯的下降路線。如何以編程方式在skype上打電話時暫停spotify
Skype有一個內置功能,iTunes播放暫停後會在呼叫進入時自動恢復。如果您有類似的Spotify功能,將會非常好。兩者都提供了一個Python API,因此這似乎是明顯的下降路線。如何以編程方式在skype上打電話時暫停spotify
我在python中做過這件事。它作爲一個守護進程在後臺運行,當呼叫來臨時暫停/恢復spotify。它使用Skype的& Spotify的的Python庫:
http://code.google.com/p/pytify/
https://developer.skype.com/wiki/Skype4Py
import Skype4Py
import time
from pytify import Spotify
# Create Skype object
skype = Skype4Py.Skype()
skype.Attach()
# Create Spotify object
spotify = Spotify()
spotifyPlaying = spotify.isPlaying()
# Create handler for when Skype call status changes
def on_call_status(call, status):
if status == Skype4Py.clsInProgress:
# Save current spotify state
global spotifyPlaying
spotifyPlaying = spotify.isPlaying()
if spotify.isPlaying():
print "Call started, pausing spotify"
# Call started, pause Spotify
spotify.stop()
elif status == Skype4Py.clsFinished:
# Call finished, resume Spotify if it was playing
if spotifyPlaying and not spotify.isPlaying():
print "Call finished, resuming spotify"
spotify.playpause()
skype.OnCallStatus = on_call_status
while True:
time.sleep(10)