Archive

Posts Tagged ‘media player’

RemotePi REST

December 3rd, 2014 subogero Comments off

I’m constantly bombarded with RESTful stuff at work. So much so, that I’ve started rewriting RemotePi as a REST API. Lots of learning and reading, then.

As usual most of the literature was written by people who studied computer science. They just love abstractions. Solving problems is OK, as long as they get their daily hit of abstractions. So there are resources, verbs and routers. Very nice.

You’re supposed to refer to a resource without ugly queries in the URL. Instead, it should be just http://pi/remotepi/home/ for the media root directory. But how the hell does such an URL generate a query that can be processed by a CGI or FastCGI app?

The computer scientists are silent on the issue.

So I had to dig deeper and discover mod_rewrite of Apache2. There is a lot in a name. It rewrites incoming URL requests and is able to turn them into proper queries. Thank you Ludovico Fischer.

So here is my “resource router”.

First enabled mod_rewrite:

a2enmod rewrite
service apache2 restart

And the router config in /etc/apache/sites-available/default

RewriteEngine On
RewriteRule /remotepi/(.+) /remotepi/api.pl?$1

Very Perly, ain’t it? It’s because it uses the Perl regex engine.

RemotePi FastCGI

December 3rd, 2014 subogero Comments off

RemotePi, the remote-control webb-app of my Raspberry Pi media center, felt sluggish. Until I measured the response time with Firefox WebDeveloper/Network. It’s now official: it was sluggish: it took 800 ms to respond. That’s nearly one second.

So it was time to turn the original CGI solution into a FastCGI one. Instead of firing up a new Perl process upon each request, the app keeps running in the background and replies requests in a main loop. I’m using Apache2 mod_fcgid.

The improvement is shocking: File browsing is about 25 ms, requests involving an omxd call take 80 ms. And that’s basically the pure runtime of the omxd command.

FastCGI is fast indeed.

RemotePi rpi.fm omxd

September 26th, 2013 subogero Comments off
Controls and playlist

Controls and playlist

My Raspberry Pi media player suite.

RemotePi

Browse music/videos, internet radio stations and even YouTube on your Raspberry Pi and play them on your audio system or non-smart HDMI TV.

Control everything from your smartphone via the RemotePi web-app. You don’t need an extra remote control, you don’t need SSH, you don’t need to connect physically to the Raspberry Pi, and you definitely don’t need to start the GUI.

Features

RemotePi uses the omxd/omxplayer backend.

Show what omxd is playing now, including album art or YouTube thumbnail and actual/overall clip time.

Limit file browsing within the Raspberry Pi’s file system to a root directory specified in a config file /etc/remotepi.cfg.

Insert, add and append files, directories or internet radio streams to the omxd playlist.

You can even interrupt the playlist to play a single file or a YouTube clip. The playlist resumes after the end of the movie.

Control buttons: Play/pause/stop playback, or navigate in the playlist with repeat, previous/next, Rewind/FastForward 30/600s, or previous or next album buttons.

Delete actual track or entire playlist.

Cycle through subtitles and soundtracks, switch audio output to HDMI of Jack.

RemotePi is strictly file and directory based and could not care less for MP3 tags in files. It does not use 3rd party databases for metadata, except for internet radio. Best used with a nicely arranged folder structure.

Browsing files

Browsing files

Goa internet radio stations

Goa stations

Watch YouTube on your TV

Watch YouTube on your TV

Installation

Source code and installation instructions on Github.

Tecnology

RemotePi is a single HTML5 webpage, you load it once and then it communicates with the Raspberry Pi with AJAX calls using JavaScript. It won’t work it JavaScript is disabled.

youtube-dl

From rg3, RemotePi uses this program to extract direct stream links from YouTube page URLs. You can install it from Raspbian, as well.

rpi.fm

Who does not love internet radio stations? Who does not like to listen to Liquid Funk or Detroit Techno or Verdi all day long? Now you can do it easily on your Raspberry Pi. rpi.fm is an interactive command line tool that allows you to browse hundreds of genres and thousands of stations from the database of internet-radio.com.

Check out the details on Github.

rpi.fm also uses the omxd media player daemon for playback.

omxd

But what the hell is omxd, you may ask. Well, you probably know the brilliant omxplayer that plays full HD videos using the GPU of the Raspberry Pi. It has a few limitations, though. It can play only one file at a time, unless you are a scary shell-wizard.

Would not it be great, if you could add your entire music collection to its playlist in one step?

Would not it be great if you could log out of your SSH/GUI session and it would keep cranking out Psytekk?

Would not it be great to interrupt your music playlist, watch a movie, and continue your playlist where you left off, after Vincent Vega and Jules leave the restaurant?

Exactly. That’s what omxd, the omxplayer daemon does. Maintain, manipulate a playlist, and play it in the background. It’s the heart and soul of RemotePi and rpi.fm.

Check it out on Github.

Future Features

Debian packages for all three tools. So all you have to do for installation is:

sudo apt-get install remotepi