Support » Fixing WordPress » How to get audio file metadata, namely, length

Viewing 1 replies (of 1 total)
  • I figured it out and I’m posting here so others may benefit. I do not guarantee that this is an elegant solution, but it does work.

    global $post;
    $audio_media = get_attached_media( 'audio', $post->ID );
    $audio_media_reset = reset($audio_media);
    $myvals = get_post_meta($audio_media_reset->ID);
    $myvals2 = unserialize($myvals['_wp_attachment_metadata'][0]);
    $audio_length = $myvals2[length];

    In place of “length” any other criteria can be used, like “filesize” or “length_formatted”, etc.

Viewing 1 replies (of 1 total)
  • The topic ‘How to get audio file metadata, namely, length’ is closed to new replies.