react-native-video
Advanced tools
| // | ||
| // AVMetadataItem+make.swift | ||
| // ReactNativeVideo | ||
| // | ||
| // Created by Kamil Moskała on 06/02/2026. | ||
| // | ||
| import AVFoundation | ||
| extension AVMetadataItem { | ||
| static func make(identifier: AVMetadataIdentifier, value: NSObjectProtocol & NSCopying) -> AVMutableMetadataItem { | ||
| let item = AVMutableMetadataItem() | ||
| item.identifier = identifier | ||
| item.value = value | ||
| item.extendedLanguageTag = "und" | ||
| return item | ||
| } | ||
| } |
@@ -117,3 +117,3 @@ import Foundation | ||
| forInterval: CMTime(value: 1, timescale: 4), | ||
| queue: .global(), | ||
| queue: .main, | ||
| using: { [weak self] _ in | ||
@@ -222,4 +222,3 @@ self?.updateNowPlayingInfo() | ||
| public func updateNowPlayingInfo() { | ||
| guard let player = currentPlayer, let currentItem = player.currentItem | ||
| else { | ||
| guard let player = currentPlayer else { | ||
| invalidateCommandTargets() | ||
@@ -230,2 +229,6 @@ MPNowPlayingInfoCenter.default().nowPlayingInfo = [:] | ||
| guard let currentItem = player.currentItem else { | ||
| return | ||
| } | ||
| // commonMetadata is metadata from asset, externalMetadata is custom metadata set by user | ||
@@ -232,0 +235,0 @@ // externalMetadata should override commonMetadata to allow override metadata from source |
@@ -165,3 +165,3 @@ // | ||
| private func invalidatePlayerItemObservers() { | ||
| func invalidatePlayerItemObservers() { | ||
| // Remove NotificationCenter observers | ||
@@ -168,0 +168,0 @@ if let playbackEndedObserver = playbackEndedObserver { |
@@ -209,6 +209,5 @@ // | ||
| NowPlayingInfoCenterManager.shared.removePlayer(player: player) | ||
| try? _eventEmitter?.clearAllListeners() | ||
| self.player.replaceCurrentItem(with: nil) | ||
| self.playerItem = nil | ||
@@ -221,3 +220,7 @@ | ||
| // Clear player observer | ||
| playerObserver?.invalidatePlayerItemObservers() | ||
| playerObserver?.invalidatePlayerObservers() | ||
| self.playerObserver = nil | ||
| self.player.replaceCurrentItem(with: nil) | ||
| status = .idle | ||
@@ -393,2 +396,40 @@ | ||
| if let metadata = source.config.metadata { | ||
| let title = metadata.title | ||
| let artist = metadata.artist | ||
| let imageUri = metadata.imageUri | ||
| DispatchQueue.main.async { [weak playerItem] in | ||
| guard let playerItem else { return } | ||
| var items: [AVMetadataItem] = [] | ||
| if let title { | ||
| items.append(.make(identifier: .commonIdentifierTitle, value: title as NSString)) | ||
| } | ||
| if let artist { | ||
| items.append(.make(identifier: .commonIdentifierArtist, value: artist as NSString)) | ||
| } | ||
| if !items.isEmpty { | ||
| playerItem.externalMetadata = items | ||
| } | ||
| } | ||
| // Load artwork in background to not block player initialization | ||
| if let imageUri, let imageUrl = URL(string: imageUri) { | ||
| Task { [weak playerItem] in | ||
| guard let (data, _) = try? await URLSession.shared.data(from: imageUrl) else { | ||
| print("[RNV] Failed to load artwork from: \(imageUrl)") | ||
| return | ||
| } | ||
| DispatchQueue.main.async { | ||
| guard let playerItem else { return } | ||
| playerItem.externalMetadata = playerItem.externalMetadata + [.make(identifier: .commonIdentifierArtwork, value: data as NSData)] | ||
| NowPlayingInfoCenterManager.shared.updateNowPlayingInfo() | ||
| } | ||
| } | ||
| } else if let imageUri { | ||
| print("[RNV] Invalid imageUri for artwork: \(imageUri)") | ||
| } | ||
| } | ||
| return playerItem | ||
@@ -395,0 +436,0 @@ } |
+1
-1
| { | ||
| "name": "react-native-video", | ||
| "version": "7.0.0-beta.5", | ||
| "version": "7.0.0-beta.6", | ||
| "description": "<Video /> Component for React Native", | ||
@@ -5,0 +5,0 @@ "source": "./src/index.tsx", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1506365
0.13%686
0.15%