chore: fix iOS build for custom metadata

This commit is contained in:
Konstantin Späth 2023-08-15 18:21:45 +02:00
parent 6cbc7cdc89
commit ae17aa747e
2 changed files with 5 additions and 5 deletions

View File

@ -5,7 +5,6 @@ import Photos
/*!
* Collection of pure functions
*/
@available(tvOS 10.0, *)
enum RCTVideoUtils {
/*!

View File

@ -390,13 +390,15 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
mapping[.commonIdentifierDescription] = description
}
if !mapping.isEmpty {
if #available(iOS 12.2, *), !mapping.isEmpty {
playerItem.externalMetadata = createMetadataItems(for: mapping)
}
#if os(tvOS)
if let chapters = _chapters {
playerItem.navigationMarkerGroups = makeNavigationMarkerGroups(chapters)
}
#endif
return playerItem
}
@ -405,6 +407,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
return mapping.compactMap { createMetadataItem(for:$0, value:$1) }
}
#if os(tvOS)
private func makeNavigationMarkerGroups(_ chapters: [Chapter]) -> [AVNavigationMarkersGroup] {
var metadataGroups = [AVTimedMetadataGroup]()
@ -438,13 +441,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
{
let imageItem = createMetadataItem(for: .commonIdentifierArtwork, value: pngData)
metadata.append(imageItem)
print("Image added")
} else {
print("Something went wrong")
}
return AVTimedMetadataGroup(items: metadata, timeRange: timeRange)
}
#endif
private func createMetadataItem(for identifier: AVMetadataIdentifier,
value: Any) -> AVMetadataItem {