You are here

function mediaelement_library_info_build in MediaElement 8

Implements hook_library_info_build().

File

./mediaelement.module, line 57
Primary module file.

Code

function mediaelement_library_info_build() {
  $libraries = [];
  $library_config = \Drupal::config('mediaelement.settings')
    ->get('library_settings');

  // Create a dynamic library based for the configured CDN.
  if ($library_config['library_source'] != 'local') {
    $cdn_name = $library_config['library_source'];
    $cdn_url = mediaelement_get_cdn_url($cdn_name);
    $library_version = $library_config["{$cdn_name}_settings"]['library_version'];
    $cdn_path = "{$cdn_url}/{$library_version}";
    $libraries["mediaelement_{$cdn_name}"] = [
      'version' => $library_config["{$cdn_name}_settings"]['library_version'],
      'js' => [
        "{$cdn_path}/mediaelement-and-player.min.js" => [],
        "js/mediaelement.bundle.js" => [],
      ],
      'css' => [
        'component' => [
          "{$cdn_path}/mediaelementplayer.min.css" => [],
        ],
      ],
      'dependencies' => [
        'core/jquery',
        'core/jquery.once',
        'core/drupal',
        'core/drupalSettings',
      ],
    ];
  }
  return $libraries;
}