video_format_done

Check that a VideoPress video format has finished processing.

Description

video_format_done( (stdClass) $info, (string) $format ); 

This uses the info object, because that is what the WPCOM endpoint uses, however we don't have a complete info object in the same way WPCOM does, so we pull the meta information out of the post options instead.

Note: This mimics the WPCOM function of the same name and helps the media API endpoint add all needed VideoPress data.

Parameters (2)

0. $info (stdClass)
The info.
1. $format (string)
The format.

Usage

  1. if ( !function_exists( 'video_format_done' ) ) { 
  2. require_once '/modules/videopress/utility-functions.php'; 
  3.  
  4. // The info. 
  5. $info = null; 
  6.  
  7. // The format. 
  8. $format = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = video_format_done($info, $format); 
  12.  

Defined (1)

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

/modules/videopress/utility-functions.php  
  1. function video_format_done( $info, $format ) { 
  2.  
  3. // Avoids notice when a non-videopress item is found. 
  4. if ( ! is_object( $info ) ) { 
  5. return false; 
  6.  
  7. $post_id = $info->post_id; 
  8.  
  9. if ( get_post_mime_type( $post_id ) !== 'video/videopress' ) { 
  10. return false; 
  11.  
  12. $post = get_post( $post_id ); 
  13.  
  14. if ( is_wp_error( $post ) ) { 
  15. return false; 
  16.  
  17. $meta = wp_get_attachment_metadata( $post->ID ); 
  18.  
  19. switch ( $format ) { 
  20. case 'fmt_hd': 
  21. return isset( $meta['videopress']['files']['hd']['mp4'] ); 
  22. break; 
  23.  
  24. case 'fmt_dvd': 
  25. return isset( $meta['videopress']['files']['dvd']['mp4'] ); 
  26. break; 
  27.  
  28. case 'fmt_std': 
  29. return isset( $meta['videopress']['files']['std']['mp4'] ); 
  30. break; 
  31.  
  32. case 'fmt_ogg': 
  33. return isset( $meta['videopress']['files']['std']['ogg'] ); 
  34. break; 
  35.  
  36. return false;