5

Skypeには、電話がかかってきたときにiTunesの再生を一時停止して自動的に再開する機能が組み込まれています。Spotifyにも同様の機能があると便利です。どちらもPythonAPIを提供しているので、これは明らかに下がるルートのように思われます。

4

1 に答える 1

6

私は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)
于 2010-05-06T08:26:50.443 に答える