This is a simple Spotify player. It is controlled with JSON commands via a TCP socket.
{
"command": "queue_add",
"type": "uri",
"uri": "<spotify uri>"
}
{
"command": "queue_delete",
"index": 0
}
{
"command": "queue_move",
"from": 0,
"to": 1
}
{
"command": "queue"
}
play_next
not implementedplay_prev
not implementedplay
not implementedstop
not implemented
{
"command": "playlists",
"user_data": "<optional data that will be returned in the response>"
}
{
"command": "playlist",
"type": "<on|off>",
"uri": "<spotify playlist uri>"
}
{
"command": "search",
"type": "<all|artist|album|track>",
"query": "<query>",
"user_data": "<optional data that will be returned in the response>"
}
metadata <spotify uri>
Get metadata for the given URI. not implementedimage <spotify uri>
Get a base64 encoded image for the given URI. not implemented
Responses are given as utf-8 encoded json objects, terminated with . The messages will always contain a type
field. Example response from queueing a song:
{
"type": "queue_uri",
"success": true,
"message": "Track added to the queue."
}
not implemented Once every second the server will send out status updates containing information about the current status of the player. Here's an example of a status update:
{
"type": "status",
"status": "playing",
"playtime": 123
}
- Get the debian image
- Install required libraries and tools
- git:
sudo apt-get install git
- alsa-utils:
sudo apt-get install alsa-utils
- To make sure that the audio-driver is loaded run
sudo modprobe snd_bcm2835
- To make sure that the audio-driver is loaded run
- libao:
sudo apt-get install libao-dev
- libspotify: Get the latest version here (eabi-armv6hf architecture, tested with release 12.1.103 beta) and follow the install instructions.
- libevent: Get the latest 2.1 alpha here and follow the instructions.
- jansson: Get latest version here (tested with release 2.4) and follow the instructions.
- git:
- Get your API key from spotify (link) and save it in the src directory as key.h
- Go into the src directory and run
make
- You're good to go. Run
./server -u <username> -p <password>
to start the server. Default port is 3579
Possible problems:
If you run into problems with an error message like error while loading shared libraries: libevent-2.1.so.1: cannot open shared object file: No such file or directory
your library path must be updated. You can do that by adding /usr/local/lib
to the /etc/ld.so.conf
file and then run sudo ldconfig
If you have problems with stuttering playback or other similar audio problems, try installing PulseAudio; sudo apt-get install libpulse-dev
As this is not finished in any way, there's guaranteed to be bugs/crashes/memory leaks and other problems, so be aware of that.
Copyright (C) 2013 Sigurd Ljødal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.