diff options
author | Fabio Varesano <fax8@13637.no-reply.drupal.org> | 2005-10-29 09:26:00 +0000 |
---|---|---|
committer | Fabio Varesano <fax8@13637.no-reply.drupal.org> | 2005-10-29 09:26:00 +0000 |
commit | d95983afe8b7c3c552001cac295cfd25b75a36df (patch) | |
tree | f13e35f92a30bd7f1869b79a024f41335c91507b | |
parent | 75a20c4bb90784f061e2a9297f8386c4096dfc0e (diff) | |
download | video-d95983afe8b7c3c552001cac295cfd25b75a36df.tar.gz video-d95983afe8b7c3c552001cac295cfd25b75a36df.tar.bz2 |
Added displaying for optional video metadata.
Changed default behaviour if download dir empty:
Instead of writing an error "There are no files to download for this video."
lets download play file.
-rw-r--r-- | video.module | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/video.module b/video.module index c2e44b6..d065959 100644 --- a/video.module +++ b/video.module @@ -296,6 +296,9 @@ function video_settings() { $output .= form_textfield(t('File extensions to show'), 'video_download_ext', variable_get('video_download_ext', 'mov,wmv,rm,flv,avi,divx,mpg,mpeg,mp4,zip'), 60, 250, t('The extensions of files to list from the multi-file download folder on the download page. Extensions should be comma seperated with no spaces, for example (mov,wmv,rm).')); + $output .= form_radios(t('Display Optional Metadata'), 'video_display_metadata', + variable_get('video_display_metadata', FALSE), array(0 => 'No', 1 => 'Yes'), + t('Allows displaying a list of videos metadata: Video bitrate, Audio bitrate, Audio Sampling Rate and Audio Channels.')); $group = form_textfield(t('Custom field group title'), 'video_customfieldtitle', variable_get('video_customfieldtitle', ''), 40, 200, t('Title of the group of all custom fields.')); $group .= form_radios(t('Start group initially collapsed'), 'video_customgroupcollapsed', variable_get('video_customgroupcollapsed', 1), array(0 => 'No', 1 => 'Yes'), @@ -411,12 +414,14 @@ function video_form($node) { $output .= form_group_collapsible(variable_get('video_customfieldtitle', 'Custom Fields'), $group, variable_get('video_customgroupcollapsed', '0'), t('')); } - $group = form_textfield(t('Video Bitrate'), 'video_bitrate', ($node->video_bitrate == 0) ? '' : $node->video_bitrate, 11, 11, t('Integer value of video bitrate')); - $group .= form_textfield(t('Audio Bitrate'), 'audio_bitrate', ($node->audio_bitrate == 0) ? '' : $node->audio_bitrate, 11, 11, t('Integer value of audio bitrate')); + // Optional Video Metadata + $group = form_textfield(t('Video Bitrate'), 'video_bitrate', ($node->video_bitrate == 0) ? '' : $node->video_bitrate, 11, 11, t('Integer value of video bitrate in Bytes/seconds')); + $group .= form_textfield(t('Audio Bitrate'), 'audio_bitrate', ($node->audio_bitrate == 0) ? '' : $node->audio_bitrate, 11, 11, t('Integer value of audio bitrate in Bytes/seconds')); $group .= form_textfield(t('Audio Sampling Rate'), 'audio_sampling_rate', ($node->audio_sampling_rate == 0) ? '' : $node->audio_sampling_rate, 11, 11, t('Integer value of audio sampling rate in Hz')); $group .= form_select(t('Audio Channels'), 'audio_channels', $node->audio_channels, array('' => '', '5.1' => t('5.1'), 'stereo' => t('Stereo'), 'mono' => t('Mono'))); - $output .= form_group_collapsible(t('Optional Metadata'), $group, TRUE, t('Metadata entered here will not be displayed. It is currently for administrative reference only.')); - + $output .= form_group_collapsible(t('Optional Metadata'), $group, !variable_get('video_display_metadata', FALSE), t('Metadata entered here will be displayed only if administrator enables displaying on the '.l(t('administration page'),'admin/settings/video', array('title'=>t('administration page'))).'.')); // We display this group expanded only if displaying of optional metadata is enabled on front page. + // Ends Video Optional Metadata + if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('video', $node)); } @@ -771,9 +776,13 @@ function video_play() { function video_view(&$node, $teaser = FALSE, $page = FALSE) { //Run the body through the standard filters. $node = node_prepare($node, $teaser); - //Add the HTML formatted output of the custom fields to the bottom. if ($teaser == FALSE) { + //Add the HTML formatted output of the custom fields to the bottom. $node->body .= theme('video_view', $node); + if(variable_get('video_display_metadata', FALSE)) { + //Add the HTML formatted output of the optional video metadata to the bottom. + $node->body .= theme('video_display_metadata', $node); + } } } @@ -1016,6 +1025,38 @@ function theme_video_view($node) { } /** + * Display optional metadata (Video and Audio bitrate,..) on the view page. + * + * @param $node + * object with node information + * + * @return + * string of content to display + $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, + */ +function theme_video_display_metadata(&$node) { + // Do not do anything if all fields are empty + if($node->video_bitrate == 0 && $node->audio_bitrate == 0 && $node->audio_sampling_rate == 0 && $node->audio_channels == 0) + return ''; + $output = "\n\n<div class=\"video_metadata\">\n"; + $output .= ' <div class="title"><h2>'.t('Video Metadata')."</h2></div>\n"; + if($node->video_bitrate != 0) { + $output .= ' <div class="odd"><b>' . t('Video Bitrate') . '</b> '.format_size($node->video_bitrate) . '/seconds</div>'; + } + if($node->audio_bitrate != 0) { + $output .= ' <div class="even"><b>' . t('Audio Bitrate') . '</b> '.format_size($node->audio_bitrate) . '/seconds</div>'; + } + if($node->audio_sampling_rate != 0) { + $output .= ' <div class="odd"><b>' . t('Audio Sampling Rate') . '</b> '. $node->audio_sampling_rate . ' ' . t('Hz') . '</div>'; + } + if($node->audio_channels != '') { + $output .= ' <div class="even"><b>' . t('Audio Channels') . '</b> '. $node->audio_channels . '</div>'; + } + $output .= '</div>'; //Closing div video_metadata + return $output; +} + +/** * Outputs the HTML for the download page when multi-file download are turned on. * * @param $node @@ -1046,9 +1087,8 @@ function theme_video_download(&$node) { $headers = array(t('File Link'), t('File Size'), t('File Type')); $output .= theme_table($headers, $file_array_table); //Create the table of files. $output .= '</div>'; //Close the "videodownload" class. - } else { //If there is an error. - drupal_set_message(t('There are no files to download for this video.'), 'error'); - drupal_goto("node/$node->nid"); //Redirect back to view page. + } else { //If there is an error lets download the play file. + _video_download_goto($node->vidfile, $node->nid); } //Adds a breadcrumb back to view on the download page. This may not be needed but some better breadcrumbs are. |