Posted by greg@beargroup.com on February 26, 2007 at 6:48pm
Hi Audiophiles -
Noticed in drupal 5, that the correct enclosures for media files are added - so things like podcasts could be achieved without adding any extra modules for support, could just upload the audio (with Upload module on). Thinking we'll disable audio module since it does a lot more than we need & go this route...
However, I'm trying to figure out how to add a simple player, so every time an mp3 is encountered on the page it tosses in a simple player instead of the download link. Ideas on how to do this?
Thanks,
-G

Comments
The simplest way (i think)
The simplest way (i think) would be to override this theme function in your theme:
http://api.drupal.org/api/5/function/theme_upload_attachments
That's what is used to output the table of file attachments for upload.module. Just check the file type to see if the file is mp3 and then generate a link to the player.
Thanks!
will give that a whirl...
Hey, newbie, here is there a
Hey, newbie, here is there a way you can give me the dummies step by step to implement the code above. I'm not sure how to override template.php and where should i upload upload_attachments.tpl.php. many thanks
google flash player?
hey this is interesting - looking through that code snippet i didnt know you could use the google mp3 player as a flash mp3 player for other files
http://mail.google.com/mail/html/audio.swf
is there a site that gives information on using google's flash players ?
That worked - thank you
That totally worked... here is the code for anyone else attempting the same:
Override for template.php
function phptemplate_upload_attachments($files) {return _phptemplate_callback('upload_attachments', array('files' => $files));
}
Created a new template called upload_attachments.tpl.php with the following - embedding the google player.
<?php
$header = array(t('Attachment'), t('Size'));
$rows = array();
foreach ($files as $file) {
if ($file->list) {
$href = $file->fid ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path()));
$text = $file->description ? $file->description : $file->filename;
if ($file->filemime == "audio/mpeg") { ?>
<p><b>Podcast Audio: <?php print substr($text,0,-4) ?> </b></p>
<object style="border: 1px solid rgb(170, 170, 170); width: 500px; height: 25px;" type="application/x-shockwave-flash"
data="http://mail.google.com/mail/html/audio.swf?audioUrl=<?php print $href; ?>">
<param name="movie" value="http://mail.google.com/mail/html/audio.swf?audioUrl=<?php print $href; ?>" />
</object>
<?php } else {
$rows[] = array(l($text, $href), format_size($file->filesize));
}
}
}
if (count($rows)) {
print theme('table', $header, $rows, array('id' => 'attachments'));
}