Created
June 4, 2016 03:55
-
-
Save rodvlopes/eee14fb55da8e264caa93b320b352567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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