Skype có chức năng sẵn có khi phát lại iTunes bị tạm dừng và tiếp tục tự động khi có cuộc gọi đến. Sẽ rất thú vị khi có một cái gì đó tương tự cho Spotify. Cả hai cung cấp một API python để điều này dường như là con đường rõ ràng để đi xuống.Cách lập trình tạm dừng spotify khi có cuộc gọi đến trên skype
5
A
Trả lời
6
Tôi đã có lỗi khi thực hiện việc này trong python. Nó chạy trong nền dưới dạng một daemon, tạm dừng/nối lại spotify khi có cuộc gọi đến. Nó sử dụng các thư viện Python cho Skype & Spotify:
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)