rtmedia_duration

Get duration for media.

Description

(array|bool|mixed|null|string|void) rtmedia_duration( (bool) $id = false ); 

Returns (array|bool|mixed|null|string|void)

Parameters (1)

0. $id — Optional. (bool) => false
The id.

Usage

  1. if ( !function_exists( 'rtmedia_duration' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'rtmedia-for-wordpress-buddypress-and-bbpress/app/main/controllers/template/rtmedia-functions.php'; 
  3.  
  4. // The id. 
  5. $id = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = rtmedia_duration($id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/app/main/controllers/template/rtmedia-functions.php  
  1. function rtmedia_duration( $id = false ) { 
  2.  
  3. global $rtmedia_backbone; 
  4.  
  5. if ( $rtmedia_backbone['backbone'] ) { 
  6. echo '<%= duration %>'; 
  7.  
  8. return; 
  9.  
  10. if ( $id ) { 
  11. $model = new RTMediaModel(); 
  12. $media = $model->get_media( array( 
  13. 'id' => $id,  
  14. ), false, false ); 
  15.  
  16. if ( isset( $media[0] ) ) { 
  17. $media_object = $media[0]; 
  18. } else { 
  19. return false; 
  20. } else { 
  21. global $rtmedia_media; 
  22.  
  23. $media_object = $rtmedia_media; 
  24.  
  25. $duration = ''; 
  26.  
  27. if ( ( 'video' === $media_object->media_type ) || ( 'music' === $media_object->media_type ) ) { 
  28. $media_time = get_rtmedia_meta( $media_object->id, 'duration_time' ); 
  29.  
  30. if ( false === $media_time || empty( $media_time ) ) { 
  31. $filepath = get_attached_file( $media_object->media_id ); 
  32. $media_tags = new RTMediaTags( $filepath ); 
  33. $duration = $media_tags->duration; 
  34.  
  35. add_rtmedia_meta( $media_object->id, 'duration_time', $duration ); 
  36. } else { 
  37. $duration = $media_time; 
  38.  
  39. $duration = str_replace( '-:--', '', $duration ); 
  40. $duration = '<span class="rtmedia_time" >' . esc_attr( $duration ) . '</span>'; 
  41.  
  42. return $duration; 
  43.