0

Is there anyway for me to play a music stream (google play music, I already got the streamURL) in the raspberry pi via node? (and also, output it to audio port).

1

If you are using nodejs, try using the nodejs groove module which supports network streams and playback control. This module contains native code which requires libgroove.

To install libgroove for raspbian, I have followed the following guide and succeeded: Turn Your Raspberry Pi Into a Music Player Server

-1

Use Simon Weber's gmusicapi python library to access Google Play Music

First install gmusicapi and mplayer

pip install gmusicapi
apt-get install mplayer

Then use my sample code. Any comments are welcome. I couldn't solve the 'device_id' problem in Mobileclient.

#!/usr/bin/env python
# Plays random song from Google Play Music Library
# Requirements : 
# gmusicapi - http://unofficial-google-music-api.readthedocs.org/en/latest/
# mplayer   - 

from gmusicapi import Mobileclient
from gmusicapi import Webclient
import subprocess
from random import randint

api = Mobileclient()
api.login('user@gmail.com', 'gmail_password')

api1 = Webclient()
api1.login('user@gmail.com', 'gmail_password')

devices = api1.get_registered_devices()
device_id = (devices[1]['id']).replace("0x","")

library = api.get_all_songs()

num = randint(1, len(library))

song_id = library[num]["id"]
song_url = api.get_stream_url(song_id,device_id)

api.logout()
api1.logout()

subprocess.call(["/usr/bin/mplayer", song_url])

Not the answer you're looking for? Browse other questions tagged or ask your own question.