Skip to content

Move metadata management to the VLCMediaMetaData class.

Hank Anderson requested to merge Sumou/VLCKit:refactor-VLCMetaInformation into master

Move metadata management to the VLCMediaMetaData class.

This eliminates the need for casting when retrieving metadata values.

let media: VLCMedia = ...

/************ before ************/
// Get metadata values
let title: String? = media.metadata(forKey: VLCMetaInformationTitle)
let title: String? = media.metaDictionary[VLCMetaInformationTitle] as? String

let trackNumber: UInt32 = media.metadata(forKey: VLCMetaInformationTrackNumber) as? UInt32 ?? .zero
let trackNumber: UInt32 = media.metaDictionary[VLCMetaInformationTrackNumber] as? UInt32 ?? .zero

// Save metadata values
media.setMetadata("new title", forKey: VLCMetaInformationTitle)
let newTrackNumber = 10
media.setMetadata("\(newTrackNumber)", forKey: VLCMetaInformationTrackNumber)

/************ after ************/
// Get metadata values
let metaData: VLCMediaMetaData = media.metaData
let title: String? = metaData.title
let trackNumber: UInt32 = metaData.trackNumber
// Save metadata values
metaData.title = "new title"
metaData.trackNumber = 10

Probably related #416 (closed)

Edited by Hank Anderson

Merge request reports