You are here

function videojs_hls_create_static_file in Video.js (HTML5 Video Player) 7.2

Same name and namespace in other branches
  1. 7.3 modules/videojs_hls/videojs_hls.pages.inc \videojs_hls_create_static_file()
1 call to videojs_hls_create_static_file()
videojs_hls_preprocess_videojs in modules/videojs_hls/videojs_hls.module
Implements hook_preprocess_videojs().

File

modules/videojs_hls/videojs_hls.pages.inc, line 40
Menu callbacks for the Video.js HTTP Live Streaming module.

Code

function videojs_hls_create_static_file(array $m3u8items) {
  $content = videojs_hls_create_index($m3u8items);
  if (!$content) {
    return FALSE;
  }
  $dir = variable_get('videojs_hls_delivery_static_scheme', variable_get('file_default_scheme', 'public')) . '://' . variable_get('videojs_hls_delivery_static_path', 'm3u8');
  $dir = rtrim($dir, '/');
  if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
    watchdog('videojs_hls', 'Directory %directory is not writable, can\'t use static files. Please check your Video.js HLS settings.', array(
      '%directory' => $dir,
    ));
    return FALSE;
  }
  $path = $dir . '/' . md5($content) . '.m3u8';
  if (!file_exists($path)) {
    file_put_contents($path, $content);
  }
  return $path;
}