function theme_minplayer in MediaFront 7
Same name and namespace in other branches
- 7.2 players/minplayer/minplayer.module \theme_minplayer()
Theme a minPlayer.
1 theme call to theme_minplayer()
- minplayer_get_player in players/
minplayer/ minplayer.module - Implements hook_get_player()
File
- players/
minplayer/ minplayer.module, line 59
Code
function theme_minplayer($variables) {
// Get the parameters.
$params = $variables['params'];
// Set the id.
if (isset($params['nodeObj'])) {
$params['id'] = 'player-' . $params['nodeObj']['nid'];
}
// Get the attributes.
$attributes = html5_media_get_attributes($params);
// See if we should show the player.
$showPlayer = isset($params['showWhenEmpty']) ? $params['showWhenEmpty'] : TRUE;
// Always show the player when viewing through the admin interface.
$showPlayer |= !empty($params['admin']);
// Get the media sources and set the source of this media.
$mediasrc = array();
if ($media = minplayer_get_sources('media', $params)) {
$media = isset($media['media']) ? $media['media'] : array_shift($media);
$mediasrc['value'] = $media->path;
if (!empty($media->filemime)) {
$mediasrc['filemime'] = $media->filemime;
}
}
// Set the poster image.
$imgsrc = '';
if ($images = minplayer_get_sources('images', $params)) {
$imgsrc = isset($images['preview']) ? $images['preview'] : $images['image'];
$imgsrc = is_string($imgsrc) ? $imgsrc : $imgsrc->path;
$attributes['poster'] = $imgsrc;
}
// Setup the 'element' provided the params.
$variables['element'] = array(
'#tag' => 'video',
'#attributes' => $attributes,
'#settings' => $params,
'#sources' => array(
$mediasrc,
),
);
// Return the theme for our media player.
$hide = !$imgsrc && !$mediasrc && !$showPlayer;
return $hide ? '' : theme('html5_player', $variables);
}