I had a fully working app on the App Store where the player would display Metadata to the user listening to the stream.
However, it seems recently that AVPlayerItemMetadataOutput no longer triggers at all but the audio still plays.
asset = AVAsset(url: stationurl!)
playerItem = AVPlayerItem(asset: asset)
let metadataOutput = AVPlayerItemMetadataOutput(identifiers: nil)
metadataOutput.setDelegate(self, queue: DispatchQueue.main)
playerItem.add(metadataOutput)
player = AVPlayer(playerItem: playerItem)
And the delegate
func metadataOutput(_ output: AVPlayerItemMetadataOutput, didOutputTimedMetadataGroups groups: [AVTimedMetadataGroup], from track: AVPlayerItemTrack?) {
if let item = groups.first?.items.first {
item.value(forKeyPath: "value")
let Song = (item.value(forKeyPath: "value")!)
MetaText = "\(Song)"
} else {
MetaText = "MetaData Error" // No Metadata or Could not read
}
}
Could anyone help me or explain to me why this is happening?