You are here

function mp3player_player_add in MP3 Player 6

Form to add a new player.

1 string reference to 'mp3player_player_add'
mp3player_menu in ./mp3player.module
Implementation of hook_menu().

File

./mp3player.module, line 198
mp3player main module file.

Code

function mp3player_player_add($form_state) {
  if (user_access('administer mp3player')) {
    $form['namegroup'] = array(
      '#type' => 'fieldset',
      '#title' => t('Player Name'),
      '#weight' => -2,
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
    );
    $form['namegroup']['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Name'),
      '#default_value' => '',
      '#required' => TRUE,
      '#size' => '20',
      '#description' => t('Unique name of player. Please only use alphanumeric characters, underscores (_), and hyphens (-) for player names.'),
    );
    $form['options'] = array(
      '#type' => 'fieldset',
      '#title' => t('Player Options'),
      '#weight' => -1,
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
    );
    $form['options']['autostart'] = array(
      '#type' => 'select',
      '#title' => t('Auto-start'),
      '#default_value' => 'no',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('If yes, player starts automatically.'),
    );
    $form['options']['loopaudio'] = array(
      '#type' => 'select',
      '#title' => t('Loop Audio'),
      '#default_value' => 'no',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('If yes, player loops audio.'),
    );
    $form['options']['animation'] = array(
      '#type' => 'select',
      '#title' => t('Animate'),
      '#default_value' => 'yes',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('If no, player is always open.'),
    );
    $form['options']['remaining'] = array(
      '#type' => 'select',
      '#title' => t('Time Remaining'),
      '#default_value' => 'no',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('If yes, shows remaining track time rather than elapsed time.'),
    );
    $form['options']['noinfo'] = array(
      '#type' => 'select',
      '#title' => t("Don't display information"),
      '#default_value' => 'no',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('If yes, disables the track information display.'),
    );
    $form['options']['initialvolume'] = array(
      '#type' => 'textfield',
      '#title' => t('Initial Volume'),
      '#default_value' => '60',
      '#required' => TRUE,
      '#size' => '10',
      '#description' => t('Initial volume level (from 0 to 100).'),
    );
    $form['options']['buffer'] = array(
      '#type' => 'textfield',
      '#title' => t('Buffer Time'),
      '#default_value' => '5',
      '#required' => TRUE,
      '#size' => '10',
      '#description' => t('Buffering time in seconds.'),
    );
    $form['options']['encode'] = array(
      '#type' => 'select',
      '#title' => t('Encode'),
      '#default_value' => 'no',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('Indicates that the mp3 file urls are encoded.'),
    );
    $form['options']['checkpolicy'] = array(
      '#type' => 'select',
      '#title' => t('Check Policy'),
      '#default_value' => 'no',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('Tells Flash to look for a policy file when loading mp3 files (this allows Flash to read ID3 tags from files hosted on a different domain.'),
    );
    $form['options']['rtl'] = array(
      '#type' => 'select',
      '#title' => t('Text Right-to-Left'),
      '#default_value' => 'no',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('Switches the layout to RTL (right to left) for Hebrew and Arabic languages.'),
    );
    $form['options']['width'] = array(
      '#type' => 'textfield',
      '#title' => t('Player Width'),
      '#default_value' => '290',
      '#required' => TRUE,
      '#size' => '10',
      '#description' => t('Width of the player. e.g. 290 (290 pixels) or 100%.'),
    );
    $form['options']['transparentpagebg'] = array(
      '#type' => 'select',
      '#title' => t('Transparent Player Background'),
      '#default_value' => 'no',
      '#options' => array(
        'no' => t('No'),
        'yes' => t('Yes'),
      ),
      '#description' => t('If yes, the player background is transparent (matches the page background).'),
    );
    $form['options']['pagebg'] = array(
      '#type' => 'textfield',
      '#title' => t('Player Background Colour'),
      '#default_value' => '',
      '#required' => FALSE,
      '#size' => '20',
      '#field_prefix' => '#',
      '#description' => t("Player background colour (set it to your page background when transparentbg is set to 'no')."),
    );
    $form['colours'] = array(
      '#type' => 'fieldset',
      '#title' => t('Player Colour Scheme'),
      '#weight' => 0,
      '#collapsible' => FALSE,
      '#collapsed' => FALSE,
    );
    $form['colours']['bg'] = array(
      '#type' => 'textfield',
      '#title' => t('Background'),
      '#default_value' => 'E5E5E5',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['leftbg'] = array(
      '#type' => 'textfield',
      '#title' => t('Left Background'),
      '#default_value' => 'CCCCCC',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
      '#description' => t('Speaker icon/Volume control background.'),
    );
    $form['colours']['lefticon'] = array(
      '#type' => 'textfield',
      '#title' => t('Speaker Icon'),
      '#default_value' => '333333',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['voltrack'] = array(
      '#type' => 'textfield',
      '#title' => t('Volume Track Background'),
      '#default_value' => 'F2F2F2',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['volslider'] = array(
      '#type' => 'textfield',
      '#title' => t('Volume Track Slider'),
      '#default_value' => '666666',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['rightbg'] = array(
      '#type' => 'textfield',
      '#title' => t('Right Background'),
      '#default_value' => 'B4B4B4',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
      '#description' => t('Play/Pause button background.'),
    );
    $form['colours']['rightbghover'] = array(
      '#type' => 'textfield',
      '#title' => t('Right Background Hover'),
      '#default_value' => '999999',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
      '#description' => t('Play/Pause button background (hover state).'),
    );
    $form['colours']['righticon'] = array(
      '#type' => 'textfield',
      '#title' => t('Play/Pause Icon'),
      '#default_value' => '333333',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['righticonhover'] = array(
      '#type' => 'textfield',
      '#title' => t('Play/Pause Icon (hover state)'),
      '#default_value' => 'FFFFFF',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['loader'] = array(
      '#type' => 'textfield',
      '#title' => t('Loading Bar'),
      '#default_value' => '009900',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['track'] = array(
      '#type' => 'textfield',
      '#title' => t('Track Backgrounds'),
      '#default_value' => 'FFFFFF',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
      '#description' => t('Loading/Progress bar track background.'),
    );
    $form['colours']['tracker'] = array(
      '#type' => 'textfield',
      '#title' => t('Progress Track'),
      '#default_value' => 'DDDDDD',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['border'] = array(
      '#type' => 'textfield',
      '#title' => t('Progress Track Border'),
      '#default_value' => 'CCCCCC',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['skip'] = array(
      '#type' => 'textfield',
      '#title' => t('Previous/Next Buttons'),
      '#default_value' => '666666',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['colours']['text'] = array(
      '#type' => 'textfield',
      '#title' => t('Text'),
      '#default_value' => '333333',
      '#required' => TRUE,
      '#size' => '10',
      '#field_prefix' => '#',
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Add new player'),
    );
    $form['#validate'][] = 'mp3player_player_validate';
    $form['#submit'][] = 'mp3player_player_submit';
    return $form;
  }
}