You are here

public function MediaBrightcoveVideoStreamWrapper::brightcoveValues in Brightcove Video Connect 7.6

Same name and namespace in other branches
  1. 7.7 brightcove_media/includes/MediaBrightcoveVideoStreamWrapper.inc \MediaBrightcoveVideoStreamWrapper::brightcoveValues()

Extracts values from a brightcove:// or a brightcove-playlist:// uri.

Parameters

bool $ensure: If set, the values will be filled up with defaults instead of NULLs, when a value is missing from the URL, or the simplified URL is used.

Return value

array An associative array with keys 'id', 'account' and 'player'.

1 call to MediaBrightcoveVideoStreamWrapper::brightcoveValues()
MediaBrightcoveVideoStreamWrapper::interpolateUrl in brightcove_media/includes/MediaBrightcoveVideoStreamWrapper.inc

File

brightcove_media/includes/MediaBrightcoveVideoStreamWrapper.inc, line 77
Stream wrapper for Brightcove videos.

Class

MediaBrightcoveVideoStreamWrapper
@file Stream wrapper for Brightcove videos.

Code

public function brightcoveValues($ensure = FALSE) {
  $parameters = (array) $this
    ->get_parameters();
  $values = [
    'id' => isset($parameters['v']) ? $parameters['v'] : $this
      ->getVideoID(),
    'account' => isset($parameters['a']) ? $parameters['a'] : NULL,
    'player' => isset($parameters['p']) ? $parameters['p'] : NULL,
    'embed' => isset($parameters['e']) ? $parameters['e'] : NULL,
  ];
  if ($ensure) {
    if (!$values['account']) {
      $client_entity = brightcove_client_load_or_default();
      $values['account'] = $client_entity->account_id;
    }
    if (!$values['embed']) {
      $values['embed'] = 'default';
    }
    if (!$values['player']) {
      $client_entities = brightcove_get_clients_by_account_id($values['account']);
      if ($client_entities) {
        $client_entity = reset($client_entities);
        $values['player'] = brightcove_get_default_player($client_entity->bcid);
      }
      else {
        $values['player'] = 'default';
      }
    }
  }
  return $values;
}