From 38aa2b057a496f96e6bf176da984df074ded418f Mon Sep 17 00:00:00 2001 From: Krzysztof Moch Date: Mon, 5 Aug 2024 11:59:49 +0200 Subject: [PATCH] fix(ios): override source metadata with custom metadata (#4050) * fix(ios): override source metadata with custom metadata * lint code --- examples/basic/ios/Podfile.lock | 10 +++++----- ios/Video/NowPlayingInfoCenterManager.swift | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/examples/basic/ios/Podfile.lock b/examples/basic/ios/Podfile.lock index b3681ae4..7ab84ea5 100644 --- a/examples/basic/ios/Podfile.lock +++ b/examples/basic/ios/Podfile.lock @@ -994,7 +994,7 @@ PODS: - React-Mapbuffer (0.74.3): - glog - React-debug - - react-native-video (6.3.0): + - react-native-video (6.4.3): - DoubleConversion - glog - hermes-engine @@ -1008,7 +1008,7 @@ PODS: - React-featureflags - React-graphics - React-ImageManager - - react-native-video/Video (= 6.3.0) + - react-native-video/Video (= 6.4.3) - React-NativeModulesApple - React-RCTFabric - React-rendererdebug @@ -1038,7 +1038,7 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - react-native-video/Video (6.3.0): + - react-native-video/Video (6.4.3): - DoubleConversion - glog - hermes-engine @@ -1559,7 +1559,7 @@ SPEC CHECKSUMS: React-jsitracing: 1aa5681c353b41573b03e0e480a5adf5fa1c56d8 React-logger: fa92ba4d3a5d39ac450f59be2a3cec7b099f0304 React-Mapbuffer: 70da5955150a58732e9336a0c7e71cd49e909f25 - react-native-video: c44719c9a5261ad54fdad49e6dd0e98439e0e1b3 + react-native-video: 3d5881ee6643a9a87e0e259b742c2d07aee7b27e react-native-video-plugin-sample: d3a93b7ad777cad7fa2c30473de75a2635ce5feb React-nativeconfig: 84806b820491db30175afbf027e99e8415dc63f0 React-NativeModulesApple: 7b79212f8cf496ab554e0b7b09acbd4aa4690260 @@ -1594,4 +1594,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: a73d485df51877001f2b04a5a4379cfa5a3ba8fa -COCOAPODS: 1.15.2 +COCOAPODS: 1.13.0 diff --git a/ios/Video/NowPlayingInfoCenterManager.swift b/ios/Video/NowPlayingInfoCenterManager.swift index 981f8ab5..b5d7b997 100644 --- a/ios/Video/NowPlayingInfoCenterManager.swift +++ b/ios/Video/NowPlayingInfoCenterManager.swift @@ -192,7 +192,12 @@ class NowPlayingInfoCenterManager { } // commonMetadata is metadata from asset, externalMetadata is custom metadata set by user - let metadata = currentItem.asset.commonMetadata + currentItem.externalMetadata + // externalMetadata should override commonMetadata to allow override metadata from source + let metadata = { + let common = Dictionary(uniqueKeysWithValues: currentItem.asset.commonMetadata.map { ($0.identifier, $0) }) + let external = Dictionary(uniqueKeysWithValues: currentItem.externalMetadata.map { ($0.identifier, $0) }) + return Array((common.merging(external) { _, new in new }).values) + }() let titleItem = AVMetadataItem.metadataItems(from: metadata, filteredByIdentifier: .commonIdentifierTitle).first?.stringValue ?? ""