You are here

video_url.module in Video 5

Enable Path or URL support for video module.

@author Fabio Varesano <fvaresano at yahoo dot it>

File

types/video_url/video_url.module
View source
<?php

// ex: set tabstop=2 expandtab shiftwidth=2 softtabstop=2:

/**
 * @file
 * Enable Path or URL support for video module.
 *
 * @author Fabio Varesano <fvaresano at yahoo dot it>
 */

/**
 * Implementation of hook_menu
*/
function video_url_menu($maycache) {
  $items = array();
  if ($maycache) {
    $items[] = array(
      'path' => 'node/add/video/url',
      'title' => t('URL'),
      'access' => user_access('create video'),
    );
  }
  return $items;
}

/**
 * Implementation of hook_v_help
*/
function video_url_v_help() {
  $help = array();
  $help['url']['data'] = '<b>' . t('Url support') . '</b>';
  $help['url']['children'] = array(
    t('You can link to any video file on the Internet.'),
  );
  return $help;
}

/**
 * Implementation of hook_v_info()
*/
function video_url_v_info() {
  $info['url'] = array(
    '#name' => 'URL Video',
    '#description' => t('Post a video available on the Internet to this website.'),
    '#downloadable' => TRUE,
    '#autothumbable' => FALSE,
    '#autoresolution' => FALSE,
    '#autoplaytime' => FALSE,
  );
  return $info;
}

/**
 * Implementation of hook_v_form()
*/
function video_url_v_form(&$node, &$form) {
  $form['video']['vidfile'] = array(
    '#type' => 'textfield',
    '#title' => t('URL to the video'),
    '#default_value' => $node->vidfile,
    '#maxlength' => 700,
    '#required' => TRUE,
    '#weight' => -20,
    '#description' => t('Insert the URL to the video file. This shuold be something similar to <em>http://www.example.com/videos/myvideo.flv</em>') . ' ' . l(t('More information.'), 'video/help', NULL, NULL, 'videofile'),
  );
  return $form;
}

/**
 * implementation of hook_v_validate
*/
function video_url_v_validate($node) {

  // Can you suggest a validation?
  // validation should allow URLs, relative paths but also streaming servers URLs
}

/**
 * Implementation of hook_v_play
*/
function video_url_v_play($node) {
  include_once drupal_get_path('module', 'video') . '/includes/common.inc';
  return _video_common_get_player($node);
}

/**
 * Implements the hook_v_download
*/
function video_url_v_download($node) {
  $url = _video_get_fileurl($node->vidfile);
  header("Location: {$url}");

  //Redirect to the video file URL.
}

Functions

Namesort descending Description
video_url_menu Implementation of hook_menu
video_url_v_download Implements the hook_v_download
video_url_v_form Implementation of hook_v_form()
video_url_v_help Implementation of hook_v_help
video_url_v_info Implementation of hook_v_info()
video_url_v_play Implementation of hook_v_play
video_url_v_validate implementation of hook_v_validate