This fork of GetId3 library updates to PSR-2 / PSR-4 CS, adds namespaces and makes it installable by composer.


Keywords
metadata, tags, getid3
License
GPL-2.0+

Documentation

GetId3

Build Status

This release of GetId3 library updates to PSR-0 CS and makes it Symfony2 installable by deps or composer mechanisms.

License

For license info please read Resources/doc/license.txt

For commercial license read Resources/doc/license.commercial.txt

Installation

(You can choose deps or composer install mechanisms)

deps

Step 1: Download GetId3

Add following lines to your deps file:

[GetId3]
    git=https://github.com/phansys/GetId3.git
    target=/phansys/getid3/GetId3

Now, run the vendors script to download the library:

$ php bin/vendors install
Step 2: Configure the Autoloader

Add the GetId3 namespace to your autoloader:

<?php
// app/autoload.php

$loader->registerPrefixes(array(
    // ...
        'GetId3_' => __DIR__.'/../vendor/phansys/getid3/GetId3',
        ));

composer

Step 1: Edit composer.json

Add following lines to your composer.json "require" definitions:

"phansys/getid3": "master"
Step 2: Run composer

Now, run the composer script to download the library:

$ php composer.phar install

Quick use example reading audio properties

<?php
namespace My\Project;

use \GetId3_GetId3 as GetId3;

class MyClass
{
    // ...
    private function MyMethod()
    {
        $getId3 = new GetId3();
        $getId3->option_md5_data        = true;
        $getId3->option_md5_data_source = true;
        $getId3->encoding               = 'UTF-8';      
        $mp3File = '/path/to/my/mp3file.mp3';   
        $audio = $getId3->analyze($mp3File);    
        if (isset($audio['error'])) 
        {
            throw new \RuntimeException('Error at reading audio properties with GetId3 : ' . $mp3File);
        }           
        $this->setLength(isset($audio['playtime_seconds']) ? $audio['playtime_seconds'] : '');
        // var_dump($audio);
    }
}