file_metadata !== null) { $this->duration = (float) $this->file_metadata['playtime_seconds']; $this->header_size = (int) $this->file_metadata['avdataoffset']; } } public function setFile(File $file): self { parent::setFile($file); $getID3 = new GetID3(); $audioMetadata = $getID3->analyze($file->getRealPath()); $this->attributes['file_mimetype'] = $audioMetadata['mime_type']; $this->attributes['file_size'] = $audioMetadata['filesize']; $this->attributes['description'] = @$audioMetadata['id3v2']['comments']['comment'][0]; $this->attributes['file_metadata'] = json_encode([ 'playtime_seconds' => $audioMetadata['playtime_seconds'], 'avdataoffset' => $audioMetadata['avdataoffset'], ], JSON_INVALID_UTF8_SUBSTITUTE); return $this; } }