ID3TagEditor
public class ID3TagEditor
A class to edit the ID3 tag of an mp3 file.
-
Init the ID3TagEditor.
Declaration
Swift
public init()
-
Read the ID3 tag contained in the mp3 file.
Throws
Could throw
InvalidFileFormat
if an mp3 file doesn’t exists at the specified path. Could throwCorruptedFile
if the file is corrupted.Declaration
Swift
public func read(from path: String) throws -> ID3Tag?
Parameters
path
path of the mp3 file to be parsed.
Return Value
an ID3 tag or nil, if a tag doesn’t exists in the file.
-
Read the ID3 tag contained in the mp3 file passed as
Data
.Throws
Could throw
CorruptedFile
if the file is corrupted.Declaration
Swift
public func read(mp3: Data) throws -> ID3Tag?
Parameters
mp3
mp3 file opened as Data.
Return Value
an ID3 tag or nil, if a tag doesn’t exists in the file.
-
Writes the mp3 to a new file or overwrite it with the new ID3 tag.
Throws
Could throw
TagTooBig
(tag size > 256 MB) orInvalidTagData
(no data set to be written in the ID3 tag).Declaration
Swift
public func write(tag: ID3Tag, to path: String, andSaveTo newPath: String? = nil) throws
Parameters
tag
the ID3 tag to be written in the mp3 file.
path
path of the mp3 file to which the id3 tag will be added.
newPath
path where the mp3 file with the new tag will be written. If nil, the mp3 file will be overwritten. If nothing is passed, the file will be overwritten at its current location.
-
Write the ID3 tag passed as parameter to the mp3 file passed as
Data
.Throws
Could throw
TagTooBig
(tag size > 256 MB) orInvalidTagData
(no data set to be written in the ID3 tag).Declaration
Swift
public func write(tag: ID3Tag, mp3: Data) throws -> Data
Parameters
tag
the ID3 tag to be written in the mp3.
mp3
the mp3 on which we want to write the new tag.
Return Value
a new
Data
object that contains the mp3 data with the new tag.