Well, after a few months, I sat down to start hacking a little on my Popcorn Hour. The Popcorn Hour Networked Media Tank (NMT) is a small media center. You can easily install a hard disk for all your media files, that you can play on your TV. It also features an internet connection (fixed; though a wireless connection can be bought), to use internet radio, sites like YouTube and even a BitTorrent client.

But the best of all, is that the thing is extremely hackable. Of course, it runs Linux and it is quite easy to install a telnet daemon on it, so you can log in. You can program your own applications to run on it, even the Gaya browser can be replaced. The Gaya browser is a simple browser that acts as the NMT’s user interface (that is, everything you see on your TV screen). The browser can connect to the internal webserver on localhost, port 8088. Yes, that’s right. A webserver. With PHP.

All these things made me fiddle a little a few weeks back, to see if I could play a music files from the browser. And you can. Gaya understands a few extra tags in HTML, to enable the media player. I guess it can play video files like this as well, but I haven’t tried yet.

The first thing you might want to try is run your own PHP files. Just create a HTML file on the disk. In there you can make a link to your PHP file like this (I split the fullpath to several lines for space. Obviously, it is one long line.):

<a href="http://localhost:8088/stream/file=
      /opt/sybhttpd/localhost.drives/HARD_DISK/
      path/to/script.php">
  Run script
</a>

Of course, using a meta-refresh can get you directly to the PHP script. Then, use the “Files” media browser, from the main NMT screen, to locate the file and click ‘OK’ on it. It opens Gaya and shows the HTML page.

Now, how to play a playlist? Again, we use the anchor tag:

<a href='playlist.jsp' TVID='1' aod='playlist'>Play</a>

It is also possible to play a single file, but I was creating a (usable) music player, that only uses playlists. The playlist format is simple. It is a plain text file, with one line per song. Each line is as follows (I split the fullpath to several lines for space. Obviously, it is one long line.):

title|0|0|file:///opt/sybhttpd/localhost.drives/
      HARD_DISK/path/to/song.mp3|

The anchor tag above will then play all the files in the list.

The beauty of the NMT, is that we have full PHP support available. So, we can easily create a file browser, an mp3 scanner, that creates the playlists, even a shuffle-script that shuffles the playlists. This way, I created a way to randomly play a directory full of mp3s recursively. Something the default media player on the NMT cannot do.

One last remark can be made about the speed of the scripts. Many people have a lot of mp3s and creating playlists by recursively scanning the driver might took a long time. A little dynamic programming (saving the playlists per directory) makes sure you only need to scan once. All in all, scanning the drive doesn’t take some much time. A few seconds on thousands of mp3s. Even shuffling the resulting playlist doesn’t take too much time (in fact, a lot less than scanning, obviously).

With all the hacking possibilities available to the NMT, it is easy to change the device to your liking and needs. I wanted a recursive music player, so I created one. With only a little PHP knowledge and some playing you can get pretty far.

Categorieën: Geekstuff

0 reacties

Geef een antwoord

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Deze website gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.