'admin/content/videofield_display', // 'title' => t('Video Field Display settings'), // 'description' => t('Configure different aspects of the Video Field Display module and its plugins'), // 'callback' => 'drupal_get_form', // 'callback arguments' => array('videofield_display_settings_form'), // 'access' => user_access('administer site configuration'), // 'type' => MENU_NORMAL_ITEM, // ); // } return $items; } /** * Implementation of hook_field_formatter_info(). */ function videofield_display_field_formatter_info() { $formatters = array(); if (module_exists('videofield')) { $formatters['videofield_player'] = array( 'label' => t('Video player'), 'field types' => array('file_video'), ); } return $formatters; } /** * Implementation of hook_field_formatter(). */ function videofield_display_field_formatter($field, $item, $formatter) { switch ($field['type']) { case 'file_video': require_once(drupal_get_path('module', 'videofield') .'/multimediafile.inc'); if (!isset($item['fid']) || empty($item['fid'])) { return ''; } $file = _field_file_load($item['fid']); $output = theme('videofield_display_player', $file, $field, $item); } return $output; } /** * theme function to control which player is presented */ function theme_videofield_display_player($file, $field, $item) { // include video.js file for Internet Explorer fixes drupal_add_js(drupal_get_path('module', 'videofield_display') . '/videofield_display.js'); // drupal_set_title(t('Playing') . ' ' . theme('placeholder', $field->title)); // if (variable_get('video_playcounter', 1)) { // db_query("UPDATE {video} SET play_counter = play_counter + 1 where vid = %d", $field->vid); //Increment play counter. // } switch (_videofield_display_get_filetype(file_create_url($file['filepath']))) { case 'divx': return theme('videofield_display_divx', $file, $field, $item); case 'mov': case 'mp4': case '3gp': case '3g2': return theme('videofield_display_quicktime', $$file, $field, $item); case 'rm': return theme('videofield_display_realmedia', $$file, $field, $item); // case 'flv': // return theme('videofield_display_flash', $$file, $field, $item); // case 'swf': // return theme('videofield_display_swf', $$file, $field, $item); // case 'dir': // case 'dcr': // return theme('videofield_display_dcr', $file, $field, $item); case 'wmv': return theme('videofield_display_windowsmedia', $file, $field, $item); // case 'ogg': // return theme('videofield_display_ogg_theora', $file, $field, $item); // case 'youtube': // return theme('videofield_display_youtube', $file, $field, $item); // case 'googlevideo': // return theme('videofield_display_googlevideo', $file, $field, $item); default: drupal_set_message('Video type not supported', 'error'); drupal_goto("node/$node->nid"); break; } } /********************************************************************* * Themeable functions for playing videos. They print a page with a player embedded. *********************************************************************/ /** * Play videos from in FLV Flash video format * * @param $field * object with node information * * @return * string of content to display */ //function theme_videofield_display_flash($field) { // $loader_location = variable_get('video_flvplayerloader', 'FlowPlayer.swf'); // // $url = _videofield_display_get_fileurl($file['filepath']); // $file = basename($url); // $base_url = substr($url, 0, strrpos($url, '/')); // // $height = $item['videoy'] + 24; // add commands height // // // this will be executed by not Internet Explorer browsers // $output = ' // // ' . "\n"; // // // this will be executed by Internet Explorer // $output .= '' . "\n"; // // // params will be passed to both IE or not IE browsers // $output .= ' // // // ' . "\n" // . _video_get_parameters($field) . // '

'. t('Your browser is not able to display this multimedia content.') .'

//
'; // // $output = _theme_videofield_display_format_play($output, t('http://www.macromedia.com/go/getflashplayer'), // t('Link to Macromedia Flash Player Download Page'), // t('Download latest Flash Player')); // return $output; //} // /** * Play Flash .swf files. * * @param $field * object with node information * * @return * string of content to display */ //function theme_videofield_display_swf($field) { // // $url = _videofield_display_get_fileurl($file['filepath']); // // // this will be executed by not Internet Explorer browsers // $output = ' // // ' . "\n"; // // // this will be executed by Internet Explorer // $output .= '' . "\n"; // // // params will be passed to both IE or not IE browsers // $output .= '' . "\n" // . _video_get_parameters($field) . // '

'. t('Your browser is not able to display this multimedia content.') .'

