*** videojs.theme.inc.orig	2010-10-31 08:43:03.000000000 -0400
--- videojs.theme.inc	2010-12-01 16:22:07.000000000 -0500
***************
*** 10,24 ****
   * Preprocess function for videojs.tpl.php when using a playlist.
   */
  function template_preprocess_videojs_formatter_videojs(&$vars) {
    videojs_add();
!   $vars['items'] = array();
    $field_name = $vars['element']['#field_name'];
    $node = $vars['element']['#node'];
!   $number = 0;
    foreach ($node->$field_name as $item) {
!     $vars['items'][] = $item;
    }
    $vars['player_id'] = 'videojs-' . $vars['element']['#node']->nid . '-' . str_replace('_', '-', $vars['element']['#field_name']);
  }
  
  /**
--- 10,79 ----
   * Preprocess function for videojs.tpl.php when using a playlist.
   */
  function template_preprocess_videojs_formatter_videojs(&$vars) {
+   $codecs = array(
+     'video/mp4' => array (
+       array('width' => '720', 'height' => '576', 'type' => "video/mp4; codecs='avc1.42E01E, mp4a.40.2'"), // Profile: Baseline, Level: 3.0
+       array('width' => '1280', 'height' => '720', 'type' => "video/mp4; codecs='avc1.4D401F, mp4a.40.2'"), // Profile: Main, Level: 3.1
+       array('width' => '1920', 'height' => '1088', 'type' => "video/mp4; codecs='avc1.640029, mp4a.40.2'"), // Profile: High, Level: 4.1 
+       array('width' => '2048', 'height' => '2048', 'type' => "video/mp4; codecs='avc1.58A033, mp4a.40.2'") // Profile: Extended, Level: 5.1 
+     ),
+     'video/webm' =>  'video/webm; codec="vp8, vorbis"',
+     'application/octet-stream' =>  'video/webm; codec="vp8, vorbis"',
+     'video/ogg' => 'video/ogg; codec="theora, vorbis"',
+     'application/ogg' => 'video/ogg; codec="theora, vorbis"',
+     'video/quicktime' => 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
+   );
+ 
    videojs_add();
!   $vars['width'] = variable_get('videojs_width', 640);
!   $vars['height'] = variable_get('videojs_height', 264);
    $field_name = $vars['element']['#field_name'];
    $node = $vars['element']['#node'];
!   $items_mp4 = array();
!   $items_others = array();
    foreach ($node->$field_name as $item) {
!     // Skip unplayable items.
!     if (!isset($codecs[$item['filemime']])) continue;
! 
!     // Special treatment for mp4 type due to different capabilities.
!     if ($item['filemime'] == 'video/mp4') {
!       // Check if Video module present and dimensions are assigned
!       if (isset($item['data']['dimensions'])) {
!         list($width,$height) = explode('x',$item['data']['dimensions'],2); // i.e. 560x314
!         foreach ($codecs['video/mp4'] as $resolution) {
!           $item['videotype'] = $resolution['type'];
!           if (($width < $resolution['width']) && ($height < $resolution['height']))
!             break;
!         }
!       } else
!         $item['videotype'] = $codecs['video/mp4'][0]['type']; // dimensions info not exist, assign default
!       $items_mp4[] = $item;
!     } else {
!       $item['videotype'] = $codecs[$item['filemime']];
!       $items_others[] = $item;
!     }
!   }
!   $vars['items'] = array_merge ($items_mp4,$items_others); // mp4 listed first
!   
!   // Video module present, retriving description and poster image from first video
!   if (isset($vars['items'][0]['data'])) {
!     $vars['description'] = $vars['items'][0]['data']['description'];
!     $vars['poster_url'] = file_create_url($vars['items'][0]['data']['video_thumb']);
    }
+   
    $vars['player_id'] = 'videojs-' . $vars['element']['#node']->nid . '-' . str_replace('_', '-', $vars['element']['#field_name']);
+ 
+ /*
+ * TODO: Flash fallback logic  
+   if (module_exists('flowplayer')) {
+     $vars['fallback'] = theme(
+       'flowplayer', 
+        array('clip' => array('url' => $vars['items'][0]['filepath'], 'autoplay' => FALSE)),
+        'vjs-flash-fallback',
+         array('style' => 'width:' . $vars['width'] . 'px; height:' . $vars['height'] .'px;')    
+     );
+   }
+ */
  }
  
  /**
