Giter VIP home page Giter VIP logo

zend-mp3's Introduction

PHP Reader (Zend Mp3)

The PHP Reader is a library written in PHP to read and write media files and their information headers in an object-oriented manner. Currently supported formats are ASF (Windows Media Player files, i.e. WMA, WMV, etc), ID3, including both ID3v1 and ID3v2 (MPEG files, i.e. MP3), MPEG Audio Bit Stream (i.e. ABS, MP1, MP2, MP3), MPEG Program Stream (MPEG movies, and DVD and HD DVD video discs, i.e. MPG, MPEG, VOB, EVO), and ISO Base Media File Format (eg QuickTime, MPEG-4 and iTunes AAC files, i.e. QT, MOV, MP4, M4A, M4B, M4P, M4V, etc).

The library was written by Sven Vollbehr and is hosted originally at Google Code. This Github fork just adds support for the PSR-0 autoloading standard for Composer.

Installation

Install PHP Reader with composer via

composer require debach/zend-mp3:dev-master
composer install

How to use PHP Reader

PHP reader has a nice documentation both on its website and in the code. What follows are a couple of examples to give you a quick start. PHP reader can do a lot more that what is covered here.

Reading the duration of an MP3 file

To retrieve the estimated duration in seconds from an MP3 file, proceed as follows:

$abs    = new Zend_Media_Mpeg_Abs('file.mp3');
$length = $abs->getLengthEstimate();

You can get the exact duration with $abs->getLength(), but it requires to read every frame of the MP3 file. Usually, the estimated duration is already very accurate and much faster.

Reading ID3 tags

Use the Zend_Media_Id3v2 class to read or write ID3 information (official documentation):

$id3   = new Zend_Media_Id3v2('file.mp3');

$frame = $id3->getFramesByIdentifier('TIT2'); // for song title; or TALB for album title; ..
$title = $frame[0]->getText();

$frame = $id3->getFramesByIdentifier('TALB');
$album = $frame[0]->getText();

zend-mp3's People

Contributors

debach avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.