When it comes to playing music in Linux, Amarok is one of the best audio players out there. It offers almost everything you need, from a clean, intuitive interface to a range of useful scripts. You can even put it on a server and give it a Web interface.
ObsidianMusic was previously known as amaroK Web Frontend. It is a collection of scripts that, combined with a MySQL database and the Amarok player, forms an excellent way of sharing MP3 files over the Internet or a small office network. All the music files in your collection can be played, downloaded, or streamed by a regular Web browser. Furthermore, ObsidianMusic offers search capabilities and music sorting, and can be customized using themes.
When your music collection hits around 10,000 songs and these are all inserted into a playlist, it takes forever for the application to index them all if you don't use a database. To give ObsidianMusic a try, begin by creating a database for Amarok. Currently, the player can connect to MySQL, PostgreSQL, and SQLite databases. We'll use good old MySQL to create a new database named amarok and grant full access to it to a user called john, also from the local network:
mysql> GRANT ALL ON amarok.* TO razvan@'192.168.0.19' IDENTIFIED BY 'pass123';
mysql> GRANT ALL PRIVILEGES ON amarok.* TO 'john'@'192.168.0.56' IDENTIFIED BY 'password678' WITH GRANT OPTION;
mysql> flush privileges;
Next, download the ObsidianMusic package and unpack the files into /var/www/amarok (or whatever Apache root directory you wish). Make sure you have PHP and php5-mysql installed. Edit /var/www/amarok/inc/config.php so that it looks something like this:
die("Cannot access directly.");
$db = array(
'user' => "razvan",
'pass' => "pass123",
'name' => "amarok",
'host' => "localhost");
$dbtype = 0;
$locked = true;
$authtype = 1;
$cookielen = 60;
$playlist = 3;
$gzip = true;
$cache = true;
$paginate = true;
$ressize = 200;
$language = "en_us";
$sitename = "My MP3 Collection";
$theme = "default";
$allowchoose = false;
$extrainfo = false;
$errorreporting = false;
$enabled = true;
The four lines below
$db are pretty straightforward: they represent the database username, database password, database name, and hostname respectively. Substitute the
$dbtype number with 0 for MySQL or 1 for PostgreSQL. If you don't want to allow everyone to access the music database, password-protect ObsidianMusic with
$locked = true. If you wish to allow passwordless access, set
$authtype to 1 or 2 to specify the method for session saving (sessions or cookies). The
$cookielen variable sets the session time in minutes.
Next, configure the output settings. One of the most important lines you can experiment with is
$playlist, where 1 specifies .pls format and 2 outputs .m3u format. If you'd rather allow downloads and not streaming, set
$playlist to 3, and when you click on a song link in the ObsidianMusic pages, it will be archived as a tar file and sent to your browser. You can also enable album downloads, which can be both a plus and a minus. The good part is that you can download multiple files at once; the bad part is that the background archiving takes a lot of CPU time.
$gzip is set to true, ObsidianMusic will offer compressed pages to the browsers that access its pages. Activate both
$cache for better performance, so that pages will load faster.
$paginate controls whether the results of the main page will be split into different pages for easier browsing. If you set
$paginate to true, you can also set
$ressize to a number that represents the amount of results displayed on a page.
$language should be self-explanatory; ObsidianMusic is currently translated into English, Romanian, Italian, German, Russian, and Dutch.
Set the name of the Web site with
$sitename. Sadly, ObsidianMusic comes with only a default theme, which is actually a CSS file containing the page settings and formatting. If you choose to create a theme of your own, you can give it a different name and specify it with
$theme, and you can let users pick their favorite template with
$allowchoose = true.
If you're not satisfied with the information ObsidianMusic provides about the songs it presents, set
$extrainfo to true to enable new columns in the results pages.
$errorreporting is used to debug your site if any errors should arise. The last line,
$enabled = true, tells Amarok and Apache that ObsidianMusic is alive and well and ready to be accessed. If you want to take the site offline, set this variable to false.
Finally, before launching the site, creating accounts for your friends. The ObsidianMusic package includes a Python script in its /inc/auth subdirectory that you can use to generate SHA1-encrypted passwords. Launch it with the command
./genauth.py password, where password is an access key for an individual user. Copy the output and open /var/www/amarok/inc/auth.users.php with a text editor. Below
$userlist insert the usernames and encrypted passwords using the following pattern:
'moni' => 'e1b00ca72e624438c2f689d03f6f6d1fb8e736f3',
'bogdan' => 'a597b8605b56193e90d637d8ef7872d2f71df4a8',
End each line with a comma.
Now you're set up. Enter your MySQL username and password into the Collection section of Amarok's Configuration window. Choose your database type, specify the hostname (usually localhost) and database name (amarok), then type in the port number MySQL runs on (usually 3306). Restart Apache and MySQL, and check whether port 3306 is open:
sudo /etc/init.d/mysql restart
netstat -tapn | grep 3306
In Amarok, from the Tools menu, choose Rescan Collection to insert the ID3 tags of the MP3 files into the newly created MySQL database. When all is done, fire up a Web browser and type in the address of the server in the URL bar: http://localhost/amarok. You should be prompted for a username and password. Log in with one of the user accounts you made and explore what ObsidianMusic has to offer.
Your users will be able to listen to audio streams or download songs, depending on the value you assigned to
$playlist in config.php. ObsidianMusic lets you search for artists, song titles, album names, music genres, and release years. With the menu on the left you can browse through songs, albums, and band names, download or play a random song, and display the latest additions.
Since Amarok 1.4, album covers are not displayed in ObsidianMusic, due to the fact that large portions of the application code were changed by the Amarok team, including the ones that handle the way image files are stored. Another downside of ObsidianMusic is the release cycle. New features rarely surface, and some fresh themes would be really welcome. Other than that, ObsidianMusic provides a great way to share music or create an on-demand online radio station for your friends and family.