Views style plugin for audio node MP3 player
Last modified: January 30, 2009 - 15:58
Here is the theming function to style a view to show audio nodes (from audio.module) with this mp3 player: http://flash-mp3-player.net/players/multi/documentation/
The player shows multiple tracks, taking these as filepaths rather than an XSPF.
Add an XSPF feed argument and you have a view that provides a podcast AND an overview page.
The implementation of hook_views_style_plugins() is left as an exercise ;)
Shouldn't be too hard to adapt this code to work with CCK fields that hold audio files.
/**
* Theming function for the view style plugin MP3 Player
*/
function theme_sam_mp3_player($view, $nodes, $type) {
if ($type == 'block') {
return;
}
// empty view
if (!$nodes) {
return;
}
foreach ($nodes as $i => $node) {
$audio_node = node_load($node->nid);
$audio_files[] = base_path() . $audio_node->audio_file->filepath;
$audio_titles[] = $node->node_title;
}
$options['mp3'] = implode('|', $audio_files);
$options['title'] = implode('|', $audio_titles);
$options['width'] = 300;
$options['height'] = 225;
$options['showplaylistnumbers'] = 0;
$url = base_path() . drupal_get_path('module', 'YOUR MODULE HERE') .'/mp3_player/player_mp3_multi.swf';
$flashvars = audio_query_string_encode($options);
$output = <<<EOT
<object type="application/x-shockwave-flash"
class="mp3-player"
data="$url"
width="{$options['width']}"
height="{$options['height']}">
<param name="movie" value="$url" />
<param name="FlashVars" value="$flashvars" />
</object>
EOT;
return $output;
}
Nice!
I like this as a Views plugin. For reference, if you don't use Views you can easily achieve a similar effect within a node template, or something, which is what I did with the same player in the past. The player is excellent, btw! =)
--
http://www.drupaler.co.uk/
WOW! It's what I was looking
WOW! It's what I was looking for. May I use it somehow on my mp3 search engine (on download page)?