You are here

function osmplayer_get_player_object in MediaFront 7

Same name and namespace in other branches
  1. 6.2 players/osmplayer/osmplayer.module \osmplayer_get_player_object()
  2. 6 players/osmplayer/osmplayer.module \osmplayer_get_player_object()

Returns the OSMPlayer object.

2 calls to osmplayer_get_player_object()
osmplayer_mediafront_preset_save in players/osmplayer/osmplayer.module
Implementation of hook_mediafront_preset_save
template_preprocess_osmplayer in players/osmplayer/osmplayer.module
The template preprocess function for the osm media player.

File

players/osmplayer/osmplayer.module, line 55

Code

function osmplayer_get_player_object($settings = null) {
  global $base_url, $user;
  static $instance = 0;
  $player = null;
  if ($settings['preset']) {
    $preset = $settings['preset'];
    if ($settings) {

      // Create the OSMPlayer object with these settings.
      $playerPath = osmplayer_get_path();
      $settings['id'] = 'mediafront_' . $preset;
      $settings['prefix'] = $settings['id'] . '_';
      $settings['baseURL'] = $base_url;
      $settings['gateway'] = $base_url . '/services/xmlrpc';
      if (isset($settings['flashPlayer'])) {
        $settings['flashPlayer'] = $base_url . '/' . $playerPath . '/' . $settings['flashPlayer'];
      }
      if (isset($settings['logo'])) {
        $logoPath = $settings['logo'] == 'logo.png' ? $playerPath . '/' : '';
        $settings['logo'] = $base_url . '/' . $logoPath . $settings['logo'];
      }

      // Create the OSMPlayer object with these settings.
      $player = new OSMPlayer($settings);
      $player
        ->setId($instance > 0 ? $player
        ->getId() . '_' . $instance : $player
        ->getId());
      $instance++;

      // Set the session id for the player.
      if (isset($user->sid)) {
        $player
          ->setSessionId($user->sid);
      }

      // Set the CSS directory of our OSMPlayer component.
      $player->template
        ->setCSSDir(osmplayer_get_css_dir());

      // Now add our playlist connections.
      if (isset($settings['connect']) && isset($settings['connect']['isplaylist'])) {
        foreach ($settings['connect']['isplaylist'] as $toPlayer) {
          $player
            ->addPlaylistTo('mediafront_' . $toPlayer);
        }
      }

      // Now add our controller connections.
      if (isset($settings['connect']) && isset($settings['connect']['iscontroller'])) {
        foreach ($settings['connect']['iscontroller'] as $toPlayer) {
          $player
            ->addControllerTo('mediafront_' . $toPlayer);
        }
      }
    }
    else {
      drupal_set_message('Initializing OSMPlayer without settings!', 'error');
    }
  }
  else {
    drupal_set_message('No preset defined to declare the OSMPlayer object!', 'error');
  }
  return $player;
}