PHP programming method for obtaining the length of audio files [Based on the getid3 class ],

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.