skype

2010-05-06 14 views
5

skype bir arama geldiğinde spotify spotify nasıl bir arama geldiğinde otomatik olarak iTunes oynatma duraklatılır ve devam ettirilir bir dahili işlevi vardır. Spotify için benzer bir şey olması güzel olurdu. Her ikisi de bir python API'sı sağlar, bu yüzden bu, aşılması gereken bariz bir yol gibi görünür.skype

cevap

6

Python'da bunu yaparken bir bıçak gördüm. Arka planda bir daemon olarak çalışır, bir çağrı geldiğinde spotify/duraklatmaya devam eder.

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) 
: Bu Skype & Spotify için Python kütüphanelerini kullanır
İlgili konular