From ae17aa747e01368c042a344912dc52ac912009fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Spa=CC=88th?= Date: Tue, 15 Aug 2023 18:21:45 +0200 Subject: [PATCH] chore: fix iOS build for custom metadata --- ios/Video/Features/RCTVideoUtils.swift | 1 - ios/Video/RCTVideo.swift | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ios/Video/Features/RCTVideoUtils.swift b/ios/Video/Features/RCTVideoUtils.swift index c3c37647..9916db37 100644 --- a/ios/Video/Features/RCTVideoUtils.swift +++ b/ios/Video/Features/RCTVideoUtils.swift @@ -5,7 +5,6 @@ import Photos /*! * Collection of pure functions */ -@available(tvOS 10.0, *) enum RCTVideoUtils { /*! diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 369ef64a..6ea8cf89 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -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 {