Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class StdoutSink(spotify.sink.Sink):
def __init__(self, session):
self._session = session
self.on()
def _on_music_delivery(self, session, audio_format, frames, num_frames):
assert (
audio_format.sample_type == spotify.SampleType.INT16_NATIVE_ENDIAN)
# print >> sys.stderr, audio_format.sample_type
# print >> sys.stderr, audio_format.sample_rate
# print >> sys.stderr, audio_format.channels
# print >> sys.stderr, audio_format.frame_size()
# print >> sys.stderr, num_frames
sys.stdout.write(frames)
return num_frames
def _close(self):
pass
#to play form the shell using SOX (brew install sox OR apt-get install sox)
python MyPySpotify.py | play -t raw -b 16 -e signed -c 2 -r 44100 -
#for more details check the examples on pyspotify project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.