You are here

function videojs_hls_create_index 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_index()
2 calls to videojs_hls_create_index()
videojs_hls_create_static_file in modules/videojs_hls/videojs_hls.pages.inc
videojs_hls_render_dynamic in modules/videojs_hls/videojs_hls.pages.inc
Menu callback for the m3u8/% path.

File

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

Code

function videojs_hls_create_index(array $m3u8items) {
  $return = array();
  $matches = array();
  foreach ($m3u8items as $m3u8item) {
    if (!preg_match('#(\\d+)k#i', $m3u8item, $matches)) {
      continue;
    }
    $bw = $matches[1] * 1000;
    $return[$bw] = '#EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=' . $bw . "\n" . file_create_url($m3u8item);
  }
  if (empty($return)) {
    return FALSE;
  }

  // Sort the files by bandwidth, lowest first.
  ksort($return);
  array_unshift($return, '#EXTM3U');
  return implode("\n", $return);
}