chore(ios): remove some warnings (#4159)
This commit is contained in:
parent
2c1fc964bf
commit
7118ba6819
@ -48,7 +48,7 @@ class VideoPluginSample: NSObject, RNVPlugin {
|
||||
* custom functions to be able to track AVPlayer state change
|
||||
*/
|
||||
func handlePlaybackRateChange(player: AVPlayer, change: NSKeyValueObservedChange<Float>) {
|
||||
NSLog("plugin: handlePlaybackRateChange \(change.oldValue)")
|
||||
NSLog("plugin: handlePlaybackRateChange \(String(describing: change.oldValue))")
|
||||
}
|
||||
|
||||
func handlePlayerItemStatusChange(playerItem: AVPlayerItem, change _: NSKeyValueObservedChange<AVPlayerItem.Status>) {
|
||||
@ -56,7 +56,7 @@ class VideoPluginSample: NSObject, RNVPlugin {
|
||||
}
|
||||
|
||||
func handleCurrentItemChange(player: AVPlayer, change: NSKeyValueObservedChange<AVPlayerItem?>) {
|
||||
NSLog("plugin: handleCurrentItemChange \(player.currentItem)")
|
||||
NSLog("plugin: handleCurrentItemChange \(String(describing: player.currentItem))")
|
||||
guard let playerItem = player.currentItem else {
|
||||
_playerItemStatusObserver?.invalidate()
|
||||
return
|
||||
|
@ -234,11 +234,10 @@ class RCTPlayerObserver: NSObject, AVPlayerItemMetadataOutputPushDelegate, AVPla
|
||||
|
||||
/* Cancels the previously registered time observer. */
|
||||
func removePlayerTimeObserver() {
|
||||
if _timeObserver != nil {
|
||||
player?.removeTimeObserver(_timeObserver)
|
||||
guard let timeObserver = _timeObserver else { return }
|
||||
player?.removeTimeObserver(timeObserver)
|
||||
_timeObserver = nil
|
||||
}
|
||||
}
|
||||
|
||||
func addTimeObserverIfNotSet() {
|
||||
if _timeObserver == nil {
|
||||
|
@ -49,7 +49,7 @@ class RCTResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelegate, URLSes
|
||||
func setLicenseResult(_ license: String!, _ licenseUrl: String!) {
|
||||
// Check if the loading request exists in _loadingRequests based on licenseUrl
|
||||
guard let loadingRequest = _loadingRequests[licenseUrl] else {
|
||||
setLicenseResultError("Loading request for licenseUrl \(licenseUrl) not found", licenseUrl)
|
||||
setLicenseResultError("Loading request for licenseUrl \(String(describing: licenseUrl)) not found", licenseUrl)
|
||||
return
|
||||
}
|
||||
|
||||
@ -87,12 +87,12 @@ class RCTResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelegate, URLSes
|
||||
_onVideoError?([
|
||||
"error": [
|
||||
"code": NSNumber(value: error.code),
|
||||
"localizedDescription": error.localizedDescription ?? "",
|
||||
"localizedDescription": error.localizedDescription,
|
||||
"localizedFailureReason": error.localizedFailureReason ?? "",
|
||||
"localizedRecoverySuggestion": error.localizedRecoverySuggestion ?? "",
|
||||
"domain": error.domain,
|
||||
],
|
||||
"target": _reactTag,
|
||||
"target": _reactTag as Any,
|
||||
])
|
||||
|
||||
return false
|
||||
@ -158,7 +158,7 @@ class RCTResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelegate, URLSes
|
||||
"loadedLicenseUrl": loadingRequest.request.url?.absoluteString ?? "",
|
||||
"contentId": contentId ?? "",
|
||||
"spcBase64": spcData.base64EncodedString(options: []),
|
||||
"target": self._reactTag])
|
||||
"target": self._reactTag as Any])
|
||||
} else {
|
||||
let data = try await RCTVideoDRM.handleInternalGetLicense(
|
||||
loadingRequest: loadingRequest,
|
||||
|
@ -60,13 +60,11 @@ enum RCTVideoSave {
|
||||
|
||||
static func ensureDirExists(withPath path: String?) -> Bool {
|
||||
var isDir: ObjCBool = false
|
||||
var error: Error?
|
||||
let exists = FileManager.default.fileExists(atPath: path ?? "", isDirectory: &isDir)
|
||||
if !(exists && isDir.boolValue) {
|
||||
do {
|
||||
try FileManager.default.createDirectory(atPath: path ?? "", withIntermediateDirectories: true, attributes: nil)
|
||||
} catch {}
|
||||
if error != nil {
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -179,12 +179,11 @@ enum RCTVideoUtils {
|
||||
title = value as! String
|
||||
}
|
||||
let language: String! = currentOption?.extendedLanguageTag ?? ""
|
||||
let selectedOpt = player.currentItem?.currentMediaSelection
|
||||
let selectedOption: AVMediaSelectionOption? = player.currentItem?.currentMediaSelection.selectedMediaOption(in: group!)
|
||||
let textTrack = TextTrack([
|
||||
"index": NSNumber(value: i),
|
||||
"title": title,
|
||||
"language": language,
|
||||
"language": language as Any,
|
||||
"selected": currentOption?.displayName == selectedOption?.displayName,
|
||||
])
|
||||
textTracks.append(textTrack)
|
||||
@ -375,8 +374,8 @@ enum RCTVideoUtils {
|
||||
assetOptions.setObject(headers, forKey: "AVURLAssetHTTPHeaderFieldsKey" as NSCopying)
|
||||
}
|
||||
let cookies: [AnyObject]! = HTTPCookieStorage.shared.cookies
|
||||
assetOptions.setObject(cookies, forKey: AVURLAssetHTTPCookiesKey as NSCopying)
|
||||
asset = AVURLAsset(url: url!, options: assetOptions as! [String: Any])
|
||||
assetOptions.setObject(cookies as Any, forKey: AVURLAssetHTTPCookiesKey as NSCopying)
|
||||
asset = AVURLAsset(url: url!, options: assetOptions as? [String: Any])
|
||||
} else {
|
||||
asset = AVURLAsset(url: url!)
|
||||
}
|
||||
@ -431,30 +430,22 @@ enum RCTVideoUtils {
|
||||
return try? await AVVideoComposition.videoComposition(
|
||||
with: asset,
|
||||
applyingCIFiltersWithHandler: { (request: AVAsynchronousCIImageFilteringRequest) in
|
||||
if filter == nil {
|
||||
request.finish(with: request.sourceImage, context: nil)
|
||||
} else {
|
||||
let image: CIImage! = request.sourceImage.clampedToExtent()
|
||||
filter.setValue(image, forKey: kCIInputImageKey)
|
||||
let output: CIImage! = filter.outputImage?.cropped(to: request.sourceImage.extent)
|
||||
request.finish(with: output, context: nil)
|
||||
}
|
||||
}
|
||||
)
|
||||
} else {
|
||||
#if !os(visionOS)
|
||||
return AVVideoComposition(
|
||||
asset: asset,
|
||||
applyingCIFiltersWithHandler: { (request: AVAsynchronousCIImageFilteringRequest) in
|
||||
if filter == nil {
|
||||
request.finish(with: request.sourceImage, context: nil)
|
||||
} else {
|
||||
let image: CIImage! = request.sourceImage.clampedToExtent()
|
||||
filter.setValue(image, forKey: kCIInputImageKey)
|
||||
let output: CIImage! = filter.outputImage?.cropped(to: request.sourceImage.extent)
|
||||
request.finish(with: output, context: nil)
|
||||
}
|
||||
}
|
||||
)
|
||||
#endif
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
#endif
|
||||
|
||||
if let video = _player?.currentItem,
|
||||
video == nil || video.status != AVPlayerItem.Status.readyToPlay {
|
||||
video.status != AVPlayerItem.Status.readyToPlay {
|
||||
return
|
||||
}
|
||||
|
||||
@ -386,7 +386,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
"playableDuration": RCTVideoUtils.calculatePlayableDuration(_player, withSource: _source),
|
||||
"atValue": currentTime?.value ?? .zero,
|
||||
"currentPlaybackTime": NSNumber(value: Double(currentPlaybackTime?.timeIntervalSince1970 ?? 0 * 1000)).int64Value,
|
||||
"target": reactTag,
|
||||
"target": reactTag as Any,
|
||||
"seekableDuration": RCTVideoUtils.calculateSeekableDuration(_player),
|
||||
])
|
||||
}
|
||||
@ -418,12 +418,12 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
// Perform on next run loop, otherwise onVideoLoadStart is nil
|
||||
onVideoLoadStart?([
|
||||
"src": [
|
||||
"uri": _source?.uri ?? NSNull(),
|
||||
"uri": _source?.uri ?? NSNull() as Any,
|
||||
"type": _source?.type ?? NSNull(),
|
||||
"isNetwork": NSNumber(value: _source?.isNetwork ?? false),
|
||||
],
|
||||
"drm": source.drm?.json ?? NSNull(),
|
||||
"target": reactTag,
|
||||
"target": reactTag as Any,
|
||||
])
|
||||
|
||||
if let uri = source.uri, uri.starts(with: "ph://") {
|
||||
@ -491,7 +491,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
if _player == nil {
|
||||
_player = AVPlayer()
|
||||
ReactNativeVideoManager.shared.onInstanceCreated(id: instanceId, player: _player)
|
||||
ReactNativeVideoManager.shared.onInstanceCreated(id: instanceId, player: _player as Any)
|
||||
|
||||
_player!.replaceCurrentItem(with: playerItem)
|
||||
|
||||
@ -812,7 +812,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
self.setPaused(self._paused)
|
||||
self.onVideoSeek?(["currentTime": NSNumber(value: Float(CMTimeGetSeconds(item.currentTime()))),
|
||||
"seekTime": time,
|
||||
"target": self.reactTag])
|
||||
"target": self.reactTag as Any])
|
||||
}
|
||||
|
||||
_pendingSeek = false
|
||||
@ -910,7 +910,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
func applyModifiers() {
|
||||
if let video = _player?.currentItem,
|
||||
video == nil || video.status != AVPlayerItem.Status.readyToPlay {
|
||||
video.status != AVPlayerItem.Status.readyToPlay {
|
||||
return
|
||||
}
|
||||
if _muted {
|
||||
@ -1009,7 +1009,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
@objc
|
||||
func setFullscreen(_ fullscreen: Bool) {
|
||||
var alreadyFullscreenPresented = _presentingViewController?.presentedViewController != nil
|
||||
let alreadyFullscreenPresented = _presentingViewController?.presentedViewController != nil
|
||||
if fullscreen && !_fullscreenPlayerPresented && _player != nil && !alreadyFullscreenPresented {
|
||||
// Ensure player view controller is not null
|
||||
// Controls will be displayed even if it is disabled in configuration
|
||||
@ -1048,7 +1048,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
self._fullscreenPlayerPresented = fullscreen
|
||||
self._playerViewController?.autorotate = self._fullscreenAutorotate
|
||||
|
||||
self.onVideoFullscreenPlayerDidPresent?(["target": self.reactTag])
|
||||
self.onVideoFullscreenPlayerDidPresent?(["target": self.reactTag as Any])
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1312,7 +1312,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
_selectedAudioTrackCriteria = nil
|
||||
_presentingViewController = nil
|
||||
|
||||
ReactNativeVideoManager.shared.onInstanceRemoved(id: instanceId, player: _player)
|
||||
ReactNativeVideoManager.shared.onInstanceRemoved(id: instanceId, player: _player as Any)
|
||||
_player = nil
|
||||
_resouceLoaderDelegate = nil
|
||||
_playerObserver.clearPlayer()
|
||||
@ -1366,7 +1366,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
_isBuffering = false
|
||||
}
|
||||
onReadyForDisplay?([
|
||||
"target": reactTag,
|
||||
"target": reactTag as Any,
|
||||
])
|
||||
}
|
||||
|
||||
@ -1385,7 +1385,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
onTimedMetadata?([
|
||||
"target": reactTag,
|
||||
"target": reactTag as Any,
|
||||
"metadata": metadata,
|
||||
])
|
||||
}
|
||||
@ -1448,7 +1448,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
var orientation = "undefined"
|
||||
|
||||
let tracks = await RCTVideoAssetsUtils.getTracks(asset: _playerItem.asset, withMediaType: .video)
|
||||
var presentationSize = _playerItem.presentationSize
|
||||
let presentationSize = _playerItem.presentationSize
|
||||
if presentationSize.height != 0.0 {
|
||||
width = Float(presentationSize.width)
|
||||
height = Float(presentationSize.height)
|
||||
@ -1495,14 +1495,14 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
[
|
||||
"error": [
|
||||
"code": NSNumber(value: (_playerItem.error! as NSError).code),
|
||||
"localizedDescription": _playerItem.error?.localizedDescription == nil ? "" : _playerItem.error?.localizedDescription,
|
||||
"localizedDescription": _playerItem.error?.localizedDescription == nil ? "" : _playerItem.error?.localizedDescription as Any,
|
||||
"localizedFailureReason": ((_playerItem.error! as NSError).localizedFailureReason == nil ?
|
||||
"" : (_playerItem.error! as NSError).localizedFailureReason) ?? "",
|
||||
"localizedRecoverySuggestion": ((_playerItem.error! as NSError).localizedRecoverySuggestion == nil ?
|
||||
"" : (_playerItem.error! as NSError).localizedRecoverySuggestion) ?? "",
|
||||
"domain": (_playerItem.error as! NSError).domain,
|
||||
],
|
||||
"target": reactTag,
|
||||
"target": reactTag as Any,
|
||||
]
|
||||
)
|
||||
}
|
||||
@ -1615,12 +1615,12 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
[
|
||||
"error": [
|
||||
"code": NSNumber(value: (error as NSError).code),
|
||||
"localizedDescription": error.localizedDescription ?? "",
|
||||
"localizedDescription": error.localizedDescription,
|
||||
"localizedFailureReason": (error as NSError).localizedFailureReason ?? "",
|
||||
"localizedRecoverySuggestion": (error as NSError).localizedRecoverySuggestion ?? "",
|
||||
"domain": (error as NSError).domain,
|
||||
],
|
||||
"target": reactTag,
|
||||
"target": reactTag as Any,
|
||||
]
|
||||
)
|
||||
}
|
||||
@ -1667,7 +1667,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
guard let lastEvent = accessLog.events.last else { return }
|
||||
if lastEvent.indicatedBitrate != _lastBitrate {
|
||||
_lastBitrate = lastEvent.indicatedBitrate
|
||||
onVideoBandwidthUpdate?(["bitrate": _lastBitrate, "target": reactTag])
|
||||
onVideoBandwidthUpdate?(["bitrate": _lastBitrate, "target": reactTag as Any])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import AVKit
|
||||
import Foundation
|
||||
|
||||
protocol RCTVideoPlayerViewControllerDelegate: class {
|
||||
protocol RCTVideoPlayerViewControllerDelegate: AnyObject {
|
||||
func videoPlayerViewControllerWillDismiss(playerViewController: AVPlayerViewController)
|
||||
func videoPlayerViewControllerDidDismiss(playerViewController: AVPlayerViewController)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user