Using wp_read_audio_metadata
-
I use XYZ Snippets to create most of my website pages so all of my wordpress development is in PHP. My current problem is not being able to access the audio metadata which is stored in a wp_postmeta record referenced by a wp_post record . I’ve tried using wp_read_audio_meta_data passing the audio file URL, (stored in wp_post as guid), but I get an error. Here`s the code:
global $wpdb ;
$mime_type = "audio/mpeg";
$all_mp3s = $wpdb->get_results ( "SELECT * FROM wp_posts WHERE post_mime_type = '$mime_type' " ) ;
foreach ( $all_mp3s as $all_mp3 )
{
$cnt = $cnt + 1 ;
$post_id = $all_mp3->ID ;
$mp3_url = $all_mp3->guid ;
$mp3_title = $all_mp3->post_title ;
$audio_meta = wp_read_audio_metadata($mp3_url) ;
if(!audio_meta)
{
echo('Call fails for '.$mp3_url.'
');
}
}I suspect the issue is the value of the $mp3_url field and that I need to adjust it somehow. An example of the stored value is : “https://mywebsite.com/wp-content/uploads/2025/01/Back-In-the-USA.mp3.
On a related note I tried accessing the wp_postmeta directly but the meta_value in the wp_postmeta record is longtext and the php strpos function won’t help me find the tag I’m looking for.
Tom
- You must be logged in to reply to this topic.