PHP programming method for obtaining the length of audio files [Based on the getid3 class ],
This example describes how to obtain the length of an audio file through PHP programming. We will share this with you for your reference. The details are as follows:
Problem:
When I added the Forum feature yesterday, I needed to know how long the audio was to be displayed on the mobile terminal;
The specific solution is as follows:
The first step is to add an audio file retention field to the database;
Then I found the getID3 class on the Internet to get the duration of the audio file and introduce it to the project;
Next, call this class in the Mobile upload audio file interface. The specific method is as follows:
$ GetID3 = new getID3 (); // instantiate class $ ThisFileInfo = $ getID3-> analyze ($ path); // analyze the file, $ path is the address of the audio file $ fileduration = $ ThisFileInfo ['playtime _ seconds ']; // The duration of the audio file is obtained.
And store the corresponding data into the database;
Then, when the Mobile End needs a data list, the audio duration will be returned at the same time.
Appendix:GetID3 click hereDownload from this site.