This article mainly introduces the method of obtaining the duration of audio files in PHP. It implements the function of operating audio files by introducing the third-party getid3 class. Friends in need can refer to the following
Question:
When the forum function was added yesterday, the mobile terminal needed to know how long the audio file was;
The specific solution is as follows:
The first thing is to add a field to save the duration of the audio file in the database;
Then I found the getID3 class on the Internet to get the duration of the audio file, and introduced it into the project;
Secondly, call this class in the interface for uploading audio files on the mobile terminal. The specific writing method is as follows:
$getID3 = new getID3(); //实例化类 $ThisFileInfo = $getID3->analyze($path); //分析文件,$path为音频文件的地址 $fileduration=$ThisFileInfo['playtime_seconds']; //这个获得的便是音频文件的时长
and store the corresponding data in the database. Medium;
Then when the mobile terminal needs the data list, just return the audio duration to the past at the same time
The above is the entire content of this article, I hope it will be helpful to everyone's learning.
Related recommendations:
PHPExtracting the root domain name through URL_php tips
##
The above is the detailed content of How to get audio file duration in PHP. For more information, please follow other related articles on the PHP Chinese website!