/** * Add the keys title, artist, album, comment, year, track and genre * to the attributes collection */ protected function addId3InformationToAttributes() { try { $id3 = new \Zend_Media_Id3v1($this->fullPathToFileOnDisk); $this->attributes['title'] = $id3->getTitle(); $this->attributes['artist'] = $id3->getArtist(); $this->attributes['album'] = $id3->getAlbum(); $this->attributes['comment'] = $id3->getComment(); $this->attributes['year'] = $id3->getYear(); $this->attributes['track'] = $id3->getTrack(); $this->attributes['genre'] = $id3->getGenre(); } catch (\Zend_Media_Id3_Exception $e) { $this->attributes['errors'][] = 'Could not read ID3v1 tags ' . $e->getMessage(); } try { $id3 = new \Zend_Media_Id3v2($this->fullPathToFileOnDisk); $this->attributes['title'] = $id3->tit2->text; } catch (\Zend_Media_Id3_Exception $e) { $this->attributes['errors'][] = 'Could not read ID3v1 tags ' . $e->getMessage(); } }
function testTagCreateVersion10() { $id3 = new Zend_Media_Id3v1(); $id3->title = 'Title 4'; $this->assertEquals('Title 4', $id3->title); $id3->artist = 'Artist 4'; $this->assertEquals('Artist 4', $id3->artist); $id3->album = 'Album 4'; $this->assertEquals('Album 4', $id3->album); $id3->year = '2020'; $this->assertEquals('2020', $id3->year); $id3->comment = 'A comment field with 30 chars.'; $this->assertEquals('A comment field with 30 chars.', $id3->comment); $id3->genre = array_search('Classical', Zend_Media_Id3v1::$genres); $this->assertEquals('Classical', $id3->genre); $id3->write('id3v1.tag'); }