I'm finding it really difficult to display the duration of a video in the node.tpl.php file (or node preprocess). I can access it in views, and I can see it in the video_queue sql table, but I can't see it in the node or content arrays. There also doesn't seem to be a function in the video module that gets metadata easily. I'm fine to write my own query to fetch this, but I'm thinking there's got to be a better way.
Thanks.

Comments

Jorrit’s picture

At this moment there is no better way then writing your own query. I plan to add this info to the field information in one of the next releases.

burgs’s picture

Thanks Jorrit,

For anyone else that needs this in the node.tpl file, I've used the following code inside the node preprocess function in template.php in my theme. Any style/performance suggestions are always welcome.

foreach($vars['node']->field_video[LANGUAGE_NONE] as $key => $file) {
     $vars['node']->field_video[LANGUAGE_NONE][$key]['duration'] = db_select('video_queue', 'v')
      ->fields('v', array('duration'))
      ->condition('fid', $file['fid'],'=')
      ->execute()
      ->fetchField();
   }
burgs’s picture

Status: Active » Postponed

Updating this to postponed.

Jorrit’s picture

If you expect to have many videos, I suggest to use an IN query to fetch all durations in one go. Otherwise, the code is fine.

brycefisherfleig’s picture

Issue summary: View changes
Status: Postponed » Postponed (maintainer needs more info)

Has a patch for this been committed to a more recent version of this module? 7.x-2.6 is about 4 minor versions behind at this. I'd love to incorporate this feature, but I'm not sure if it's already in the module.