chore(linter/swift): add shorthand_optional_binding
rule (#3456)
* chore(linter/swift): add `shorthand_optional_binding` rule * lint code
This commit is contained in:
parent
481cc71eda
commit
2ed3949307
@ -40,6 +40,7 @@ opt_in_rules:
|
||||
- redundant_nil_coalescing
|
||||
- attributes
|
||||
- convenience_type
|
||||
- shorthand_optional_binding
|
||||
analyzer_rules:
|
||||
- explicit_self
|
||||
- unused_declaration
|
||||
|
@ -24,7 +24,7 @@
|
||||
}
|
||||
|
||||
func requestAds() {
|
||||
guard let _video = _video else { return }
|
||||
guard let _video else { return }
|
||||
// Create ad display container for ad rendering.
|
||||
let adDisplayContainer = IMAAdDisplayContainer(adContainer: _video, viewController: _video.reactViewController())
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
// MARK: - IMAAdsLoaderDelegate
|
||||
|
||||
func adsLoader(_: IMAAdsLoader, adsLoadedWith adsLoadedData: IMAAdsLoadedData) {
|
||||
guard let _video = _video else { return }
|
||||
guard let _video else { return }
|
||||
// Grab the instance of the IMAAdsManager and set yourself as the delegate.
|
||||
adsManager = adsLoadedData.adsManager
|
||||
adsManager?.delegate = self
|
||||
@ -81,7 +81,7 @@
|
||||
// MARK: - IMAAdsManagerDelegate
|
||||
|
||||
func adsManager(_ adsManager: IMAAdsManager, didReceive event: IMAAdEvent) {
|
||||
guard let _video = _video else { return }
|
||||
guard let _video else { return }
|
||||
// Mute ad if the main player is muted
|
||||
if _video.isMuted() {
|
||||
adsManager.volume = 0
|
||||
@ -117,7 +117,7 @@
|
||||
print("AdsManager error: " + error.message!)
|
||||
}
|
||||
|
||||
guard let _video = _video else { return }
|
||||
guard let _video else { return }
|
||||
|
||||
if _video.onReceiveAdEvent != nil {
|
||||
_video.onReceiveAdEvent?([
|
||||
|
@ -18,13 +18,13 @@ import React
|
||||
}
|
||||
|
||||
func pictureInPictureControllerDidStartPictureInPicture(_: AVPictureInPictureController) {
|
||||
guard let _onPictureInPictureStatusChanged = _onPictureInPictureStatusChanged else { return }
|
||||
guard let _onPictureInPictureStatusChanged else { return }
|
||||
|
||||
_onPictureInPictureStatusChanged()
|
||||
}
|
||||
|
||||
func pictureInPictureControllerDidStopPictureInPicture(_: AVPictureInPictureController) {
|
||||
guard let _onPictureInPictureStatusChanged = _onPictureInPictureStatusChanged else { return }
|
||||
guard let _onPictureInPictureStatusChanged else { return }
|
||||
|
||||
_onPictureInPictureStatusChanged()
|
||||
}
|
||||
@ -33,7 +33,7 @@ import React
|
||||
_: AVPictureInPictureController,
|
||||
restoreUserInterfaceForPictureInPictureStopWithCompletionHandler completionHandler: @escaping (Bool) -> Void
|
||||
) {
|
||||
guard let _onRestoreUserInterfaceForPictureInPictureStop = _onRestoreUserInterfaceForPictureInPictureStop else { return }
|
||||
guard let _onRestoreUserInterfaceForPictureInPictureStop else { return }
|
||||
|
||||
_onRestoreUserInterfaceForPictureInPictureStop()
|
||||
|
||||
@ -41,7 +41,7 @@ import React
|
||||
}
|
||||
|
||||
func setRestoreUserInterfaceForPIPStopCompletionHandler(_ restore: Bool) {
|
||||
guard let _restoreUserInterfaceForPIPStopCompletionHandler = _restoreUserInterfaceForPIPStopCompletionHandler else { return }
|
||||
guard let _restoreUserInterfaceForPIPStopCompletionHandler else { return }
|
||||
_restoreUserInterfaceForPIPStopCompletionHandler(restore)
|
||||
self._restoreUserInterfaceForPIPStopCompletionHandler = nil
|
||||
}
|
||||
@ -61,7 +61,7 @@ import React
|
||||
}
|
||||
_isActive = isActive
|
||||
|
||||
guard let _pipController = _pipController else { return }
|
||||
guard let _pipController else { return }
|
||||
|
||||
if _isActive && !_pipController.isPictureInPictureActive {
|
||||
DispatchQueue.main.async {
|
||||
|
@ -98,7 +98,7 @@ class RCTPlayerObserver: NSObject, AVPlayerItemMetadataOutputPushDelegate {
|
||||
private var _playerViewControllerOverlayFrameObserver: NSKeyValueObservation?
|
||||
|
||||
deinit {
|
||||
if let _handlers = _handlers {
|
||||
if let _handlers {
|
||||
NotificationCenter.default.removeObserver(_handlers)
|
||||
}
|
||||
}
|
||||
@ -206,7 +206,7 @@ class RCTPlayerObserver: NSObject, AVPlayerItemMetadataOutputPushDelegate {
|
||||
}
|
||||
|
||||
func replaceTimeObserverIfSet(_ newUpdateInterval: Float64? = nil) {
|
||||
if let newUpdateInterval = newUpdateInterval {
|
||||
if let newUpdateInterval {
|
||||
_progressUpdateInterval = newUpdateInterval
|
||||
}
|
||||
if _timeObserver != nil {
|
||||
|
@ -159,12 +159,12 @@ enum RCTPlayerOperations {
|
||||
mediaOption = group.options[index]
|
||||
}
|
||||
}
|
||||
} else if let group = group { // default. invalid type or "system"
|
||||
} else if let group { // default. invalid type or "system"
|
||||
player?.currentItem?.selectMediaOptionAutomatically(in: group)
|
||||
return
|
||||
}
|
||||
|
||||
if let group = group {
|
||||
if let group {
|
||||
// If a match isn't found, option will be nil and text tracks will be disabled
|
||||
player?.currentItem?.select(mediaOption, in: group)
|
||||
}
|
||||
@ -206,7 +206,7 @@ enum RCTPlayerOperations {
|
||||
options = .duckOthers
|
||||
}
|
||||
|
||||
if let category = category, let options = options {
|
||||
if let category, let options {
|
||||
do {
|
||||
try audioSession.setCategory(category, options: options)
|
||||
} catch {
|
||||
@ -229,13 +229,13 @@ enum RCTPlayerOperations {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else if let category = category, options == nil {
|
||||
} else if let category, options == nil {
|
||||
do {
|
||||
try audioSession.setCategory(category)
|
||||
} catch {
|
||||
debugPrint("[RCTPlayerOperations] Problem setting up AVAudioSession category. Error: \(error).")
|
||||
}
|
||||
} else if category == nil, let options = options {
|
||||
} else if category == nil, let options {
|
||||
do {
|
||||
try audioSession.setCategory(audioSession.category, options: options)
|
||||
} catch {
|
||||
|
@ -113,7 +113,7 @@ class RCTResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelegate, URLSes
|
||||
|
||||
func handleEmbeddedKey(_ loadingRequest: AVAssetResourceLoadingRequest!) -> Bool {
|
||||
guard let url = loadingRequest.request.url,
|
||||
let _localSourceEncryptionKeyScheme = _localSourceEncryptionKeyScheme,
|
||||
let _localSourceEncryptionKeyScheme,
|
||||
let persistentKeyData = RCTVideoUtils.extractDataFromCustomSchemeUrl(from: url, scheme: _localSourceEncryptionKeyScheme)
|
||||
else {
|
||||
return false
|
||||
@ -139,7 +139,7 @@ class RCTResourceLoaderDelegate: NSObject, AVAssetResourceLoaderDelegate, URLSes
|
||||
|
||||
_loadingRequests[requestKey] = loadingRequest
|
||||
|
||||
guard let _drm = _drm, let drmType = _drm.type, drmType == "fairplay" else {
|
||||
guard let _drm, let drmType = _drm.type, drmType == "fairplay" else {
|
||||
return finishLoadingWithError(error: RCTVideoErrorHandler.noDRMData, licenseUrl: requestKey)
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ enum RCTVideoDRM {
|
||||
var request = URLRequest(url: URL(string: licenseServer)!)
|
||||
request.httpMethod = "POST"
|
||||
|
||||
if let headers = headers {
|
||||
if let headers {
|
||||
for item in headers {
|
||||
guard let key = item.key as? String, let value = item.value as? String else {
|
||||
continue
|
||||
@ -90,7 +90,7 @@ enum RCTVideoDRM {
|
||||
reject(spcError)
|
||||
}
|
||||
|
||||
guard let spcData = spcData else {
|
||||
guard let spcData else {
|
||||
reject(RCTVideoErrorHandler.noSPC)
|
||||
return
|
||||
}
|
||||
@ -101,7 +101,7 @@ enum RCTVideoDRM {
|
||||
|
||||
static func createCertificateData(certificateStringUrl: String?, base64Certificate: Bool?) -> Promise<Data> {
|
||||
return Promise<Data>(on: .global()) { fulfill, reject in
|
||||
guard let certificateStringUrl = certificateStringUrl,
|
||||
guard let certificateStringUrl,
|
||||
let certificateURL = URL(string: certificateStringUrl.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed) ?? "") else {
|
||||
reject(RCTVideoErrorHandler.noCertificateURL)
|
||||
return
|
||||
@ -115,7 +115,7 @@ enum RCTVideoDRM {
|
||||
}
|
||||
} catch {}
|
||||
|
||||
guard let certificateData = certificateData else {
|
||||
guard let certificateData else {
|
||||
reject(RCTVideoErrorHandler.noCertificateData)
|
||||
return
|
||||
}
|
||||
@ -130,7 +130,7 @@ enum RCTVideoDRM {
|
||||
|
||||
return RCTVideoDRM.createCertificateData(certificateStringUrl: certificateUrl, base64Certificate: base64Certificate)
|
||||
.then { certificateData -> Promise<Data> in
|
||||
guard let contentIdData = contentIdData else {
|
||||
guard let contentIdData else {
|
||||
throw RCTVideoError.invalidContentId as! Error
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ enum RCTVideoDRM {
|
||||
)
|
||||
}
|
||||
.then { spcData -> Promise<Data> in
|
||||
guard let licenseServer = licenseServer else {
|
||||
guard let licenseServer else {
|
||||
throw RCTVideoError.noLicenseServerURL as! Error
|
||||
}
|
||||
return RCTVideoDRM.fetchLicense(
|
||||
|
@ -12,7 +12,7 @@ enum RCTVideoUtils {
|
||||
* \returns The playable duration of the current player item in seconds.
|
||||
*/
|
||||
static func calculatePlayableDuration(_ player: AVPlayer?, withSource source: VideoSource?) -> NSNumber {
|
||||
guard let player = player,
|
||||
guard let player,
|
||||
let video: AVPlayerItem = player.currentItem,
|
||||
video.status == AVPlayerItem.Status.readyToPlay else {
|
||||
return 0
|
||||
@ -31,7 +31,7 @@ enum RCTVideoUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if let effectiveTimeRange = effectiveTimeRange {
|
||||
if let effectiveTimeRange {
|
||||
let playableDuration: Float64 = CMTimeGetSeconds(CMTimeRangeGetEnd(effectiveTimeRange))
|
||||
if playableDuration > 0 {
|
||||
if source?.cropStart != nil {
|
||||
@ -95,7 +95,7 @@ enum RCTVideoUtils {
|
||||
}
|
||||
|
||||
static func getAudioTrackInfo(_ player: AVPlayer?) -> [AnyObject]! {
|
||||
guard let player = player else {
|
||||
guard let player else {
|
||||
return []
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ enum RCTVideoUtils {
|
||||
}
|
||||
|
||||
static func getTextTrackInfo(_ player: AVPlayer?) -> [TextTrack]! {
|
||||
guard let player = player else {
|
||||
guard let player else {
|
||||
return []
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ enum RCTVideoUtils {
|
||||
}
|
||||
|
||||
static func base64DataFromBase64String(base64String: String?) -> Data? {
|
||||
if let base64String = base64String {
|
||||
if let base64String {
|
||||
return Data(base64Encoded: base64String)
|
||||
}
|
||||
return nil
|
||||
@ -216,7 +216,7 @@ enum RCTVideoUtils {
|
||||
let videoAsset: AVAssetTrack! = asset.tracks(withMediaType: AVMediaType.video).first
|
||||
var validTextTracks: [TextTrack] = []
|
||||
|
||||
if let textTracks = textTracks, !textTracks.isEmpty {
|
||||
if let textTracks, !textTracks.isEmpty {
|
||||
for i in 0 ..< textTracks.count {
|
||||
var textURLAsset: AVURLAsset!
|
||||
let textUri: String = textTracks[i].uri
|
||||
|
@ -240,7 +240,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
if let userInfo = notification.userInfo {
|
||||
let reason: AVAudioSession.RouteChangeReason! = userInfo[AVAudioSessionRouteChangeReasonKey] as? AVAudioSession.RouteChangeReason
|
||||
// let previousRoute:NSNumber! = userInfo[AVAudioSessionRouteChangePreviousRouteKey] as? NSNumber
|
||||
if reason == .oldDeviceUnavailable, let onVideoAudioBecomingNoisy = onVideoAudioBecomingNoisy {
|
||||
if reason == .oldDeviceUnavailable, let onVideoAudioBecomingNoisy {
|
||||
onVideoAudioBecomingNoisy(["target": reactTag as Any])
|
||||
}
|
||||
}
|
||||
@ -307,7 +307,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
// perform on next run loop, otherwise other passed react-props may not be set
|
||||
RCTVideoUtils.delay()
|
||||
.then { [weak self] in
|
||||
guard let self = self else { throw NSError(domain: "", code: 0, userInfo: nil) }
|
||||
guard let self else { throw NSError(domain: "", code: 0, userInfo: nil) }
|
||||
guard let source = self._source else {
|
||||
DebugLog("The source not exist")
|
||||
throw NSError(domain: "", code: 0, userInfo: nil)
|
||||
@ -349,7 +349,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
return Promise { self.playerItemPrepareText(asset: asset, assetOptions: assetOptions, uri: source.uri ?? "") }
|
||||
}.then { [weak self] (playerItem: AVPlayerItem!) in
|
||||
guard let self = self else { throw NSError(domain: "", code: 0, userInfo: nil) }
|
||||
guard let self else { throw NSError(domain: "", code: 0, userInfo: nil) }
|
||||
|
||||
self._player?.pause()
|
||||
self._playerItem = playerItem
|
||||
@ -583,7 +583,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
let seekTime: NSNumber! = info["time"] as! NSNumber
|
||||
let seekTolerance: NSNumber! = info["tolerance"] as! NSNumber
|
||||
let item: AVPlayerItem? = _player?.currentItem
|
||||
guard item != nil, let player = _player, let item = item, item.status == AVPlayerItem.Status.readyToPlay else {
|
||||
guard item != nil, let player = _player, let item, item.status == AVPlayerItem.Status.readyToPlay else {
|
||||
_pendingSeek = true
|
||||
_pendingSeekTime = seekTime.floatValue
|
||||
return
|
||||
@ -598,7 +598,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
seekTolerance: seekTolerance.floatValue
|
||||
)
|
||||
.then { [weak self] (_: Bool) in
|
||||
guard let self = self else { return }
|
||||
guard let self else { return }
|
||||
|
||||
self._playerObserver.addTimeObserverIfNotSet()
|
||||
if !wasPaused {
|
||||
@ -711,7 +711,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
|
||||
if let _maxBitRate = _maxBitRate {
|
||||
if let _maxBitRate {
|
||||
setMaxBitRate(_maxBitRate)
|
||||
}
|
||||
|
||||
@ -811,7 +811,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
viewController.present(playerViewController, animated: true, completion: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
guard let self else { return }
|
||||
// In fullscreen we must display controls
|
||||
self._playerViewController?.showsPlaybackControls = true
|
||||
self._fullscreenPlayerPresented = fullscreen
|
||||
@ -821,7 +821,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if !fullscreen && _fullscreenPlayerPresented, let _playerViewController = _playerViewController {
|
||||
} else if !fullscreen && _fullscreenPlayerPresented, let _playerViewController {
|
||||
self.videoPlayerViewControllerWillDismiss(playerViewController: _playerViewController)
|
||||
_presentingViewController?.dismiss(animated: true, completion: { [weak self] in
|
||||
self?.videoPlayerViewControllerDidDismiss(playerViewController: _playerViewController)
|
||||
@ -846,7 +846,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
func usePlayerViewController() {
|
||||
guard let _player = _player, let _playerItem = _playerItem else { return }
|
||||
guard let _player, let _playerItem else { return }
|
||||
|
||||
if _playerViewController == nil {
|
||||
_playerViewController = createPlayerViewController(player: _player, withPlayerItem: _playerItem)
|
||||
@ -855,7 +855,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
// resize mode must be set before subview is added
|
||||
setResizeMode(_resizeMode)
|
||||
|
||||
guard let _playerViewController = _playerViewController else { return }
|
||||
guard let _playerViewController else { return }
|
||||
|
||||
if _controls {
|
||||
let viewController: UIViewController! = self.reactViewController()
|
||||
@ -881,7 +881,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
func usePlayerLayer() {
|
||||
if let _player = _player {
|
||||
if let _player {
|
||||
_playerLayer = AVPlayerLayer(player: _player)
|
||||
_playerLayer?.frame = self.bounds
|
||||
_playerLayer?.needsDisplayOnBoundsChange = true
|
||||
@ -891,7 +891,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
setResizeMode(_resizeMode)
|
||||
_playerObserver.playerLayer = _playerLayer
|
||||
|
||||
if let _playerLayer = _playerLayer {
|
||||
if let _playerLayer {
|
||||
self.layer.addSublayer(_playerLayer)
|
||||
}
|
||||
self.layer.needsDisplayOnBoundsChange = true
|
||||
@ -934,7 +934,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
func videoPlayerViewControllerWillDismiss(playerViewController: AVPlayerViewController) {
|
||||
if _playerViewController == playerViewController
|
||||
&& _fullscreenPlayerPresented,
|
||||
let onVideoFullscreenPlayerWillDismiss = onVideoFullscreenPlayerWillDismiss {
|
||||
let onVideoFullscreenPlayerWillDismiss {
|
||||
_playerObserver.removePlayerViewControllerObservers()
|
||||
onVideoFullscreenPlayerWillDismiss(["target": reactTag as Any])
|
||||
}
|
||||
@ -965,7 +965,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
let filter: CIFilter! = CIFilter(name: filterName)
|
||||
if #available(iOS 9.0, *), let _playerItem = _playerItem {
|
||||
if #available(iOS 9.0, *), let _playerItem {
|
||||
self._playerItem?.videoComposition = AVVideoComposition(
|
||||
asset: _playerItem.asset,
|
||||
applyingCIFiltersWithHandler: { (request: AVAsynchronousCIImageFilteringRequest) in
|
||||
@ -1032,7 +1032,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
if _controls, let _playerViewController = _playerViewController {
|
||||
if _controls, let _playerViewController {
|
||||
_playerViewController.view.frame = bounds
|
||||
|
||||
// also adjust all subviews of contentOverlayView
|
||||
@ -1057,7 +1057,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
self.removePlayerLayer()
|
||||
|
||||
if let _playerViewController = _playerViewController {
|
||||
if let _playerViewController {
|
||||
_playerViewController.view.removeFromSuperview()
|
||||
_playerViewController.removeFromParent()
|
||||
_playerViewController.rctDelegate = nil
|
||||
@ -1120,7 +1120,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
let value = item.value as? String
|
||||
let identifier = item.identifier?.rawValue
|
||||
|
||||
if let value = value {
|
||||
if let value {
|
||||
metadata.append(["value": value, "identifier": identifier])
|
||||
}
|
||||
}
|
||||
@ -1133,7 +1133,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
|
||||
// Handle player item status change.
|
||||
func handlePlayerItemStatusChange(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<AVPlayerItem.Status>) {
|
||||
guard let _playerItem = _playerItem else {
|
||||
guard let _playerItem else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -1145,7 +1145,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
func handleReadyToPlay() {
|
||||
guard let _playerItem = _playerItem else { return }
|
||||
guard let _playerItem else { return }
|
||||
var duration = Float(CMTimeGetSeconds(_playerItem.asset.duration))
|
||||
|
||||
if duration.isNaN {
|
||||
@ -1217,7 +1217,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
func handlePlaybackFailed() {
|
||||
guard let _playerItem = _playerItem else { return }
|
||||
guard let _playerItem else { return }
|
||||
onVideoError?(
|
||||
[
|
||||
"error": [
|
||||
@ -1249,7 +1249,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
func handlePlaybackRateChange(player: AVPlayer, change: NSKeyValueObservedChange<Float>) {
|
||||
guard let _player = _player else { return }
|
||||
guard let _player else { return }
|
||||
|
||||
if player.rate == change.oldValue && change.oldValue != nil {
|
||||
return
|
||||
@ -1269,7 +1269,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
func handleVolumeChange(player: AVPlayer, change: NSKeyValueObservedChange<Float>) {
|
||||
guard let _player = _player else { return }
|
||||
guard let _player else { return }
|
||||
|
||||
if player.rate == change.oldValue && change.oldValue != nil {
|
||||
return
|
||||
@ -1280,7 +1280,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
|
||||
}
|
||||
|
||||
func handleExternalPlaybackActiveChange(player _: AVPlayer, change _: NSKeyValueObservedChange<Bool>) {
|
||||
guard let _player = _player else { return }
|
||||
guard let _player else { return }
|
||||
onVideoExternalPlaybackChange?(["isExternalPlaybackActive": NSNumber(value: _player.isExternalPlaybackActive),
|
||||
"target": reactTag as Any])
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class RCTVideoCachingHandler: NSObject, DVAssetLoaderDelegatesDelegate {
|
||||
let url = URL(string: uri)
|
||||
return getItemForUri(uri)
|
||||
.then { [weak self] (videoCacheStatus: RCTVideoCacheStatus, cachedAsset: AVAsset?) -> AVPlayerItem in
|
||||
guard let self = self, let playerItemPrepareText = self.playerItemPrepareText else { throw NSError(domain: "", code: 0, userInfo: nil) }
|
||||
guard let self, let playerItemPrepareText = self.playerItemPrepareText else { throw NSError(domain: "", code: 0, userInfo: nil) }
|
||||
switch videoCacheStatus {
|
||||
case .missingFileExtension:
|
||||
DebugLog("""
|
||||
@ -53,7 +53,7 @@ class RCTVideoCachingHandler: NSObject, DVAssetLoaderDelegatesDelegate {
|
||||
return playerItemPrepareText(asset, options, "")
|
||||
|
||||
default:
|
||||
if let cachedAsset = cachedAsset {
|
||||
if let cachedAsset {
|
||||
DebugLog("Playing back uri '\(uri)' from cache")
|
||||
// See note in playerItemForSource about not being able to support text tracks & caching
|
||||
return AVPlayerItem(asset: cachedAsset)
|
||||
|
Loading…
Reference in New Issue
Block a user