简体   繁体   中英

How to read mp3 metadata in php

My problem is simple, i need to read/write metadada from/into a mp3 file from a php script, but I can't find any reliable sorce of information. I'm over a week searching for answers but no real solution.

To explain my self a little better, I need to upload a mp3 file that has metadata attached, read this data and store in my database. After thar initial load, any new mp3 files that will be sent, will not have any metadata, and my system must insert some data into it, like track name, author, and a few others.

I can't find the a working solution for this read/write metadata anywhere, just some offline docs and outdated information.

If your path to your mp3 file is for example "/var/lib/my_mixtape.mp3", then give the code below a try:

$mp3FileLocation = "/var/lib/my_mixtape.mp3";
$metaData = id3_get_tag($mp3FileLocation);

// Fetch the necessary information from the $meta

For further reference, checkout the PHP documentation on the id3 function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM