? .video.module.marks ? video_manual_sizing.patch ? video_update.patch ? views_video.inc_.patch ? views_video.patch Index: video.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/video/video.module,v retrieving revision 1.68.2.15 diff -u -r1.68.2.15 video.module --- video.module 5 Mar 2008 16:36:41 -0000 1.68.2.15 +++ video.module 15 Mar 2008 13:42:23 -0000 @@ -11,6 +11,11 @@ */ + +// the id in the select field for manually assign resolution values. See functions below. +define("VIDEO_MANUALLY_SET_VIDEO_RESOLUTION_SELECT_ID", 30); + + /** * Let's include views logic if views module is enabled */ @@ -234,7 +239,7 @@ * array of permissions */ function video_perm() { - $array = array('create video', 'access video', 'administer video', 'play video', 'download video', 'view play counter', 'view download counter', 'edit own video', 'edit all video nodes'); + $array = array('create video', 'access video', 'administer video', 'play video', 'download video', 'view play counter', 'view download counter', 'edit own video', 'edit all video nodes', 'manually set video resolution'); return $array; } @@ -307,7 +312,7 @@ '#type' => 'textfield', '#title' => t("Default width"), '#default_value' => variable_get("video_resolution_width", 400), - '#description' => t('The width which will be used to scale video during playing. This let all videos on the website look the same') + '#description' => t('The width which will be used to scale video during playing. This let all videos on the website look the same. NOTE: You can disable video scaling making this field blank.') ); $i = 1; @@ -622,15 +627,46 @@ $form['video'] = array('#type' => 'fieldset', '#title' => t('Video Information'), '#weight' => -19); if(!video_support_autoresolution($node)) { // this vtype doesn't support autoresolution + + $selected_option = _video_get_resolution_selected_option($node); + // let's display the resolution selection $form['video']['vresolution'] = array( '#type' => 'select', '#title' => t('Resolution'), '#description' => t("Select the approriate resolution (aspect ratio) for your video.
If you don't know what to choose then the default value will probably be ok for you."), '#options' => _video_get_resolution_options(), - '#default_value' => _video_get_resolution_selected_option($node), + '#default_value' => $selected_option, '#required' => true, ); + + + // manual resolution form logic + $form['video']['manual_resolution'] = array( + '#type' => 'fieldset', + '#title' => t('Manual resolution'), + ); + + $is_manually_set = ($selected_option == VIDEO_MANUALLY_SET_VIDEO_RESOLUTION_SELECT_ID); + $width = ($is_manually_set ? $node->videox : NULL); + $height = ($is_manually_set ? $node->videoy : NULL);; + + $form['video']['manual_resolution']['manual_resolution_width'] = array( + '#type' => 'textfield', + '#title' => t('Width'), + '#size' => 4, + '#maxlength' => 4, + '#default_value' => $width, + '#description' => t('Video width expressed in pixels.'), + ); + $form['video']['manual_resolution']['manual_resolution_height'] = array( + '#type' => 'textfield', + '#title' => t('Height'), + '#size' => 4, + '#maxlength' => 4, + '#default_value' => $height, + '#description' => t('Video height expressed in pixels.'), + ); } if(!video_support_autoplaytime($node)) { // this vtype doesn't support autoplaytime @@ -685,8 +721,6 @@ } module_invoke('video_'.$node->vtype, 'v_validate', $node); - - } @@ -704,11 +738,15 @@ } else { // we should have a good value (checked by Form API) - if($node->vresolution) { + if($node->vresolution < VIDEO_MANUALLY_SET_VIDEO_RESOLUTION_SELECT_ID) { $res = explode('x', variable_get('video_resolution_' . $node->vresolution . '_value', '')); $node->videox = $res[0]; $node->videoy = $res[1]; } + else if($node->vresolution == VIDEO_MANUALLY_SET_VIDEO_RESOLUTION_SELECT_ID) { // this is a manually set video resolution + $node->videox = $node->manual_resolution_width; + $node->videoy = $node->manual_resolution_height; + } } if(video_support_autoplaytime($node)) { // vtype support auto playtime @@ -1328,6 +1366,12 @@ } $i++; } + + if(user_access('manually set video resolution')) { + // to manually insert resolution values + $options[VIDEO_MANUALLY_SET_VIDEO_RESOLUTION_SELECT_ID] = t("manually set "); + } + return $options; } @@ -1336,6 +1380,11 @@ * Get the selected resolution id from the videox and videoy fields */ function _video_get_resolution_selected_option($node) { + + if(!isset($node->nid)) { // do not assign a default value if we are creating a new node + return NULL; + } + $value = $node->videox . "x" . $node->videoy; $i = 1; @@ -1346,6 +1395,12 @@ $i++; } + + // we did not find the value in the presets fields + // let's consider it as a manually set resolution (if the user have permissions) + if(user_access('manually set video resolution')) { + return VIDEO_MANUALLY_SET_VIDEO_RESOLUTION_SELECT_ID; + } } /** @@ -1353,8 +1408,22 @@ */ function _video_scale_video(&$node) { $def_width = (int) variable_get("video_resolution_width", 400); + + + if($def_width <= 0) { // video scaling has been disabled + + if (!$node->videox || !$node->videoy) { // we shouldn't have videox or videoy null.. but this is just in case for safety + $node->video_scaled_x = 400; + $node->video_scaled_y = 300; + } else { + $node->video_scaled_x = $node->videox; + $node->video_scaled_y = $node->videoy; + } + + return; + } - if (!$node->videox || !$node->videoy) { + if (!$node->videox || !$node->videoy) { // we shouldn't have videox or videoy null.. but this is just in case for safety $height = $def_width * 3 / 4; } else { $height = $def_width * ($node->videoy / $node->videox); // do you remember proportions?? :-) @@ -1369,3 +1438,5 @@ $node->video_scaled_y = $height; } + +