Last updated September 7, 2013. Created by GrahamO on September 3, 2013.
Log in to edit this page.

To do this in Drupal 7 first install two modules : getID3() and Computed Field.

In the content type that holds the details for each audio track add a field of type 'Computed'
For this field, in the entry 'Computed Field (PHP)' insert the following code:

$node = menu_get_object();
if(!isset($node->nid)){
//this is to be a new node so get audio file uri from
//most recent entry in Drupal's file_managed table
$name2=db_query_range('SELECT uri FROM {file_managed} ORDER BY fid DESC',0,1)->fetchField();
}else{
//this is an existing node being edited so get audio file uri
//for this node from Drupal's node table
$thisname = field_get_items('node', $node, 'field_audiofile');
$name2=$thisname[0]['uri'];
}
$fileinfo=getID3_analyze(drupal_realpath($name2));
$playtime=round($fileinfo['playtime_seconds']/60);
$entity_field[0]['value'] = $playtime;

where 'field_audiofile' is the machine name of the field used for the file path of each track
In this case '$playtime' uses PHP code to give the duration of the track in minutes

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.