Initial release of the flexinode MP3 field

robertDouglass - September 14, 2004 - 06:20

I've checked in a new contrib field for the flexinode module to handle the upload of Mp3 files (available in CVS). It builds on the functionality of the file field by doing the following additional tasks:
1) reads ID3 tag information and stores it in the flexinode for output (playing time, track name, bitrate, artist etc.)
2) creates an m3u file that references the mp3.
3) creates a download link and a streaming link when the node is displayed. The download link simply points to the mp3. The streaming link loads the m3u which in turn points to the mp3. This allows the music to start playing before the entire mp3 has been downloaded. It also makes it a slight bit harder for people to simply copy your mp3.

The filed is dependent on external libraries that you will have to install if you have the mp3 field in your flexinode directory. Here are the installation instructions with the external libs:

The mp3 field is dependent on the getid3 project from Sourceforge:
http://getid3.sourceforge.net/

download the scripts and put them in modules/flexinode/getid3
http://sourceforge.net/project/showfiles.php?group_id=55859&package_id=6...

get the helper applications (for Windows) and put them in modules/flexinode/helperapps
http://sourceforge.net/project/showfiles.php?group_id=55859&package_id=1...

place the field_mp3.inc file in the flexinode directory.

Here is a list of things that still need to get done:
If you edit an existing Mp3 field and replace the file with a different Mp3, the change
does not take place, the update fails. Help fixing this would be greatly appreciated.

It would be nice if the administrator could change a setting to allow or disallow
further file types. There is also more information available from the id3 tags than is displayed.
It would be nice id the admin had some control over this as well. I haven't tested
this code with anything but mp3 files, so I don't know what information is
available to other file formats, but this should be configurable.

The output of the tag information needs to be considered and possibly improved.

This field is a prime candidate for monitoring by the throttle module, but I
don't have any idea how this is done.

The third party libraries' location should be configurable.

Hope people test this and find it useful!

-Robert

--------------
visit me at http://www.robshouse.net

cool

moshe weitzman - September 14, 2004 - 10:51

does you module read the ID3 tags from the file on every page view or do you store that somewhere. if on every page view, it seems expensive for a node listing page. i imagine you do it on every view since you mention throttle.module. instead of watching for a throttle condition, i suggest you use a tag table. or maybe you do that already.

serialized in the flexinode

robertDouglass - September 14, 2004 - 11:20

The Id3 info gets serialized with the flexinode. While serialized data isn't the very best, performance-wise, I don't think it merits a tag_info table.

- Robert Douglass

-----
visit me at www.robshouse.net

tag_info

moshe weitzman - September 19, 2004 - 12:35

i think folks will quickly want 'artist' pages, and genre pages, and so on. in order to build those pages quickly, you don't want serialized data. so i actually think a need will soon arise for a separate table.

Good point

robertDouglass - September 19, 2004 - 14:10

I've got a support request open on this code concerning the last major bug that it has (unable to edit an existing mp3). When I solve that, or if someone can help, then I'd be happy to start working on moving these data to a separate table.

What would actually be needed is an MP3 (or audio) module that offers an API for handling this data and the table to store it in. Then, any node could use it, including flexinodes. Since I'm interested in making lots of sites with large numers of audio files I'll continue working on this, but suggestions, advice and code are all welcome.

Has anybody actually tried the mp3 field out?

- Robert Douglass

-----
visit me at www.robshouse.net

I've tried it

chromatic - October 26, 2004 - 15:25

I've tried it but I'm not able to get it working. I'm not sure what the problem is since i've been lacking free time lately and have only had a few moments here or there to try it. I'll get back to you with more specifics on the problem or thoughts on it if I get it working.

It would be nice if it did this for the core file module (read id3 data) as it would reduce redundant file uploading modules.

A compromise..

javanaut - October 26, 2004 - 16:30

I could see using a tag_info table to hold common fields for many media types: author, album, track, track number, genre, date, format, bitrate, etc. Each format will have other fields that are particular to that format. The remaining fields could be serialized, while the tag_info fields are there and searchable. That way, you could store, for example, tag info for a Quicktime movie in the tag_info table (author, genre, date), with the frames per second value stored in a local serialized object.

A good starting point would be looking at all of the common fields that the getid3 tool returns for various media types.

Excellent idea.

robertDouglass - October 26, 2004 - 16:41

- Robert Douglass

-----
visit me at www.robshouse.net

Congrats, Robert!

javanaut - October 26, 2004 - 16:21

Thanks for the contribution. Your project turned me onto the getid3 project, which offers inspiration for various audio and video functionality. I think this is a great contribution toward multimedia-fying Drupal.

If ever my plate clears off enough, I would like to make a generic video.module as well as an audio.module. I would like to encourage others to do this before me, if possible. The getid3 utility is quite versatile and pulls much more info than just id3 tags from mp3 files. It also supports many other audio formats as well as video and image analysis.

