1. Go to this page and download the library: Download pyrex-fwi/id3 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pyrex-fwi / id3 example snippets
class MyClass
{
public function readId3()
{
$mp3OrFlacFile = '/path/to/file';
/** @var Sapar\Id3\Metadata\Id3MetadataInterface */
$id3Metadata = new Sapar\Metadata\Id3Metadata($mp3OrFlacFile);
/** @var Sapar\Wrapper\BinWrapper\BinWrapperInterface */
$mediaInfoWrapper = new Sapar\Wrapper\BinWrapper\MediainfoWrapper();
$mediaInfoWrapper->setBin('/usr/local/bin/mediainfo');
if ($mediaInfoWrapper->read($metaDataFile)) {
$metaDataFile->getTitle();
$metaDataFile->getArtist();
$metaDataFile->getAlbum();
$metaDataFile->getGenre();
$metaDataFile->getYear();
$metaDataFile->getBpm();
$metaDataFile->getTimeDuration();
}
}
}
class MyClass
{
public function writeId3()
{
$mp3OrFlacFile = '/path/to/file';
/** @var Sapar\Id3\Metadata\Id3MetadataInterface */
$id3Metadata = new Sapar\Metadata\Id3Metadata($mp3OrFlacFile);
$id3Metadata->setAlbum('album');
$id3Metadata->setTitle('title');
$id3Metadata->setGenre('genre');
$id3Metadata->setYear(2016);
$id3Metadata->setComment('comment');
$id3Metadata->setBpm(120);
/** @var Sapar\Wrapper\BinWrapper\BinWrapperInterface */
$id3v2wrapper = new Sapar\Wrapper\BinWrapper\Id3v2Wrapper();
$id3v2wrapper->setBin('/usr/local/bin/id3v2');
if ($mediaInfoReader->write($metaDataFile)) {
//it's done!
}
}
class MyClass
{
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.