//
'; // // $output = _theme_videofield_display_format_play($output, t('http://www.macromedia.com/go/getflashplayer'), t('Link to Flash player download'), t('Download the latest Flash player')); // return $output; //} /** * Play Director .dcr/.dir files. * * @param $field * object with node information * * @return * string of content to display */ // //function theme_videofield_display_dcr($field) { // // $url = _videofield_display_get_fileurl($file['filepath']); // // // this will be executed by not Internet Explorer browsers // $output = ' // // ' . "\n"; // // // this will be executed by Internet Explorer // $output .= '' . "\n"; // //// params will be passed to both IE or not IE browsers // $output .= '' . "\n" // . _video_get_parameters($field) . // '

'. t('Your browser is not able to display this multimedia content.') .'

//
'; // // $output = _theme_videofield_display_format_play($output, t('http://www.macromedia.com/shockwave/download/'), // t('Link to Macromedia Shockwave Player Download Page'), // t('Download latest Shockwave Player')); // return $output; //} /** * Play videos from in DivX format * * @see http://developer.apple.com/internet/ieembedprep.html * @param $field * object with node information * * @return * string of content to display */ function theme_videofield_display_divx($file, $field, $item) { //Increase the height to accommodate the player controls on the bottom. $height = $item['videoy'] + 20; $url = _videofield_display_get_fileurl($file['filepath']); $output = ' '. "\n"; // this will be executed by not Internet Explorer browsers $output = ' '."\n"; $output .= ''."\n"; $output .= ''."\n"; $output .= ''; $output = _theme_videofield_display_format_play($output,t('http://www.divx.com/divx/webplayer/'), t('Link to DivX Download Page'), t('Download latest DivX Web Player')); return $output; } /** * Play videos from in Quicktime format * * @see http://developer.apple.com/internet/ieembedprep.html * @param $field * object with node information * * @return * string of content to display */ function theme_videofield_display_quicktime($file, $field, $item) { //Increase the height to accommodate the player controls on the bottom. $height = $item['videoy'] + 16; $url = _videofield_display_get_fileurl($file['filepath']); // this will be executed by not Internet Explorer browsers $output = ' ' . "\n"; // this will be executed by Internet Explorer $output .= '' . "\n"; // params will be passed to both IE or not IE browsers $output .= ' ' . "\n" /* . _video_get_parameters($field) */. '

'. t('Your browser is not able to display this multimedia content.') .'

