From 8041073c8d74e5d24e3b9f10143f3e4bd04db2de Mon Sep 17 00:00:00 2001 From: Heshan Wanigasooriya Date: Tue, 23 Mar 2010 04:17:29 +0000 Subject: removing old files and commenting new file field and other files to the vidoe module page. --- includes/common.inc | 384 +++++++++++++++++++++++++++------------------------- 1 file changed, 201 insertions(+), 183 deletions(-) (limited to 'includes/common.inc') diff --git a/includes/common.inc b/includes/common.inc index c70a7a5..ce9d89c 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -4,57 +4,82 @@ * @file * Add some common functions for the various video types supported * - * @author Fabio Varesano - * porting to Drupal 6 - * @author Heshan Wanigasooriya - * @author Glen Marianko Twitter@demoforum * @todo Configure default players by video filetype (user configurable?) */ + /** * Get the object for the suitable player for the parameter resource -*/ -function _video_common_get_player($node) { - switch (_video_get_filetype($node->vidfile)) { + */ +function _video_common_get_player($element) { + $field = content_fields($element['#field_name'], $element['#type_name']); + $resolution = array_filter(explode(':', $field['widget']['default_resolution'])); + $element['#item']['data']['height'] = $element['#item']['data']['width'] * ($resolution[1]/$resolution[0]); + + $op = _video_get_filetype($element['#item']['filename']); + //play HQ mp4 videos in flash player + if(variable_get('mp4_play_in_flowplayer', FALSE) && $op == 'mp4'){ + $op = 'mp4f'; + } + switch ($op) { case 'divx': - return theme('video_play_divx', $node); + return theme('video_play_divx', $element); case 'mov': case '3gp': case '3g2': - case 'mp4': - return theme('video_play_quicktime', $node); + case 'mp4': // video/mp4 + return theme('video_play_quicktime', $element); case 'rm': - return theme('video_play_realmedia', $node); - case 'flv': - return theme('video_play_flash', $node); + return theme('video_play_realmedia', $element); + case 'mp4f': + case 'f4v' : + case 'flv' : // flowplayer also supprts MP4, H.264 (.extension?) + return theme('video_play_flash', $element); case 'swf': - return theme('video_play_swf', $node); + return theme('video_play_swf', $element); case 'dir': case 'dcr': - return theme('video_play_dcr', $node); + return theme('video_play_dcr', $element); case 'asf': case 'wmv': case 'avi': case 'mpg': case 'mpeg': - return theme('video_play_windowsmedia', $node); + return theme('video_play_windowsmedia', $element); case 'ogg': - return theme('video_play_ogg_theora', $node); - case 'youtube': - return theme('video_play_youtube', $node); - case 'googlevideo': - return theme('video_play_googlevideo', $node); + return theme('video_play_ogg_theora', $element); default: - drupal_set_message('Video type not supported', 'error'); + drupal_set_message('No video player is configured for ' .$op, 'error'); break; } } + +/** + * 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 _video_get_filetype($vidfile) { + if (strstr($vidfile, '.')) { //If file contains a "." then get the file extension after the ". + $file_type = end(explode('.', $vidfile)); + } + else { + $file_type = FALSE; + } + + return strtolower($file_type); +} + /********************************************************************* * Themeable functions for playing videos. They print a page with a player embedded. *********************************************************************/ - /** +/** * Play videos from in FLV Flash video format * * @param $node @@ -63,44 +88,34 @@ function _video_common_get_player($node) { * @return * string of content to display */ -function theme_video_play_flash($node) { - $loader_location = variable_get('video_flvplayerloader', 'FlowPlayer.swf'); - - $url = _video_get_fileurl($node->vidfile); - $file = basename($url); - $base_url = substr($url, 0, strrpos($url, '/')); - - $height = $node->video_scaled_y + 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 - $config = sprintf("config={'playerId':'player','clip':{'url':'%s'},'playlist':[{'url':'%s','autoPlay':%s}]}", $base_url . '/' . $file, $base_url . '/' . $file, (variable_get('video_autoplay', TRUE) ? 'true' : 'false')); - $output .= ' - - - - - ' - . _video_get_parameters($node) . - '

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

-
'; - - $output = theme('video_format_play', $output, t('http://get.adobe.com/flashplayer/'), - t('Link to Adobe Flash Player Download Page'), - t('Download latest Flash Player')); - return $output; +function theme_video_play_flash($element) { +//TODO : remove item height set in here + $video = file_create_url($element['#item']['filepath']); + // echo file_create_url($element['#item']['filepath']); + $width = isset($element['#item']['data']['width']) ? $element['#item']['data']['width'] : ''; + $height = isset($element['#item']['data']['height']) ? $element['#item']['data']['height'] : ''; + $width = empty($width) ? '350px' : $width .'px'; + $height = empty($height) ? '285px' : $height .'px'; + $id = $element['#formatter']; + + if (module_exists('flowplayer')) { + $output = theme('flowplayer', array( + 'clip' => array( + 'url' => $video, + //TODO: Make settings for this + 'autoPlay' => variable_get('video_autoplay', TRUE), // Turn autoplay off + 'autoBuffering' => variable_get('video_autobuffering', TRUE), + ), + ), + $id, array( + 'style' => "width: $width; height: $height", + ) + ); + } + else { + $output='

Use SwfTools Module to play FLV files if you only convert/upload FLV videos or FlowPlayer Module must be enabled in order to play FLV videos with other types.

'; + } + return $output; } /** @@ -112,31 +127,36 @@ codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve * @return * string of content to display */ -function theme_video_play_swf($node) { +function theme_video_play_swf($element) { + + $video = file_create_url($element['#item']['filepath']); + $width = isset($element['#item']['data']['width']) ? $element['#item']['data']['width'] : ''; + $height = isset($element['#item']['data']['height']) ? $element['#item']['data']['height'] : ''; + $width = empty($width) ? '350px' : $width .'px'; + $height = empty($height) ? '285px' : $height .'px'; - $url = _video_get_fileurl($node->vidfile); // this will be executed by not Internet Explorer browsers $output = ' - - ' . "\n"; + + ' . "\n"; // this will be executed by Internet Explorer $output .= '' . "\n"; + + ' . "\n"; // params will be passed to both IE or not IE browsers - $output .= ''. "\n" . + $output .= ''. "\n" . '' . "\n" - . _video_get_parameters($node) . - '

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

-
'; - - $output = theme('video_format_play', $output, t('http://www.macromedia.com/go/getflashplayer'), t('Link to Flash player download'), t('Download the latest Flash player')); + . //_video_get_parameters($node) . + '

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

+
'; +/* + $output = theme('video_format_play', $output, t('http://www.macromedia.com/go/getflashplayer'), t('Link to Flash player download'), t('Download the latest Flash player'));*/ return $output; } @@ -152,33 +172,37 @@ codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve * string of content to display */ -function theme_video_play_dcr($node) { +function theme_video_play_dcr($element) { - $url = _video_get_fileurl($node->vidfile); + $video = file_create_url($element['#item']['filepath']); + $width = isset($element['#item']['data']['width']) ? $element['#item']['data']['width'] : ''; + $height = isset($element['#item']['data']['height']) ? $element['#item']['data']['height'] : ''; + $width = empty($width) ? '350px' : $width .'px'; + $height = empty($height) ? '285px' : $height .'px'; // this will be executed by not Internet Explorer browsers $output = ' - - ' . "\n"; + + ' . "\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($node) . - '

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

-
'; + $output .= '' . "\n"; + // params will be passed to both IE or not IE browsers + $output .= '' . "\n" + . //_video_get_parameters($node) . + '

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

+
'; +/* $output = theme('video_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; + t('Download latest Shockwave Player'));*/ + return $output; } /** @@ -191,26 +215,31 @@ codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#vers * @return * string of content to display */ -function theme_video_play_divx($node) { - //Increase the height to accommodate the player controls on the bottom. - $height = $node->video_scaled_y + 20; +function theme_video_play_divx($element) { +//Increase the height to accommodate the player controls on the bottom. + $video = file_create_url($element['#item']['filepath']); + $width = isset($element['#item']['data']['width']) ? $element['#item']['data']['width'] : ''; + $height = isset($element['#item']['data']['height']) ? $element['#item']['data']['height'] : ''; + $width = empty($width) ? '350px' : $width .'px'; + $height = empty($height) ? '285px' : $height .'px'; - $url = _video_get_fileurl($node->vidfile); + //$url = _video_get_fileurl($node->vidfile); $output = ' - - '. "\n"; + + '. "\n"; // this will be executed by not Internet Explorer browsers $output = ' - - '."\n"; + + '."\n"; - $output .= ''."\n"; + $output .= ''."\n"; $output .= ''."\n"; $output .= ''; + /* $output = theme('video_format_play', $output,t('http://www.divx.com/divx/webplayer/'), t('Link to DivX Download Page'), - t('Download latest DivX Web Player')); + t('Download latest DivX Web Player'));*/ return $output; } @@ -224,45 +253,38 @@ function theme_video_play_divx($node) { * @return * string of content to display */ -function theme_video_play_quicktime($node) { - //Increase the height to accommodate the player controls on the bottom. - $height = $node->video_scaled_y + 16; - - $url = _video_get_fileurl($node->vidfile); +function theme_video_play_quicktime($element) { +//Increase the height to accommodate the player controls on the bottom. + $video = file_create_url($element['#item']['filepath']); + $width = isset($element['#item']['data']['width']) ? $element['#item']['data']['width'] : ''; + $height = isset($element['#item']['data']['height']) ? $element['#item']['data']['height'] : ''; + $width = empty($width) ? '350px' : $width .'px'; + $height = empty($height) ? '285px' : $height .'px'; // this will be executed by not Internet Explorer browsers $output = ' - - ' . "\n"; + + ' . "\n"; // this will be executed by Internet Explorer - $output .= '' . "\n"; + $output .= '' . "\n"; // params will be passed to both IE or not IE browsers //GMM: kioskmode enabled so users don't bypass download security video through player - $output .= ' - + $output .= ' + ' . "\n" - . _video_get_parameters($node) . - '

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

-
'; // only one
needed becouse only one opening tag has been parsed by browsers + . //_video_get_parameters($node) . + '

'. 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('video_format_play', $output, t('http://www.apple.com/quicktime/download'), - t('Link to QuickTime Download Page'), - t('Download latest Quicktime Player')); return $output; } @@ -275,27 +297,29 @@ data="'. $url .'"> * @return * string of content to display */ -function theme_video_play_realmedia($node) { - // Real's embeded player includes the controls - // in the height - $node->video_scaled_y += 40; - - $url = _video_get_fileurl($node->vidfile); +function theme_video_play_realmedia($element) { +// Real's embeded player includes the controls +// in the height + $video = file_create_url($element['#item']['filepath']); + $width = isset($element['#item']['data']['width']) ? $element['#item']['data']['width'] : ''; + $height = isset($element['#item']['data']['height']) ? $element['#item']['data']['height'] : ''; + $width = empty($width) ? '350px' : $width .'px'; + $height = empty($height) ? '285px' : $height .'px'; // this will be executed by not Internet Explorer browsers $output = ' - - ' . "\n"; + + ' . "\n"; // this will be executed by Internet Explorer - $output .= '' . "\n"; + $output .= '' . "\n"; // params will be passed to both IE or not IE browsers - $output .= ' + $output .= ' @@ -309,14 +333,14 @@ classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" > ' - . _video_get_parameters($node) . - '

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

-
'; // only one
needed becouse only one opening tag has been parsed by browsers - + . //_video_get_parameters($node) . + '

'. 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('video_format_play', $output, t('http://www.real.com/'), t('Link to Real'), - t('Download latest Realmedia Player')); + t('Download latest Realmedia Player'));*/ return $output; } @@ -329,44 +353,38 @@ classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" > * @return * string of content to display */ -function theme_video_play_windowsmedia($node) { - // Windows Media's embeded player includes the controls in the height - $node->video_scaled_y += 68; - $url = _video_get_fileurl($node->vidfile); +function theme_video_play_windowsmedia($element) { +// Windows Media's embeded player includes the controls in the height + $video = file_create_url($element['#item']['filepath']); + $width = isset($element['#item']['data']['width']) ? $element['#item']['data']['width'] : ''; + $height = isset($element['#item']['data']['height']) ? $element['#item']['data']['height'] : ''; + $width = empty($width) ? '350px' : $width .'px'; + $height = empty($height) ? '285px' : $height .'px'; // this will be executed by not Internet Explorer browsers $output = ' - - ' . "\n"; + + ' . "\n"; // this will be executed by Internet Explorer - $output .= '' . "\n"; + $output .= '' . "\n"; // params will be passed to both IE or not IE browsers - $output .= ' - + $output .= ' + ' - . _video_get_parameters($node) . - '

'. 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 = "\n
\n" . $output; - $output .= "

\n". t('Problems viewing videos?'); - $output .= "
\n"; - $output .= l(t('Download latest Windows Media Player'), t('http://windowsupdate.microsoft.com/'), array('attributes' => array('title' => t('Link to Windows Update')), 'absolute' => TRUE)); - //GMM: add link to Windows Media Player plug-in for Firefox browsers - $output .= "
\n"; - $output .= l(t('Download the plug-in for Firefox'), t('http://support.mozilla.com/en-US/kb/Using+the+Windows+Media+Player+plugin+with+Firefox'), array('attributes' => array('title' => t('Link to Firefox Plug-in')), 'absolute' => TRUE)); - $output .= "\n

\n
\n"; + . //_video_get_parameters($node) . + '

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

+ '; // only one needed becouse only one opening tag has been parsed by browsers + return $output; } @@ -382,10 +400,11 @@ classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" > * @return * string of content to display */ -function theme_video_play_ogg_theora($node) { +function theme_video_play_ogg_theora($element) { global $base_url; $cortado_location = variable_get('video_cortado', $base_url . '/cortado.jar'); - $url = _video_get_fileurl($node->vidfile); + //$url = _video_get_fileurl($node->vidfile); + $video = file_create_url($element['#item']['filepath']); $width = ($node->video_scaled_x ? $node->video_scaled_x : '425'); $height = ($node->video_scaled_y ? $node->video_scaled_y : '350'); @@ -406,7 +425,7 @@ function theme_video_play_ogg_theora($node) { - + @@ -422,9 +441,8 @@ function theme_video_play_ogg_theora($node) { '; - +/* $output = theme('video_format_play', $output, - t('http://java.com/download/'), t('Link to java.com'), t('Download Java')); + t('http://java.com/download/'), t('Link to java.com'), t('Download Java'));*/ return $output; -} - +} \ No newline at end of file -- cgit v1.2.3