route66 - database driven mp3 player by: Anders Brownworth - anders-route66 at anders.com contributors: Michael Kidd 1. Introduction route66 is a perl based mp3 player with database backend intended for car and home use. it will drive a 4 line by 20 character serial display from matrix-orbital ( http://www.matrix-orbital.com/ ) or the system console and requires mysql. you build up the database with included tools, and then build selections from it to play. aside from the usual things you would store in an mp3 database such as track name and artist, route66 also stores things like user prefrence for songs, artists and albums on a per user basis which can be tweaked as the music plays. 2. Installation note: the version number is pre 1.0 on this package. not everything works here, so don't expect too much. note: it takes quite some familiarity with setting up linux machines and databases to get all of this to work. i wouldn't consider this to be a simple install. this is not for the faint of heart! you have been warned. what you need to get this working: route66 code (this package) http://elmer.imaginemedia.com/route66/ mysql (database) http://www.mysql.org/ perl 5 (probably included in your distribution) http://www.perl.org/ perl::DBI http://search.cpan.org/search?dist=DBI perl::DBD for mysql http://search.cpan.org/search?dist=DBD-mysql mysql-modules http://search.cpan.org/search?module=DBD::mysql the SWIG package <- only needed to recompile the playerlib http://www.swig.org source code to splay <- only needed to recompile the playerlib seems to have dissapeared: http://adam.kaist.ac.kr/~jwj95/ a serial port display (matrix orbital 4x20) <- only for external control http://www.matrix-orbital.com/ you can now use the console apache (or other webserver) <- for webedit database administration http://www.apache.org/ <- but you probably already have it MP3-Info <- perl module for webedit to read ID3 tags http://search.cpan.org/search?module=MP3::Info install the mysql database. install perl, perl::DBI and perl::DBD for your database. make sure that you can access your database through perl. (a test is included). once you have mysql up and running, you will want to create a database called route66 and set up the schema. in the following example, i essentially create a new database and show you a few essential things and inject the schema. eyore is the name of my machine. eyore ~> mysql mysql -u root ... mysql> show databases; mysql> drop database route66; mysql> create database route66; mysql> use mysql; mysql> grant all privileges on route66.* to route66@localhost identified by 'route66'; mysql> flush privileges; mysql> select user, host, password from user; +---------+-----------+------------------+ | user | host | password | +---------+-----------+------------------+ | root | localhost | | | root | eyore | | | | localhost | | | | eyore | | | route66 | localhost | 3c894bc50ccb5d1a | +---------+-----------+------------------+ 5 rows in set (0.01 sec) mysql> \q Bye eyore ~> mysql -u route66 -proute66 route66 < database/schema.sql ... eyore ~> mysql -u route66 -proute66 route66 ... mysql> show tables; ... mysql> \q Bye. eyore ~> now we (hopefully) have a database called route66 with the schema set up. let's go over permissions briefly as shown in the table above. user root is allowed to access the database without a password from the localhost. (also called eyore) the user route66 is allowed to connect from the localhost if they are useing the correct password. you probably want to add a password for the root user. you can change passwords with the following command: mysql> update user set password=password('secret') where user='root'; mysql> flush privileges; with the schema is one record of data, essentially the database version number. you can check that by selecting it: mysql> select version from versions; +----------+ | versions | +----------+ | 0.6.0 | +----------+ 1 row in set (0.0 sec) mysql> default values for user, contributor and filesystem have been included in the schema.sql import you just did. however, you are going to want to add your filesystem name. the concept here being that you can have one database for more than one filesystem. when the player does selects from the database, it will only ask for matches on the current filesystem. this could be fairly usefull if you use removeable media such as a jazz/orb/cd/dvd drive as your storage area. to add a filesystem, run the database/add_filesystem script and make a note of the filesystemid that it spits out. the add_songs script just makes the assumption that the filesystemid and contributorid are both "2". if you get anything other than 2, edit the add_songs script and change the filesystemid and contributorid at the top. eyore database/> ./add_filesystem what's the name of the filesystem? eyore.imaginemedia.com eyore.imaginemedia.com filesystemid = 2 done. eyore database/> ./add_contributor what's the contributor? Anders Anders contributorid = 2 done. eyore database/> note: contributors are not users! you have to add a user to the database also. contributors are the people (or servers) that contribute music to the system. a user is someone who uses the system and sets prefrences. contributors don't have to be users, nor users contributors. adding a user is as simple as running the software and going to "add user" in the options menu. or you could just use the add_user script in the same way as above. now we need to start inserting records into this database. at the moment, i have a few cheezy tools that do little if any checking for inserting data into the database. you will be most interested in first setting up your genres like so: eyore database/> ./add_genre what's the genre? Reggae genreid = 1 Done. eyore database/> once you have a few of those set up, (rock, classical, reggae, jazz) you will want to start adding songs to the database. adding songs is done with the webedit frontend, and so we need to install it: install the apache webserver. (you probably already have it. most distributions do) make sure the DirectoryIndex line in the httpd.conf file has index.cgi listed. somthing like this: DirectoryIndex index.html index.cgi make a link from your document root directory to the webedit directoryin the route66 source tree. (or move it to the docroot) if your route66 source lived in /usr/local/src/route66 and your docroot was /home/www/... ln -s /usr/local/src/route66/webedit /home/www/webedit will make the url http://12.34.56.78/webedit/ be the administration tool. (replace 12.34.56.78 with your server's ip) install the MP3::Info package: cd MP3-Info-0.80/ perl Makefile.pl make make test make install <- as root now we can start adding tracks. fire up a web browser such as internet explorer and hit your webedit directory. if all goes well, you will get the results of index.cgi. go to "insert" and type a filesystem path to where some of your mp3s reside. (note: don't point it to the root of your 50 gig mp3 directory, or the program will take forever and probably crash your browser!) the system will find all the mp3 files under that directory tree and check your database to see if any of them are already inserted. if a track is not inserted, you will see an "insert" link which will open another window and let you enter the meta information about each track. the ID3 tag info is displayed if present. several choices for each path are displayed below each field gleaned from various locations. to use one of them, just click it. if artists and albums don't already exist, the system will create them for you. go through your directories and insert the tracks that you want in the system. a note on browsers: the input screens were made to work with explorer and netscape. they are heavily javascript dependant. try to use a newer javascript capable browser when entering music. there is also an edit function to allow you to edit the song's meta information. no delete facility exists yet. next you will need to edit the file Settings.pm for your configuration / liking. set the serial port to be whatever port your display is on. next, set the up / down / forward / backward keys that you have attached to your display. they are conveniently named $up_key, $down_key ... etc. you'll see what i'm talking about. set $display_type to be "lcd", "vfd", or "con" ( "con" uses the standard console as display ) depending on what you have. the lcds and vfds have differient character sets, so this picks the apropriate character set. if you want to use the program "display" that accepts either "off" or "on" as an argument, you will need to set the serial port in there as well. i decided not to have any dependancy with this file so it works everywhere weither or not you have the Display.pm installed. 3. Running now for the moment of truth. you can try running the route66 perl script and see if it works. type ./route66 and with luck, you should see the menu come up. if it doesn't, don't blame me! :) go over your hardware / software settings and try to narrow things down. if you are lucky enough to get things working, please drop me a piece of email at anders-mp3@elmer.imaginemedia.com and let me know. i want to get some feedback on how all this code is being used. to learn how to use this package, read the file called user_features.txt in the docs directory. there is also a document called dev.txt which explains what i was thinking about as i created this package. you might find it interesting. it's sort of a ruinning history of the project. i should also take this time to apologize for all the cheezy code in this package, and the fact that this release is a "barely working" version. there are many options that i haven't even begun to roll out. and as usual, all donations are greatfully accepted. there is a list that announcements are made on as well as general discussion. to subscribe, send email to: route66-subscribe@elmer.imaginemedia.com to post, send email to: route66@elmer.imaginemedia.com <- subscribers only to unsubscribe, send email to: route66-unsubscribe@elmer.imaginemedia.com best of luck!!!