Audio sink for systems using ALSA, e.g. most Linux systems.
This audio sink requires pyalsaaudio. pyalsaaudio is probably packaged in your Linux distribution.
For example, on Debian/Ubuntu you can install it from APT:
sudo apt-get install python-alsaaudio
Or, if you want to install pyalsaaudio inside a virtualenv, install the ALSA development headers from APT, then pyalsaaudio:
sudo apt-get install libasound2-dev
pip install pyalsaaudio
The device keyword argument is passed on to alsaaudio.PCM. Please refer to the pyalsaaudio documentation for details.
Example:
>>> import spotify
>>> session = spotify.Session()
>>> audio = spotify.AlsaSink(session)
>>> loop = spotify.EventLoop(session)
>>> loop.start()
# Login, etc...
>>> track = session.get_track('spotify:track:3N2UhXZI4Gf64Ku3cCjz2g')
>>> track.load()
>>> session.player.load(track)
>>> session.player.play()
# Listen to music...
Turn off the audio sink.
This disconnects the sink from the relevant session events.
Audio sink for PortAudio.
PortAudio is available for many platforms, including Linux, OS X, and Windows. This audio sink requires PyAudio. PyAudio is probably packaged in your Linux distribution.
On Debian/Ubuntu you can install PyAudio from APT:
sudo apt-get install python-pyaudio
Or, if you want to install PyAudio inside a virtualenv, install the PortAudio development headers from APT, then PyAudio:
sudo apt-get install portaudio19-dev
pip install --allow-unverified=pyaudio pyaudio
On OS X you can install PortAudio using Homebrew:
brew install portaudio
pip install --allow-unverified=pyaudio pyaudio
For an example of how to use this class, see the AlsaSink example. Just replace AlsaSink with PortAudioSink.
Turn off the audio sink.
This disconnects the sink from the relevant session events.