You are here

function theme_html5_player in HTML5 Media 7

Theme a media player.

1 theme call to theme_html5_player()
html5_media_field_formatter_view in ./html5_media.module
Implements hook_field_formatter_view().

File

./html5_media.module, line 174

Code

function theme_html5_player($variables) {

  // Get the element for this player.
  if (isset($variables['element'])) {
    $element =& $variables['element'];
  }
  else {
    $element & $variables;
  }

  // Get the settings.
  $settings = $element['#settings'];
  $attributes = $element['#attributes'];

  // Check to make sure there are sources.
  if (empty($element['#sources'])) {
    return 'No media sources provided';
  }

  // Set the value.
  $element['#value'] = '';

  // Iterate through each of the sources and create a source for that file.
  foreach ($element['#sources'] as $delta => $file) {

    // Ensure it is an object.
    $file = (object) $file;

    // Gets the source of this media.
    if ($source = html5_media_get_source($file)) {

      // Add the sources to the #value of the media tag.
      $element['#value'] .= theme('html_tag', array(
        'element' => array(
          '#tag' => 'source',
          '#attributes' => array(
            'src' => $source,
          ),
        ),
      ));
    }
  }

  // Add some variables that the template needs.
  $variables['player'] = theme('html_tag', $variables);
  $variables['settings'] = $settings;
  $variables['params'] = $settings;

  // Register the media player in JavaScript.
  html5_media_register_player($settings, $attributes);

  // Return the theme for our media player.
  return theme('html5_player_' . $settings['template'], $variables);
}