Skip to content

Instantly share code, notes, and snippets.

@rodvlopes
Created June 4, 2016 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodvlopes/eee14fb55da8e264caa93b320b352567 to your computer and use it in GitHub Desktop.
Save rodvlopes/eee14fb55da8e264caa93b320b352567 to your computer and use it in GitHub Desktop.
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