'; // only one
needed becouse only one opening tag has been parsed by browsers /* $output = ''; */ $output = _theme_videofield_display_format_play($output, t('http://www.apple.com/quicktime/download'), t('Link to QuickTime Download Page'), t('Download latest Quicktime Player')); return $output; } /** * Play videos from in Realmedia format * * @param $field * object with node information * * @return * string of content to display */ function theme_videofield_display_realmedia($field) { // Real's embeded player includes the controls // in the height $item['videoy'] += 40; $url = _videofield_display_get_fileurl($file['filepath']); // this will be executed by not Internet Explorer browsers $output = ' ' . "\n"; // this will be executed by Internet Explorer $output .= '' . "\n"; // params will be passed to both IE or not IE browsers $output .= ' ' . _video_get_parameters($field) . '

'. t('Your browser is not able to display this multimedia content.') .'

'; // only one needed becouse only one opening tag has been parsed by browsers $output = _theme_videofield_display_format_play($output, t('http://www.real.com/'), t('Link to Real'), t('Download latest Realmedia Player')); return $output; } /** * Play videos from in WindowsMediaVideo format * * @param $field * object with node information * * @return * string of content to display */ function theme_videofield_display_windowsmedia($field) { // Windows Media's embeded player includes the controls in the height $item['videoy'] += 68; $url = _videofield_display_get_fileurl($file['filepath']); // this will be executed by not Internet Explorer browsers $output = ' ' . "\n"; // this will be executed by Internet Explorer $output .= '' . "\n"; // params will be passed to both IE or not IE browsers $output .= ' ' . _video_get_parameters($field) . '

'. t('Your browser is not able to display this multimedia content.') .'

'; // only one needed becouse only one opening tag has been parsed by browsers $output = _theme_videofield_display_format_play($output, t('http://windowsupdate.microsoft.com/'), t('Link to Windows Update'), t('Download latest Windows Media Player')); return $output; } /** * Play videos hosted on youtube.com * Allows users to host videos on youtube.com and then use the video ID to post it in the module. * In the future it could also use the youtube developer API to get info and comments of the video. * * @param $field * object with node information * * @return * string of content to display */ //function theme_videofield_display_youtube($field) { // $width = ($item['videox'] ? $item['videox'] : '425'); // $height = ($item['videoy'] ? $item['videoy'] : '350'); // // // // this will be executed by not Internet Explorer browsers // $output = ' // // ' . "\n"; // // // this will be executed by Internet Explorer // $output .= '' . "\n"; // // // params will be passed to both IE or not IE browsers // $output .= '' . "\n" // . _video_get_parameters($field) . // '

'. t('Your browser is not able to display this multimedia content.') .'

//
'; // // // $output = _theme_videofield_display_format_play($output, t('http://www.youtube.com/t/help_center'), t('Link to youtube.com'), t('youtube.com')); // return $output; //} /** * Play videos hosted on video.google.com * Allows users to host videos on video.google.com and then use the video ID to post it in the module. * * @param $field * object with node information * * @return * string of content to display */ //function theme_videofield_display_googlevideo($field) { // $width = ($item['videox'] ? $item['videox'] : '425'); // $height = ($item['videoy'] ? $item['videoy'] : '350'); // // Strip heading "google:" // $videoid = substr($field->vidfile, 7); // // // this will be executed by not Internet Explorer browsers // $output = ' // // ' . "\n"; // // // this will be executed by Internet Explorer // $output .= '' . "\n"; // // // params will be passed to both IE or not IE browsers // $output .= '' . "\n"; // // following a list of params simply copied from old embed tag params. I don't know if this are really needed. // $output .= ' // // // // // // ' // . _video_get_parameters($field) . // '

'. t('Your browser is not able to display this multimedia content.') .'

//
'; // // // $output = _theme_videofield_display_format_play($output, t('http://video.google.com/support'), t('Link to video.google.com'), t('video.google.com')); // return $output; //} /** * Play Ogg Theora videos with Cortado Applet * * @param $field * object with node information * * @return * string of content to display */ //function theme_videofield_display_ogg_theora($field) { // global $base_url; // $cortado_location = variable_get('video_cortado', $base_url . '/cortado.jar'); // $url = _videofield_display_get_fileurl($file['filepath']); // // $width = ($item['videox'] ? $item['videox'] : '425'); // $height = ($item['videoy'] ? $item['videoy'] : '350'); // // $output = ' // // // // // // // // // // // // // // // // // // // // This browser does not have a Java Plug-in.
// // Get the latest Java Plug-in here. // //
//
// '; // // $output = _theme_videofield_display_format_play($output, // t('http://java.com/download/'), t('Link to java.com'), t('Download Java')); // return $output; //} /** * Cut down on redundant link text * * @param $url * string URL to link to * * @param $title * string title of link to show on mouseover * * @param $link_text * string text of the link * * @return * string HTML link */ function _theme_videofield_display_format_play($output, $url, $title, $link_text) { $output = "\n
\n" . $output; $output .= "

\n". t('Problems viewing videos?'); $output .= "
\n"; $output .= l($link_text, $url, array('title' => $title), NULL, NULL, TRUE); return $output ."\n

\n
\n"; } /** * Pull the file extension from a filename * * @param $vidfile * string filename to get the filetype from. * * @return * string value of file type or boolean FALSE on error */ function _videofield_display_get_filetype($vidfile) { //If the filename doesn't contain a ".", "/", or "\" and is exactly 11 characters then consider it a youtube video ID. if (!strpos($vidfile, '.') and !strpos($vidfile, '/') and !strpos($vidfile, '\\') and strlen($vidfile) == 11) { $file_type = 'youtube'; } else if (strpos($vidfile, 'google:') === 0) { $file_type = 'googlevideo'; } else if (strstr($vidfile, '.')) { //If file contains a "." then get the file extension after the "." $file_type = substr($vidfile, strrpos($vidfile, '.') + 1); } else { $file_type = FALSE; } return $file_type; } /** * Settings Hook * * @return * string of form content or error message */ //function videofield_display_settings_form() { // global $base_url; // // //Must have "administer site configuration" and "administer video" privilages. // if (!user_access('administer video')) { // drupal_access_denied(); // } // $options = array(1 => 'Yes', 0 => 'No'); // // $form = array(); // $form['tabs'] = array('#type' => 'fieldset', '#title' => t('Tab menu options'), '#collapsible' => TRUE, '#collapsed' => TRUE); // $form['tabs']['video_playinbody'] = array( // '#type' => 'radios', // '#title' => t('Play in node'), // '#options' => $options, // '#default_value' => variable_get('video_playinbody', 1), // '#description' => t('Toggle display of video in the body of the node.')); // $form['tabs']['video_displayplaymenutab'] = array( // '#type' => 'radios', // '#title' => t('Display play menu tab'), // '#options' => $options, // '#default_value' => variable_get('video_displayplaymenutab', 1), // '#description' => t('Toggle display of menu link to play video from the node page. If you have chosen to display the video in the body of the node, then this is redundant and must be set to "No."')); // $form['tabs']['video_displaydownloadmenutab'] = array( // '#type' => 'radios', // '#title' => t('Display download menu tab'), // '#options' => $options, // '#default_value' => variable_get('video_displaydownloadmenutab', 1), // '#description' => t('Toggle display of menu link to download video from the node page.')); // // $form['flash'] = array('#type' => 'fieldset', '#title' => t('Flash settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); // $form['flash']['video_flvplayerloader'] = array( // '#type' => 'textfield', // '#title' => t('Filename of Flash loader'), // '#default_value' => variable_get('video_flvplayerloader', 'FlowPlayer.swf'), // '#description' => t('The name of the Shockwave file that manages loading the FLV movie.')); // $form['ogg'] = array('#type' => 'fieldset', '#title' => t('Ogg Theora settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); // $form['ogg']['video_cortado'] = array( // '#type' => 'textfield', // '#title' => t('Filename of Cortado Java Applet'), // '#default_value' => variable_get('video_cortado', $base_url . '/cortado.jar'), // '#description' => t('The path to the Cortado Applet to play Ogg Theora Files.')); // $form['menu'] = array('#type' => 'fieldset', '#title' => t('Items to display in the node menu'), '#weight' => -5, '#collapsible' => TRUE, '#collapsed' => TRUE); // $form['menu']['video_displayplaylink'] = array( // '#type' => 'radios', // '#title' => t('Display play link'), // '#options' => $options, // '#default_value' => variable_get('video_displayplaylink', 1), // '#description' => t('Toggle display of "play" link (below the node content in most themes). If you choose to display the video in the body of the node, then this is redundant and must be set to "No."')); // $form['menu']['video_displaydownloadlink'] = array( // '#type' => 'radios', // '#title' => t('Display download link'), // '#options' => $options, // '#default_value' => variable_get('video_displaydownloadlink', 1), // '#description' => t('Toggle display of "download" link (below the node content in most themes).')); // $form['menu']['video_displayplaytime'] = array( // '#type' => 'radios', // '#title' => t('Display playtime'), // '#options' => $options, // '#default_value' => variable_get('video_displayplaytime', 1), // '#description' => t('Toggle the display of the playtime for a video.')); // $form['menu']['video_displayfilesize'] = array( // '#type' => 'radios', // '#title' => t('Display filesize'), // '#options' => $options, // '#default_value' => variable_get('video_displayfilesize', 1), // '#description' => t('Toggle the display of the filesize for a video.')); // // $form['counters'] = array('#type' => 'fieldset', '#title' => t('Statistics counters'), '#description' => t('To allow users to view counters visit: ') . l(t('access control'), 'admin/access'), '#collapsible' => TRUE, '#collapsed' => TRUE); // $form['counters']['video_playcounter'] = array( // '#type' => 'radios', // '#title' => t('Count play hits'), // '#options' => $options, // '#default_value' => variable_get('video_playcounter', 1), // '#description' => t('Counts a hit everytime someone views the play page.')); // $form['counters']['video_downloadcounter'] = array( // '#type' => 'radios', // '#title' => t('Count downloads'), // '#options' => $options, // '#default_value' => variable_get('video_downloadcounter', 1), // '#description' => t('Counts a hit everytime someone downloads a video.')); // // return system_settings_form($form); //} /** * Import the video.js script */ //function theme_video_get_script() { // drupal_set_html_head(''); //} /** * Returns an absolute url which references * to the video file * * @param $video_file * string containing absolute or relative URL to video. * * @return * string containing absolute URL path to video file. */ function _videofield_display_get_fileurl($video_file) { global $base_url; //creation of absolute url if (preg_match("/^(http|ftp|mm|rstp)(s?):\/\//", $video_file)) { //If path is absolute return check_plain($video_file); } else { // path is relative to drupal install return check_plain($base_url . '/' . $video_file); } }