getid3_id3v1::GenerateID3v1Tag

Advertisement

Syntax Syntax

getid3_id3v1::GenerateID3v1Tag( string $title, string $artist, string $album, string $year, int $genreid, string $comment, int|string $track = '' )

Parameters Parameters

$title

(string) (Required)

$artist

(string) (Required)

$album

(string) (Required)

$year

(string) (Required)

$genreid

(int) (Required)

$comment

(string) (Required)

$track

(int|string) (Optional)

Default value: ''

Return Return

(string)

Source Source

File: wp-includes/ID3/module.tag.id3v1.php

	 * @param string     $year
	 * @param int        $genreid
	 * @param string     $comment
	 * @param int|string $track
	 *
	 * @return string
	 */
	public static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') {
		$ID3v1Tag  = 'TAG';
		$ID3v1Tag .= str_pad(trim(substr($title,  0, 30)), 30, "\x00", STR_PAD_RIGHT);
		$ID3v1Tag .= str_pad(trim(substr($artist, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
		$ID3v1Tag .= str_pad(trim(substr($album,  0, 30)), 30, "\x00", STR_PAD_RIGHT);
		$ID3v1Tag .= str_pad(trim(substr($year,   0,  4)),  4, "\x00", STR_PAD_LEFT);
		if (!empty($track) && ($track > 0) && ($track <= 255)) {
			$ID3v1Tag .= str_pad(trim(substr($comment, 0, 28)), 28, "\x00", STR_PAD_RIGHT);
			$ID3v1Tag .= "\x00";
			if (gettype($track) == 'string') {
				$track = (int) $track;
			}
			$ID3v1Tag .= chr($track);
		} else {
			$ID3v1Tag .= str_pad(trim(substr($comment, 0, 30)), 30, "\x00", STR_PAD_RIGHT);
		}
		if (($genreid < 0) || ($genreid > 147)) {
			$genreid = 255; // 'unknown' genre
		}
		switch (gettype($genreid)) {
			case 'string':
			case 'integer':
				$ID3v1Tag .= chr(intval($genreid));
				break;

Advertisement

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

What are you looking for?