Skip to content

Commit

Permalink
Avoid emitting empty metadata.
Browse files Browse the repository at this point in the history
Using rntp, I was seeing empty values for Event.MetadataTimedReceived like: `{ "raw": [] }`. This commit filters out these empty metadata groups.
  • Loading branch information
puckey committed Oct 3, 2023
1 parent 77fb2b8 commit 77fc4d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion SwiftAudioEx/Classes/Observer/AVPlayerItemObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class AVPlayerItemObserver: NSObject {

extension AVPlayerItemObserver: AVPlayerItemMetadataOutputPushDelegate {
func metadataOutput(_ output: AVPlayerItemMetadataOutput, didOutputTimedMetadataGroups groups: [AVTimedMetadataGroup], from track: AVPlayerItemTrack?) {
delegate?.item(didReceiveTimedMetadata: groups)
let groupsWithMetadata = groups.filter { !$0.items.isEmpty }
if !groupsWithMetadata.isEmpty {
delegate?.item(didReceiveTimedMetadata: groupsWithMetadata)
}
}
}

0 comments on commit 77fc4d4

Please sign in to comment.