You are here

function brightcove_player_load_all in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.2 brightcove.module \brightcove_player_load_all()
  2. 7.3 brightcove.module \brightcove_player_load_all()
  3. 7.4 brightcove.module \brightcove_player_load_all()
  4. 7.5 brightcove.module \brightcove_player_load_all()
  5. 7.6 brightcove.module \brightcove_player_load_all()

Load all players.

Return value

\Brightcove\Object\Player\Player[]

3 calls to brightcove_player_load_all()
brightcove_client_form in ./brightcove.client.inc
Form callback: create or edit a brightcove client.
brightcove_player_list in ./brightcove.module
Get players list.
brightcove_player_load in ./brightcove.module
Load a player.

File

./brightcove.module, line 2793
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function brightcove_player_load_all($client_id = NULL) {
  if ($client_id === NULL) {
    $client_id = variable_get('brightcove_client_default');
  }
  if (!$client_id) {
    return [];
  }
  brightcove_load_lib();
  $cid = "brightcove:players:{$client_id}";
  if (!($players = brightcove_cache_get($cid))) {
    $client = brightcove_client_load($client_id);
    $players = [];
    brightcove_try(function () use (&$players, $client) {

      /** @var \Brightcove\API\PM $pm */
      list(, , $pm) = brightcove_create_classes($client);
      $players = $pm
        ->listPlayers()
        ->getItems();
    });
    if ($players) {
      brightcove_cache_set($cid, $players);
    }
  }
  return $players;
}