PHP Classes

File: getID3/demos/demo.simple.write.php

Recommend this page to a friend!
  Classes of Ali YILMAZ  >  PHP Media File Info Library  >  getID3/demos/demo.simple.write.php  >  Download  
File: getID3/demos/demo.simple.write.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Media File Info Library
Retrieve the details from a video or audio file
Author: By
Last change:
Date: 7 months ago
Size: 2,754 bytes


Class file image Download
/// getID3() by James Heinrich <> //
// available at //
// or //
// or //
// //
// /demo/demo.simple.write.php - part of getID3() //
// Sample script showing basic syntax for writing tags //
// see readme.txt for more details //
// ///

die('For security reasons, this demo has been disabled. It can be enabled by removing line '.__LINE__.' in demos/'.basename(__FILE__));

$TextEncoding = 'UTF-8';

// Initialize getID3 engine
$getID3 = new getID3;

// Initialize getID3 tag-writing module
$tagwriter = new getid3_writetags;
//$tagwriter->filename = '/path/to/file.mp3';
$tagwriter->filename = 'c:/file.mp3';

//$tagwriter->tagformats = array('id3v1', 'id3v2.3');
$tagwriter->tagformats = array('id3v2.3');

// set various options (optional)
$tagwriter->overwrite_tags = true; // if true will erase existing tag data and write only passed data; if false will merge passed data with existing tag data (experimental)
$tagwriter->remove_other_tags = false; // if true removes other tag formats (e.g. ID3v1, ID3v2, APE, Lyrics3, etc) that may be present in the file and only write the specified tag format(s). If false leaves any unspecified tag formats as-is.
$tagwriter->tag_encoding = $TextEncoding;
$tagwriter->remove_other_tags = true;

// populate data array
$TagData = array(
'title' => array('My Song'),
'artist' => array('The Artist'),
'album' => array('Greatest Hits'),
'year' => array('2004'),
'genre' => array('Rock'),
'comment' => array('excellent!'),
'track_number' => array('04/16'),
'popularimeter' => array('email'=>'', 'rating'=>128, 'data'=>0),
'unique_file_identifier' => array('ownerid'=>'', 'data'=>md5(time())),
$tagwriter->tag_data = $TagData;

// write tags
if ($tagwriter->WriteTags()) {
'Successfully wrote tags<br>';
    if (!empty(
$tagwriter->warnings)) {
'There were some warnings:<br>'.implode('<br><br>', $tagwriter->warnings);
} else {
'Failed to write tags!<br>'.implode('<br><br>', $tagwriter->errors);

For more information send a message to info at phpclasses dot org.