You are here

function ajax_brightcove_media_upload_callback in Brightcove Video Connect 7.4

Same name and namespace in other branches
  1. 7.7 brightcove_media/brightcove_media.module \ajax_brightcove_media_upload_callback()
  2. 7.2 brightcove_media/brightcove_media.module \ajax_brightcove_media_upload_callback()
  3. 7.3 brightcove_media/brightcove_media.module \ajax_brightcove_media_upload_callback()
  4. 7.6 brightcove_media/brightcove_media.module \ajax_brightcove_media_upload_callback()

Ajax callback for upload form

_state

Parameters

$form:

Return value

Validated form with messages

1 string reference to 'ajax_brightcove_media_upload_callback'
brightcove_media_upload_form in brightcove_media/brightcove_media.module
Upload form for brightcove media.

File

brightcove_media/brightcove_media.module, line 776
This module provide the hook implementations for the integration with Media module.

Code

function ajax_brightcove_media_upload_callback($form, $form_state) {
  global $user;

  // Make sure it is not set, might be needed if a user changes mind after upload and wants to upload another.
  unset($_SESSION['brightcove']["video_just_uploaded_{$user->uid}"]);
  $video = _brightcove_upload_form_callback($form, $form_state);
  if (is_array($video) || is_bool($video)) {
    return $video;
  }
  $uri = file_stream_wrapper_uri_normalize("brightcove://{$video->id}");
  $file = file_uri_to_object($uri);
  $file->filename = $video->name;
  $file->filemime = 'media/brightcove';
  $file->type = 'video';
  if (!isset($file->fid)) {
    $file->fid = 0;
  }
  media_browser_build_media_item($file);
  $_SESSION['brightcove']["video_just_uploaded_{$user->uid}"] = $file;
  $commands = array();
  $commands[] = ajax_command_brightcove_media_upload($file);
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}