i choose mediafield & mediafield_display to build up my podcast site.
i use mediafield create audio & video upload form, then i use mediafield_display to create player to play the file. that's work very well.
the original mediafield_display is use 1pixelout.swf & button.swf this two player, only support audiofield, videofield not support yet.
so i change to JW FLV MEDIA PLAYER to support audiofield & videofield.
the code i add to mediafield_display module like this:
/**
* Implementation of hook_field_formatter_info().
*/
function mediafield_display_field_formatter_info() {
$formatters = array();
if (module_exists('audiofield')) {
$path = drupal_get_path('module', 'mediafield_display') .'/players/mediaplayer/';
if (file_exists($path .'mediaplayer.swf')) {
$formatters['mediaplayer'] = array(
'label' => t('mediaplayer'),
'field types' => array('file_audio', 'link'),
);
$formatters['mediaplayer_plus'] = array(
'label' => t('mediaplayer plus download link'),
'field types' => array('file_audio'),
);
}
}
return $formatters;
}
/**
* Theme a mediaplayer audio file.
*/
function theme_mediafield_display_mediaplayer($file_title, $file_url, $item, $field) {
global $base_url;
// Set the URL for the player.
$url->player = $base_url . '/' . drupal_get_path('module', 'mediafield_display') . '/players/mediaplayer/mediaplayer.swf';
$url->logo = $base_url . '/' . drupal_get_path('module', 'mediafield_display') . '/players/mediaplayer/player-logo.png';
$url->swfobject = $base_url . '/' . drupal_get_path('module', 'mediafield_display') . '/players/mediaplayer/swfobject.js';
// Set some Flash variables.
$options = array();
$options['soundFile'] = $file_url;
$flashvars = drupal_query_string_encode($options);
// This is a fix for http://drupal.org/node/158687.
$flashvars = str_replace('http%3A/%252F', 'http://', $flashvars);
$flashvars = str_replace('soundFile=', '', $flashvars);
$output = <<<EOT
<script type="text/javascript" src="$url->swfobject"></script>
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('$url->player','mpl','300','65','8');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addVariable('height','65');
so.addVariable('width','300');
so.addVariable('file','$flashvars');
so.addVariable('showeq', 'true');
so.addVariable('backcolor','0x456bbb');
so.addVariable('frontcolor','0xf8f9fc');
so.addVariable('lightcolor','0xA8BBE1');
so.addVariable('logo','$url->logo');
so.addVariable('displayheight','65');
so.addVariable('showicons','false');
so.write('player');
</script>
EOT;
return $output;
}
all setting well to view in full node, but if i view in teaser node that got one faults.
i think the problem is this code --> so.write('player'); <-- that will write the player at <div id="player">, so if view in teaser node the will be output few player to play, BUT all the player will replace at <div id="player">.
player cant come out for another <div id="player">, so that show "This text will be replaced".
so hope anyone can give me some idea for fix it?
something like --> so.write('player_$id'); <-- --> <div id="player_$id"> <--
Thank so much^^
ANY better idea? (pls show the setup step)