Simple music player (WAV/OGG) written in python with pygame
- docker >= 19.03.5
Run ./bin/build-image. After it's done, run ./bin/run-player to start.
The HTTP API will be available on localhost:8080.
- vagrant >= 2.2.6
- virtualbox <= 6.0 (6.1 won't work)
- GitBash
- vagrant >= 2.2.6
- virtualbox <= 6.0 (6.1 won't work)
Download GitBash (for Windows)
Since we can't easily share the audio devices on a OSX or Windows hosts, this project comes with a Vagrantfile to run everything inside a Virtual Machine.
Run vagrant up and when it is done, run vagrant reload so it restarts the VM
and reloads the audio drivers. Then, to connect to the VM, simply run vagrant ssh
Once inside the VM (vagrant ssh), run ./bin/build-image and
./bin/run-player to start the API. From now on, all endpoints will be
accessible on localhost:8080, even from outside the VM.
Check the audio volume and the selected audio device.
You're probably using a non-standard audio card, so you need to change the audio
controller. Open the Vagrantfile and at line 67, change the controller to
match the correct one. For AC97, change the audiocontroller value from hda
to ac97. And for soundblaster, change it to sb16.
Then do vagrant reload and it will load the new controller.
Do a vagrant reload to restart the VM.
Every time you start the player, it will ask you for the Card ID. That is the ID
of your soundcard. It will load a list of available devices and you have to
choose the correct one. Look for devices that are NOT HDMI. If you choose one
and it doesn't work, simply restart the player and pick another one :) In most
cases, the correct choice will be 0 or the device with Analog in its name.
You can control the player using the HTTP API listening on port 8080.
Play by name (local file) or by url (download and play).
Parameters (one or the other, name has precedence):
- name
- url
Play by name:
curl -X POST localhost:8080/play?name=cantina-band.wav
Play by url:
curl -X POST localhost:8080/play?url=<asset-url>
Playing by URL will cause the song to be cached, so it is available to be played by name
curl -X POST localhost:8080/stop
curl -X POST localhost:8080/pause
curl -X POST localhost:8080/unpause
It will download the asset and cache it under the music directory. So it is
available to be played using the name parameter.
curl -X POST localhost:8080/download?url=<asset-url>
It will return playing if it's playing or paused and idle if it's not
playing nor paused.
curl localhost:8080/status