function osmplayer_get_player in MediaFront 7
Same name and namespace in other branches
- 6.2 players/osmplayer/osmplayer.module \osmplayer_get_player()
- 6 players/osmplayer/osmplayer.module \osmplayer_get_player()
- 7.2 players/osmplayer/osmplayer.module \osmplayer_get_player()
Implements hook_get_player()
File
- players/
osmplayer/ osmplayer.module, line 9
Code
function osmplayer_get_player($params) {
$template = isset($params['template']) && $params['template'] ? $params['template'] : "default";
$showPlayer = isset($params['showWhenEmpty']) ? $params['showWhenEmpty'] : TRUE;
// Always show the player when viewing through the admin interface.
$showPlayer |= !empty($params['admin']);
// If they provide the playlist object, encode it as JSON.
if (isset($params['playlistObj']) && $params['playlistObj']) {
$showPlayer |= $params['playlistObj']['total_rows'] > 0;
$params['playlist'] = drupal_json_encode($params['playlistObj']);
}
else {
$showPlayer |= isset($params['playlist']) && $params['playlist'];
}
// If they provide the node object, encode it as JSON.
if (isset($params['nodeObj']) && $params['nodeObj']) {
$showPlayer |= isset($params['nodeObj']['mediafiles']) && count($params['nodeObj']['mediafiles']) > 0;
$params['node'] = drupal_json_encode($params['nodeObj']);
}
else {
$showPlayer |= isset($params['node']) && $params['node'];
}
// Iterate through each parameter and filter it for output.
foreach ($params as $param => &$value) {
if (gettype($value) == 'string') {
$value = check_plain($value);
}
}
// Show the player.
return $showPlayer ? theme('osmplayer_' . $template, array(
'params' => $params,
)) : '';
}