You are here

function _video_playtime_seconds in Video 6.2

Handler to to render the correct playtime for the video in a field

1 call to _video_playtime_seconds()
video_views_handler_field_playtime_seconds::render in views/video_views_handler_field_playtime_seconds.inc
Render field output to the browser.

File

views/video_views_handler_field_playtime_seconds.inc, line 52

Code

function _video_playtime_seconds($values, $type) {
  if ($values->node_type && $values->node_type != 'video') {
    return NULL;
  }
  switch ($type) {
    case 'hms':
      $hms = _video_sec2hms($values->video_playtime_seconds);

      // Pad the minutes / seconds with a leading "0", if
      // necessary
      if ($hms['hours'] > 0) {
        $hms['minutes'] = str_pad($hms['minutes'], 2, '0', STR_PAD_LEFT);
      }
      $hms['seconds'] = str_pad($hms['seconds'], 2, '0', STR_PAD_LEFT);
      $out = '';
      if ($hms['hours'] > 0) {
        $out .= $hms['hours'] . ":";
      }
      $out .= $hms['minutes'] . ":" . $hms['seconds'];
      return $out;
    case 'sec':
    default:
      return $values->video_playtime_seconds;
  }
}