Home > Backend Development > PHP Tutorial > How to get audio file duration in PHP

How to get audio file duration in PHP

墨辰丷
Release: 2023-03-27 17:32:02
Original
6790 people have browsed it

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']; //这个获得的便是音频文件的时长
Copy after login

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:

PHPUsing overlong (oversized) number operations to prevent numbers from being displayed in scientific notation Method_php tips

PHPExtracting the root domain name through URL_php tips

##PHPMethods to calculate the sum and product of values ​​in an array (array_sum and array_product functions)_php skills

##

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template