This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Graphics & Multimedia

Create an MP3 file server using Amarok and ObsidianMusic

By Razvan T. Coloja on December 19, 2007 (4:00:00 PM)

Share    Print    Comments   

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> CREATE DATABASE amarok; 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:

<?php if(eregi("config.php", $_SERVER['PHP_SELF'])){ 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.

If $gzip is set to true, ObsidianMusic will offer compressed pages to the browsers that access its pages. Activate both $gzip and $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:

'aygun' => '7b718ce5d791eb5234b2c8f2293afc5d6bd791c2', '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/apache2 restart 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.

Razvan T. Coloja has published more than 150 Linux and IT-related articles in print and online magazines. He is an editor for a Romanian magazine and one of the maintainers and editors of www.mylro.org, a Romanian Linux/OSS portal and community.

Share    Print    Comments   

Comments

on Create an MP3 file server using Amarok and ObsidianMusic

Note: Comments are owned by the poster. We are not responsible for their content.

Create an MP3 file server using Amarok and ObsidianMusic

Posted by: Anonymous [ip: 75.178.188.32] on December 19, 2007 05:07 PM
Check out Ampache too. I used ObsidianMusic for a while, but Windows users don't like its tar format. I'm hooked on Ampache.

http://www.ampache.org/

#

An Ogg server would be more to the point

Posted by: Anonymous [ip: 82.192.250.149] on December 19, 2007 07:55 PM
An article on Linux.com should mention ogg files first, and mp3 second if at all. Ogg is technically better than mp3, and there are plenty of devices that can play ogg files.

#

Create an MP3 file server using Amarok and ObsidianMusic

Posted by: Anonymous [ip: 85.82.204.47] on December 21, 2007 09:00 AM
Ampache becomes even more interesting in connection with Amarok as the upcoming Amarok2 can function as an Ampache client: http://amarok.kde.org/blog/archives/529-Inter-project-collaboration-Ampache-integration.html

#

Create an MP3 file server using Amarok and ObsidianMusic

Posted by: Anonymous [ip: 85.81.168.86] on December 28, 2007 09:49 AM
Editing configuration _by hand_...? Come on - we're close to 2008...

Besides (the brilliant) Ampache; kPlaylist and Ampjuke are also worth taking a closer look at.

#

Amarok sucks!

Posted by: Anonymous [ip: 212.112.39.196] on December 30, 2007 12:57 AM
Amarok - enjoy your silly animations.

#

Re: Amarok sucks!

Posted by: Anonymous [ip: 124.188.17.65] on December 31, 2007 04:52 AM
Hmm,.. no reasoning offered or preferred alternative. Enjoy making comments with no value.

(side issue: a Captcha that relies on externally hosted JS to work (and fails telling you the captcha answer is wrong if external JS is blocked) is a bit lame isn't it? You're slugging your user for your spam problem by making them use the captcha -- cool -- but then you're also asking them to allow a script to run from a place they've probably never heard of (cetrk.com). Teaches bad habits.

#

Create an MP3 file server using Amarok and ObsidianMusic

Posted by: Anonymous [ip: unknown] on January 02, 2008 06:16 AM
Installed Obsidian to use with PostgreSQL and Amarok, just to see what it did. Several problems. First, why in the world should one have to change an $enabled=false line in the application to turn it on? Shouldn't it ship with this value set to true? On certain queries (Browse Albums, Browse By Letter), it returned PHP/PostgreSQL errors because the author used a REGEXP keyword in his queries that I've never heard of in PostgreSQL. Do they only test MySQL? When one selects a song, it opens a dialog box to ask if you want to save the song or open it with Amarok. That's just silly. And although Amarok would play a given song on its own, it did not appear to want to play the song when fed the information from Obsidian. But really, Obsidian doesn't appear to be worth much. It mostly provides a way to browse your playlist(s) in various ways from a web interface. Very weak.
Paul M. Foster

#

Create an MP3 file server using Amarok and ObsidianMusic

Posted by: Anonymous [ip: 72.12.201.2] on January 23, 2008 04:33 PM
what if you don't have amarok? What then?!?

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya