aboutsummaryrefslogtreecommitdiff
path: root/plugins/video_optmetadata/video_optmetadata.module
diff options
context:
space:
mode:
authorFabio Varesano <fax8@13637.no-reply.drupal.org>2006-06-18 14:41:32 +0000
committerFabio Varesano <fax8@13637.no-reply.drupal.org>2006-06-18 14:41:32 +0000
commitbff6fafe62a4201c99bdba20144313276d654bca (patch)
tree3f58c4adad06446274c6e842f9f9fb6155ba4b34 /plugins/video_optmetadata/video_optmetadata.module
parent2540b23c26f79ed8b223d6ec8b00ca4bfc76e7ef (diff)
downloadvideo-bff6fafe62a4201c99bdba20144313276d654bca.tar.gz
video-bff6fafe62a4201c99bdba20144313276d654bca.tar.bz2
List of changes:
Pluginization: Video.module file was too big and complex. I isolated each different feature which was not excencial and removed from the video.module file. Those features are now added by helper modules called plugins under the directory "plugins". The download has been separed from multidownload. There is now a separated plugin called video_multidownload which add multidownload feature. There are also some hooks being defined. See file hooks.php for details. XHTML Compliace: I worked hard to remove unvalid code from video module. Now the code generated by the module validates on W3C validator. This will probæbly generate some problems with uncommon browsers we will try to solve them as soon as reported. Thanks a lot to Karl Rudd who point me to the right direction towards compliace. Thumbnailing: There is plugin called video_image.module which add thumbnails support for the video module. Thumbnails are uploaded throught the video creation form and a image node is created with it. Video file Uploads: There is a plugin called video_upload.module which add a file upload field to the node creation form. The uploaded file is automatically set as path of the video. Then usable for plays/downloads. NOTE ON BUGS: I tryed to test new features the most as possible but I can't guarantee that all this code is bugfree. Video module is becaming too big to be tested by only one person (me). Hope you guys will be able to help with debugging. Fabio
Diffstat (limited to 'plugins/video_optmetadata/video_optmetadata.module')
-rw-r--r--plugins/video_optmetadata/video_optmetadata.module134
1 files changed, 134 insertions, 0 deletions
diff --git a/plugins/video_optmetadata/video_optmetadata.module b/plugins/video_optmetadata/video_optmetadata.module
new file mode 100644
index 0000000..f3764d2
--- /dev/null
+++ b/plugins/video_optmetadata/video_optmetadata.module
@@ -0,0 +1,134 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Enable addition of optional metadata on video nodes created by video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_help().
+ */
+function video_optmetadata_help($section) {
+ switch ($section) {
+ case 'admin/modules#description':
+ return t('Enable addition of optional metadata on video nodes created by video module. Optional metadata are Video Bitrate, Audio Bitrate, Audio Sampling Rate and Audio Channels.');
+ }
+}
+
+
+/**
+ * Implementation of hook_perm().
+ */
+function video_optmetadata_perm() {
+ return array('insert optional metadata');
+}
+
+
+
+/**
+ * Implementation of hook_form_alter()
+ * We use this to add some fields to the video creation form.
+ * In those fields users will be able to insert some video metadatas.
+ */
+function video_optmetadata_form_alter($form_id, &$form) {
+
+ if($form_id == 'video_node_form' && isset($form['video']) && user_access('insert optional metadata')) {
+
+ // get node object
+ $node = $form['#node'];
+ // Optional Video Metadata. We display this group expanded only if displaying of optional metadata is enabled.
+ $form['metadata'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Optional Metadata'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#weight' => -16,
+ '#description' => t('Insert here the metadata informations.')
+ );
+ $form['metadata']['video_bitrate'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Video Bitrate'),
+ '#length' => 11,
+ '#maxlength' => 11,
+ '#default_value' => $node->video_bitrate,
+ '#description' => t('Video bitrate in kbits/sec.')
+ );
+ $form['metadata']['audio_bitrate'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Audio Bitrate'),
+ '#length' => 11,
+ '#maxlength' => 11,
+ '#default_value' => $node->audio_bitrate,
+ '#description' => t('Audio bitrate in kbits/sec.')
+ );
+ $form['metadata']['audio_sampling_rate'] = array(
+ '#type' => 'select',
+ '#title' => t('Audio Sampling Rate'),
+ '#options' => array(0 => 'none', 8000 => '8 kHz', 11025 => '11 kHz', 16000 => '16 kHz', 22050 => '22 kHz', 32000 => '32 kHz', 44100 => '44.1 kHz', 48000 => '48 kHz', 96000 => '96 kHz', 192400 => '192 kHz'),
+ '#default_value' => $node->audio_sampling_rate,
+ '#description' => t('Integer value of audio sampling rate in Hz.')
+ );
+ $form['metadata']['audio_channels'] = array(
+ '#type' => 'select',
+ '#title' => t('Audio Channels'),
+ '#options' => array('' => 'none', '5.1' => t('5.1'), 'stereo' => t('Stereo'), 'mono' => t('Mono')),
+ '#default_value' => $node->audio_channels
+ );
+ // Ends Video Optional Metadata
+ }
+}
+
+
+/**
+ * Implementation of hook_nodeapi()
+ */
+function video_optmetadata_nodeapi(&$node, $op, $teaser) {
+ if($node->type == 'video') {
+ switch ($op) {
+ case 'view':
+ //Add the HTML formatted output of the optional video metadata to the bottom.
+ $node->body .= theme('video_metadata', $node);
+ break;
+ }
+ }
+}
+
+/**
+ * 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_metadata($node) {
+ //Make sure atleast one fields had data.
+ if ($node->video_bitrate != 0 or $node->audio_bitrate != 0 or $node->audio_sampling_rate != 0 or $node->audio_channels != 0) {
+ $output = "\n\n<div class=\"video_metadata\">\n";
+ $output .= ' <div class="title"><h2>'.t('Video Metadata')."</h2></div>\n";
+ if($node->video_bitrate != 0) {
+ $fields[] = array('title' => t('Video Bitrate') . ':', 'body' => $node->video_bitrate . ' ' . t('kbits/sec'));
+ }
+ if($node->audio_bitrate != 0) {
+ $fields[] = array('title' => t('Audio Bitrate') . ':', 'body' => $node->audio_bitrate . ' ' . t('kbits/sec'));
+ }
+ if($node->audio_sampling_rate != 0) {
+ $fields[] = array('title' => t('Audio Sampling Rate') . ':', 'body' => $node->audio_sampling_rate . ' ' . t('Hz'));
+ }
+ if($node->audio_channels != '') {
+ $fields[] = array('title' => t('Audio Channels') . ':', 'body' => $node->audio_channels);
+ }
+ $output .= theme('video_fields', $fields); //Generate the fields HTML.
+ $output .= '</div>'; //Closing div video_metadata
+ }
+ else { //If all the fields are blank then display nothing.
+ $output = '';
+ }
+ return $output;
+}