You are here

function videojs_hls_form_alter in Video.js (HTML5 Video Player) 7.3

Same name and namespace in other branches
  1. 7.2 modules/videojs_hls/videojs_hls.module \videojs_hls_form_alter()

File

modules/videojs_hls/videojs_hls.module, line 67
Provides bandwidth switching for the Video.js player.

Code

function videojs_hls_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id != 'videojs_settings_form') {
    return;
  }
  array_unshift($form['#submit'], 'videojs_hls_submit');
  $form['hls'] = array(
    '#type' => 'fieldset',
    '#title' => t('Video.js HTTP Live Streaming'),
  );
  $form['hls']['videojs_hls_delivery_type'] = array(
    '#type' => 'radios',
    '#title' => t('Delivery mode'),
    '#options' => array(
      'dynamic' => t('Dynamic files: m3u8 index files are create dynamically'),
      'static' => t('Static files: m3u8 index files are written to disk'),
    ),
    '#default_value' => variable_get('videojs_hls_delivery_type', 'dynamic'),
    '#required' => TRUE,
  );
  $scheme_options = array();
  foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $stream_wrapper) {
    $scheme_options[$scheme] = $stream_wrapper['name'];
  }
  $form['hls']['videojs_hls_delivery_static_scheme'] = array(
    '#type' => 'radios',
    '#title' => t('Destination location'),
    '#options' => $scheme_options,
    '#default_value' => variable_get('videojs_hls_delivery_static_scheme', variable_get('file_default_scheme', 'public')),
    '#states' => array(
      'visible' => array(
        ':input[name=videojs_hls_delivery_type]' => array(
          'value' => 'static',
        ),
      ),
    ),
  );
  $form['hls']['videojs_hls_delivery_static_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Destination path'),
    '#default_value' => variable_get('videojs_hls_delivery_static_path', 'm3u8'),
    '#states' => array(
      'visible' => array(
        ':input[name=videojs_hls_delivery_type]' => array(
          'value' => 'static',
        ),
      ),
    ),
  );
}