A web-server/web-application based remote control for Linux 'media-devices', implemented in the Go programming language (actually just an interface to Mplayer).
Small Linux devices are gaining popularity, especially since the 'invention' of ASUS EeePC and of course the Raspberry Pi. One of the many applications of such Linux devices, is functioning as a sort of media player. The Raspberry Pi in particular, since it's not a netbook but just a headless computer.
A mediaplayer is obviously nothing much without some sort of lazy remote controlling :) Wasp's intention is to be that remote control, albeit not in traditional manner. Instead of using LIRC (infrared) or Bluetooth, the controlling is done with a web interface Wasp is providing.
Once Wasp is started, it acts as a webserver to which you can browse to. That means you
can open a browser on Android, iOS, a PC, laptop or netbook to the IP address of the
device where Wasp is running, like http://192.168.1.10:8080/index
. Once opened, it will
provide you with a basic interface where you can:
- Browse for media files in an intuitive manner.
- Play/pause media files.
- Change volume.
- Stop playback.
- and likely some more features added in the future.
The project is of course still in its infancy, but follow these basic steps to start off.
Prerequisites:
- Install a Go compiler.
- Install Mplayer (or use a package manager for your distro).
Build the sources:
Clone the git repository:
git clone git://github.com/krpors/wasp.git
Change directory to the just cloned repository:
cd ./wasp
Set the GOPATH to the current directory:
export GOPATH=$(pwd)
Build the sources:
make
Try invoking the binary:
./bin/wasp
This will create the initial configuration in ${HOME}/.wasp/wasp.properties
. This configuration
sets a few properties as follows:
- Mplayer fifo pipe:
/tmp/mplayer.fifo
- Media directory:
/
(root) - Bind address:
:8080
. This will bind the webserver to port 8080 on the local host. - Allowed/listable audio/video file extensions.
Once Wasp is started, a FIFO will automatically be created in the configured path (if you have create/write permissions, of course).
Last but not least, start Mplayer in slave mode, with the input to be from the FIFO:
while true; do mplayer -noconfig all -noconsolecontrols -quiet -idle -slave -fs -zoom -input file=/tmp/mplayer.fifo; done
The while true
makes sure Mplayer keeps running at all times, in case unwanted intervention has been done.
This is not a necessity though, but something to consider.
After this, you should have two processes running: mplayer and wasp.
Try opening up a browser to the host where Wasp is running, e.g. http://localhost:8080/. You'll see web interface as follows:
For those interested in some implementation details:
As mentioned previously, the actual code is done using the Go language. The web interface is HTML5, CSS3 and Javascript, with help of jQuery Mobile for UI widgets and jQuery for other common JS tasks.
The A/V backend is Mplayer, which can be run in a 'slave mode' to accept commands from external applications.
Just some notes for development.
- Slave mode Mplayer
- Slave mode commands
mplayer -noconfig all -noconsolecontrols -quiet -idle -slave -fs -zoom -input file=/tmp/mplayer.fifo