I tried this field out about a week ago, and couldn't get it working. It seemed to be a conflict with some code in file.inc, but I ran out of time looking at it. I'll try again now.

Thanks!

Yes, please try it

robertDouglass - October 26, 2004 - 16:40

I haven't tested it it with anything more recent than the 4.5 RC, so there is a good chance things need updating. An audio module is one thing that *will* get written this year still, so anyone thinking about writing one please contact me and we can coordinate efforts.

- Robert Douglass

-----
visit me at www.robshouse.net

Hi Robert, I have been wor

harald.walker - October 26, 2004 - 17:33

Hi Robert,

I have been working on a similar project, the Quicktime movie field extension for flexinode, which is based a lot on your mp3 code. With the help of getId3 I also retrieve tag information out of the movie and store in the flexinode.

I will have a look at your recent changes and examine the file update problem. I thought that it worked in my extension but am not shure since it is 1 1/2 weeks ago that I worked on it.

I would also like to give the use more options, e.g. which tag information to display. A wizard with 2 or 3 steps would be nice. Another possibility might be to preview first and then allow the user to make selections.

I am still relatively new to Drupal and have to learn a lot about the architecture but it sounds to me as if we can cooperate, since our projects are very similar.

Harald

My contact info

robertDouglass - October 26, 2004 - 18:23

rob at robshouse dot net

- Robert Douglass

-----
visit me at www.robshouse.net

Which version of getID3?

chromatic - October 26, 2004 - 18:08

Which version of getID3 should I be using? I'm getting different results with different versions. 1.7.1 had the 'demos' working, 1.7.0b5 says I don't have iconv installed in php. 2.0.0 says it doesn't have mp3s working... I'm just a little confused here. The closest I got it to working was where I could upload an mp3 but it did not display the id3 information. Currently it gives me "File must be an MP3 file". Sorry for not having any more info yet. I'm a little confused and as I said - when I started trying this out it was a couple of weeks ago. Just to feel not so stupid: is this working with 4.5?

built for 4.5RC

robertDouglass - October 26, 2004 - 18:22

I wrote it agains 4.5 RC and 1.7.1beta-2004.07.26_13:36 and haven't tested with anything newer.

I'll invest some time into all this but it'll have to wait til the weekend - I'm swamped with other work. Thanks for testing it!

- Robert Douglass

-----
visit me at www.robshouse.net

Which version of getID3?

chromatic - October 26, 2004 - 18:30

Which version of getID3 should I be using? I'm getting different results with different versions. 1.7.1 had the 'demos' working, 1.7.0b5 says I don't have iconv installed in php. 2.0.0 says it doesn't have mp3s working... I'm just a little confused here. The closest I got it to working was where I could upload an mp3 but it did not display the id3 information. Currently it gives me "File must be an MP3 file". Sorry for not having any more info yet. I'm a little confused and as I said - when I started trying this out it was a couple of weeks ago. Just to feel not so stupid: is this working with 4.5?

1.7.1b works

chromatic - October 26, 2004 - 18:33

but error of 'file must be MP3' still comes up when trying to add content. could it be permissions or that a directory is misplaced?

...also - i tried changing filetype to capitals as the error msg reads, it's not the problem.

Check your mime types

robertDouglass - October 26, 2004 - 20:30

The check in the code that is failing looks like this:

<?php
   
if($file->filemime != 'audio/mpeg')
?>

you therefore need to make sure that your server recognizes mp3s as audio/mpeg. My Apache installation has this line:

audio/mpeg mpga mp2 mp3

in the mime.types file.

You could also set a print statement at line 74 in the field_mp3.inc and see what type of mime the server thinks you have. If you're trying to upload other media, like videos, you'll have to extend line 75 to accept them as well. There is the need for all sorts of configurable parameters here.

- Robert Douglass

-----
visit me at www.robshouse.net

After writing this: instea

chromatic - October 27, 2004 - 03:50

After writing this:
<?return array('error' => $mime);?>
instead of the error array currently on line 74 I discovered that it thinks of it as an
application/x-download
So I check my apache cpanel settings (on a third party host) and found
audio/mpeg
but not
application/x-download

I'm not really sure where to go from here. My best hunch is that somewhere between getid3 (the demos work) and drupal it's not getting the mime type.

I'm pretty sure that it couldn't be the mp3's themselves.

I'm stumped

robertDouglass - October 27, 2004 - 06:55

I don't know why you're having this problem. It still sounds like some sort of server configuration problem. Anyone else have ideas for chromatic?

- Robert Douglass

-----
visit me at www.robshouse.net

Sorry, this isn't new news bu

chromatic - October 27, 2004 - 15:26

Sorry, this isn't new news but I realized I didn't mention that I also wrote
<?
$mime = $file->filemime;
?>
right above so that it looks like this:
<?
$mime = $file->filemime;
// return array('error' => 'File must be an MP3 file. ');
return array('error' => $mime);
?>

