You are here

function scald_video_scald_prerender in Scald: Media Management made easy 7

Implements hook_scald_prerender().

File

modules/providers/scald_video/scald_video.module, line 99
Scald Video is a Scald Atom Provider for video files.

Code

function scald_video_scald_prerender($atom, $context, $options, $mode) {
  $video_datas = array();
  $video_datas[] = array(
    'path' => file_create_url($atom->file_source),
    'mime_type' => file_get_mimetype($atom->file_source),
  );

  // Loading alternative video sources:
  if (isset($atom->data['alternative_video_sources']) && count($atom->data['alternative_video_sources'])) {
    foreach ($atom->data['alternative_video_sources'] as $key => $video_file) {
      $video_datas[] = array(
        'path' => file_create_url($video_file->uri),
        'mime_type' => $video_file->filemime,
      );
    }
  }
  $video_sources = array();
  foreach ($video_datas as $key => $video) {
    $video_sources[] = array(
      'path' => $video['path'],
      'mime_type' => $video['mime_type'],
    );
  }
  if ($mode == 'atom') {
    $atom->rendered->player = theme('scald_video_player', array(
      'vars' => array(
        'atom' => $atom,
        'video_sources' => $video_sources,
        'video_width' => check_plain($atom->data['video_width']),
        'video_height' => check_plain($atom->data['video_height']),
        'thumbnail' => $atom->thumbnail_source,
        'class' => 'scald_video',
        'context' => $context,
      ),
    ));
  }
}