You are here

private function video_transcoder::get_instance in Video 6.4

Same name and namespace in other branches
  1. 7 includes/transcoder.inc \video_transcoder::get_instance()

Parameters

<type> $transcoder :

1 call to video_transcoder::get_instance()
video_transcoder::__construct in includes/transcoder.inc

File

includes/transcoder.inc, line 27

Class

video_transcoder

Code

private function get_instance($transcoder = null) {

  //get our configured transcoder.
  if (!isset($transcoder)) {
    $transcoder = variable_get('vid_convertor', 'video_ffmpeg');
  }

  //    module_load_include('inc', 'video', '/transcoders/' . $transcoder);
  if (!module_load_include('inc', 'video', '/transcoders/' . $transcoder)) {
    $modules = module_list();
    $files = array();
    foreach ($modules as $module) {
      $module_path = drupal_get_path('module', $module) . '/transcoders';
      $inc_files = file_scan_directory($module_path, '^.*\\.inc$');
      if (!empty($inc_files)) {
        $files[$module] = $inc_files;
      }
    }

    // @TODO : add lazy load
    foreach ($files as $module => $_files) {
      foreach ($_files as $file) {
        if ($file->name == $transcoder) {
          module_load_include('inc', $module, '/transcoders/' . $file->name);
        }
      }
    }
  }
  if (class_exists($transcoder)) {
    $transcoder_instance = new $transcoder();
    $this->transcoder = $transcoder_instance;
    return $transcoder_instance;
  }
  else {
    drupal_set_message(t('The transcoder is not configured properly.'), 'error');
  }
}