I'm just clarifying that $mime was not a variable previously.

MP3 field has been updated for 4.5

robertDouglass - October 27, 2004 - 06:47

I also added an error message when the upload fails due to the file being too large. As always, testers are appreciated.

- Robert Douglass

-----
visit me at www.robshouse.net

where would it be?

chromatic - October 29, 2004 - 15:51

Sorry, but is it in the contrib directory of the flexinode module or is there another place to get just mp3_field?

Contrib directory

robertDouglass - October 29, 2004 - 16:16

I get it straight from the CVS repository, so I don't know if it is on the dowloads page, and if so, if it is the updated version.

contributions/modules/flexinode/contrib/

- Robert Douglass

-----
visit me at www.robshouse.net

Add Info to Docs

oadaeh - October 31, 2004 - 14:29

This may sound like whining, but would it be possible to add the getid3 requirement and information to the flexinode/INSTALL file? That's the first place I look for instructions, requirements, etc. when I'm installing a module. The second is the README file.

README.mp3

robertDouglass - October 31, 2004 - 15:33

I followed the precedent of including a README file in the contrib directory in CVS. The file is named README.mp3 (should probably be README.mp3.txt), and is up to date.

I don't really know if the info in the README.mp3 will ever get added to the flexinode INSTALL file as it is an optional contrib extension to the flexinode.module. I tend to think it is best where it is.

Let me know if you do not find the README.mp3 or if that doesn't answer all of your questions.

- Robert Douglass

-----
visit me at www.robshouse.net

Yes, please rename README.mp3

Uwe Hermann - October 31, 2004 - 15:58

Yes, please rename README.mp3 to README.mp3.txt. Also, the same should be done with the other README* files which don't end in ".txt"...

Uwe.
--
My Drupal site: http://www.crazy-hacks.org
Soon to be drupalized: http://www.unmaintained-free-software.org

How to delete

robertDouglass - October 31, 2004 - 21:36

Hi Uwe,

Just wanted to check with you how to best do that with regards to the CVS repository. I can of course check in the renamed files with no problem, but how does one delete? Do I need to delete them, commit, then check in the new ones? Someday I should actually learn how to use CVS instead of depending on Eclipse!

Thanks,

- Robert Douglass

-----
visit me at www.robshouse.net

Yes, renaming files in CVS is

Uwe Hermann - November 1, 2004 - 10:52

Yes, renaming files in CVS is the same as removing the old one and adding the new one.

On the command line:

cvs remove -f foo.txt
cvs ci
cvs add newfoo.txt
cvs ci

HTH, Uwe.
--
My Drupal site: http://www.crazy-hacks.org
Soon to be drupalized: http://www.unmaintained-free-software.org

Done

robertDouglass - November 1, 2004 - 11:26

- Robert Douglass

-----
visit me at www.robshouse.net

this doesnt work unless you

sulleleven - December 29, 2004 - 06:16

this doesnt work unless you use getID version 1.7x, not with newer version 2.x

confirm?

Correct

robertDouglass - January 2, 2005 - 00:18

I have not been tracking ID3 development and have not been maintaining this contribution very actively. If you have a specific request, please contact me and if I can, I will try to accomodate.

- Robert Douglass

-----
visit me at www.robshouse.net

video

sulleleven - January 4, 2005 - 22:16

ok. thanks for confirming. I have it working now.

I need to work on video flexinode field type. I don't think anyone has done this, at least not that I can find except a quicktime field which didnt work for me. So I am going to start on this unless someone points me to dev already started. Would you happen to have any insight if it is out there? I will just base it on this mp3 type, but it will auto-detect video file type based on file extension and use proper output code.

Media.module

robertDouglass - February 19, 2005 - 11:56

This may be of interest to people working with audio files

http://drupal.org/node/17572

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

serialized_data artist on tabular view?

azote - March 29, 2005 - 04:55

is there any way to show artists on the tabular view? or other details that the getid3 serializes?

Media module

robertDouglass - March 29, 2005 - 06:40

That is why the media module got written.

http://drupal.org/node/19304

- Robert Douglass

-----
www.robshouse.net
www.webs4.com

Streaming link doesn't work

maui1 - November 7, 2005 - 18:10

I just tried using your Mp3 field for flexinode. I am able to upload an Mp3 file, and it shows up fine with two links to the file. The first link will download the file, but when I click on the second link to stream the file, it brings up a Page not Found error.

I have a standard flexinode installation on Drupal 4.6.3. The get id3 folder and the field_mp3.inc file are in the main flexinode directory. Should I have some kind of player in there too?

Are private downloads turned on?

robertDouglass - November 8, 2005 - 09:20

Is the admin/settings download method set to private? This doesn't seem to be compatible with the Mp3 field. Other have had success fixing this problem by using the public download method.

- Robert Douglass

-----
My sites: HornRoller.com, RobsHouse.net

 
 

Drupal is a registered trademark of Dries Buytaert.