You are here

function scald_video_scald_add_form_fill in Scald: Media Management made easy 7

Implements hook_scald_add_form_fill().

File

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

Code

function scald_video_scald_add_form_fill(&$atoms, $form, $form_state) {
  $dir_video_thumb = 'public://atoms/video/thumb';
  foreach ($atoms as $delta => $atom) {

    // Delta is used only with multifile field:
    if (is_array($form_state['values']['file'])) {

      // plupload infos:
      $file_infos = $form_state['values']['file'][$delta];
    }
    else {

      // This will be a fid:
      $file_infos = $form_state['values']['file'];
    }
    $file = scald_video_get_video_file($file_infos, $form['file']['#upload_location']);
    $atom->base_id = $file->fid;
    $atom->file_source = $file->uri;
    $atom->data['video_file'] = $file->uri;
    $atom->data['video_id'] = $file->fid;
    $atom->title = $file->filename;

    // @TODO : find lib to get metadatas from video files
  }
}