chore: swift lint (#4856)

This commit is contained in:
Kamil Moskała
2026-03-15 12:56:47 +01:00
committed by GitHub
parent 92b0a0e416
commit 11962d9e02
12 changed files with 47 additions and 33 deletions

View File

@@ -86,7 +86,7 @@ class AudioSessionManager {
configureAudioSession() configureAudioSession()
} }
// Handle remote control events from NowPlayingInfoCenterManager /// Handle remote control events from NowPlayingInfoCenterManager
func setRemoteControlEventsActive(_ active: Bool) { func setRemoteControlEventsActive(_ active: Bool) {
if isAudioSessionManagementDisabled { if isAudioSessionManagementDisabled {
// AUDIO SESSION MANAGEMENT DISABLED BY USER // AUDIO SESSION MANAGEMENT DISABLED BY USER
@@ -111,7 +111,7 @@ class AudioSessionManager {
} }
} }
// Notification that a player's properties have changed /// Notification that a player's properties have changed
func playerPropertiesChanged(view: RCTVideo) { func playerPropertiesChanged(view: RCTVideo) {
// Only update if this is a registered view // Only update if this is a registered view
if videoViews.contains(view) { if videoViews.contains(view) {

View File

@@ -12,10 +12,21 @@ public struct AdParams {
let json: NSDictionary? let json: NSDictionary?
var isCSAI: Bool { type == "csai" && adTagUrl != nil } var isCSAI: Bool {
var isDAI: Bool { type == "ssai" } type == "csai" && adTagUrl != nil
var isDAIVod: Bool { type == "ssai" && streamType == "vod" } }
var isDAILive: Bool { type == "ssai" && streamType == "live" }
var isDAI: Bool {
type == "ssai"
}
var isDAIVod: Bool {
type == "ssai" && streamType == "vod"
}
var isDAILive: Bool {
type == "ssai" && streamType == "live"
}
init(_ json: NSDictionary!) { init(_ json: NSDictionary!) {
guard json != nil else { guard json != nil else {

View File

@@ -3,9 +3,9 @@ import AVFoundation
// MARK: - OverridePlayerAssetType // MARK: - OverridePlayerAssetType
public enum OverridePlayerAssetType { public enum OverridePlayerAssetType {
// Return partially modified asset, that will go through the default prepare process /// Return partially modified asset, that will go through the default prepare process
case partial case partial
// Return fully modified asset, that will skip the default prepare process /// Return fully modified asset, that will skip the default prepare process
case full case full
} }

View File

@@ -1,5 +1,5 @@
struct SubtitleStyle { struct SubtitleStyle {
// Extend with more style properties as needed. /// Extend with more style properties as needed.
private(set) var opacity: CGFloat private(set) var opacity: CGFloat
enum SubtitleStyleKeys { enum SubtitleStyleKeys {

View File

@@ -16,7 +16,7 @@ class DRMManager: NSObject, DRMManagerSpec {
var onVideoError: RCTDirectEventBlock? var onVideoError: RCTDirectEventBlock?
var onGetLicense: RCTDirectEventBlock? var onGetLicense: RCTDirectEventBlock?
// Licenses handled by onGetLicense (from JS side) /// Licenses handled by onGetLicense (from JS side)
var pendingLicenses: [String: AVContentKeyRequest] = [:] var pendingLicenses: [String: AVContentKeyRequest] = [:]
override init() { override init() {

View File

@@ -6,15 +6,15 @@
private weak var _video: RCTVideo? private weak var _video: RCTVideo?
private var _isPictureInPictureActive: () -> Bool private var _isPictureInPictureActive: () -> Bool
/* Entry point for the SDK. Used to make ad requests. */ /** Entry point for the SDK. Used to make ad requests. */
private var adsLoader: IMAAdsLoader! private var adsLoader: IMAAdsLoader!
/* Main point of interaction with the SDK. Created by the SDK as the result of an ad request. */ /** Main point of interaction with the SDK. Created by the SDK as the result of an ad request. */
private var adsManager: IMAAdsManager! private var adsManager: IMAAdsManager!
/* References the stream manager from the IMA DAI SDK after successfully loading the DAI stream. */ /** References the stream manager from the IMA DAI SDK after successfully loading the DAI stream. */
private var streamManager: IMAStreamManager? private var streamManager: IMAStreamManager?
/* Ad container view for DAI - stored to ensure proper z-ordering */ /** Ad container view for DAI - stored to ensure proper z-ordering */
private var daiAdContainerView: UIView? private var daiAdContainerView: UIView?
/* Picture-in-Picture proxy for DAI - stored to ensure proper Picture-in-Picture support */ /** Picture-in-Picture proxy for DAI - stored to ensure proper Picture-in-Picture support */
private var pipProxy: IMAPictureInPictureProxy? private var pipProxy: IMAPictureInPictureProxy?
init(video: RCTVideo!, isPictureInPictureActive: @escaping () -> Bool) { init(video: RCTVideo!, isPictureInPictureActive: @escaping () -> Bool) {

View File

@@ -236,7 +236,7 @@ class RCTPlayerObserver: NSObject, AVPlayerItemMetadataOutputPushDelegate, AVPla
) )
} }
/* Cancels the previously registered time observer. */ /** Cancels the previously registered time observer. */
func removePlayerTimeObserver() { func removePlayerTimeObserver() {
guard let timeObserver = _timeObserver else { return } guard let timeObserver = _timeObserver else { return }
player?.removeTimeObserver(timeObserver) player?.removeTimeObserver(timeObserver)

View File

@@ -5,7 +5,7 @@ let RCTVideoUnset = -1
// MARK: - RCTPlayerOperations // MARK: - RCTPlayerOperations
/*! /** !
* Collection of mutating functions * Collection of mutating functions
*/ */
enum RCTPlayerOperations { enum RCTPlayerOperations {

View File

@@ -38,11 +38,11 @@ enum RCTVideoAssetsUtils {
// MARK: - RCTVideoUtils // MARK: - RCTVideoUtils
/*! /** !
* Collection of pure functions * Collection of pure functions
*/ */
enum RCTVideoUtils { enum RCTVideoUtils {
/*! /** !
* Calculates and returns the playable duration of the current player item using its loaded time ranges. * Calculates and returns the playable duration of the current player item using its loaded time ranges.
* *
* \returns The playable duration of the current player item in seconds. * \returns The playable duration of the current player item in seconds.
@@ -195,7 +195,7 @@ enum RCTVideoUtils {
return textTracks return textTracks
} }
// UNUSED /// UNUSED
static func getCurrentTime(playerItem: AVPlayerItem?) -> Float { static func getCurrentTime(playerItem: AVPlayerItem?) -> Float {
return Float(CMTimeGetSeconds(playerItem?.currentTime() ?? .zero)) return Float(CMTimeGetSeconds(playerItem?.currentTime() ?? .zero))
} }
@@ -310,7 +310,7 @@ enum RCTVideoUtils {
return validTextTracks return validTextTracks
} }
/* /**
* Create an useless/almost empty VTT file in the list with available tracks. * Create an useless/almost empty VTT file in the list with available tracks.
* This track gets selected when you give type: "disabled" as the selectedTextTrack * This track gets selected when you give type: "disabled" as the selectedTextTrack
* This is needed because there is a bug where sideloaded texttracks cannot be disabled in the AVPlayer. Loading this VTT file instead solves that problem. * This is needed because there is a bug where sideloaded texttracks cannot be disabled in the AVPlayer. Loading this VTT file instead solves that problem.

View File

@@ -261,7 +261,7 @@ class NowPlayingInfoCenterManager {
} }
} }
// We will observe players rate to find last active player that info will be displayed /// We will observe players rate to find last active player that info will be displayed
private func observePlayers(player: AVPlayer) -> NSKeyValueObservation { private func observePlayers(player: AVPlayer) -> NSKeyValueObservation {
return player.observe(\.rate) { [weak self] player, change in return player.observe(\.rate) { [weak self] player, change in
guard let self else { return } guard let self else { return }

View File

@@ -26,7 +26,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
private var _pendingSeekTime: Float = 0.0 private var _pendingSeekTime: Float = 0.0
private var _lastSeekTime: Float = 0.0 private var _lastSeekTime: Float = 0.0
/* For sending videoProgress events */ /** For sending videoProgress events */
private var _controls = false private var _controls = false
/* Keep track of any modifiers, need to be applied after each play */ /* Keep track of any modifiers, need to be applied after each play */
@@ -85,9 +85,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
/* IMA Ads */ /* IMA Ads */
#if USE_GOOGLE_IMA #if USE_GOOGLE_IMA
private var _imaAdsManager: RCTIMAAdsManager! private var _imaAdsManager: RCTIMAAdsManager!
/* Playhead used by the SDK to track content video progress and insert mid-rolls. */ /** Playhead used by the SDK to track content video progress and insert mid-rolls. */
private var _contentPlayhead: IMAAVPlayerContentPlayhead? private var _contentPlayhead: IMAAVPlayerContentPlayhead?
/* The reference of your video player for the IMA DAI SDK to monitor playback and handle timed metadata */ /** The reference of your video player for the IMA DAI SDK to monitor playback and handle timed metadata */
private var _imaVideoDisplay: IMAAVPlayerVideoDisplay? private var _imaVideoDisplay: IMAAVPlayerVideoDisplay?
#endif #endif
private var _didRequestAds = false private var _didRequestAds = false
@@ -1505,7 +1505,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
]) ])
} }
// When timeMetadata is read the event onTimedMetadata is triggered /// When timeMetadata is read the event onTimedMetadata is triggered
func handleTimeMetadataChange(timedMetadata: [AVMetadataItem]) { func handleTimeMetadataChange(timedMetadata: [AVMetadataItem]) {
guard onTimedMetadata != nil else { return } guard onTimedMetadata != nil else { return }
@@ -1525,7 +1525,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
]) ])
} }
// Handle player item status change. /// Handle player item status change.
func handlePlayerItemStatusChange(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<AVPlayerItem.Status>) { func handlePlayerItemStatusChange(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<AVPlayerItem.Status>) {
guard let _playerItem else { guard let _playerItem else {
return return
@@ -1544,12 +1544,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
return nil return nil
} }
// Map each enumerated pair to include the index in the json dictionary // Map each enumerated pair to include the index in the json dictionary
let mappedTracks = tracks.enumerated().compactMap { index, track -> NSDictionary? in return tracks.enumerated().compactMap { index, track -> NSDictionary? in
guard let json = track.json?.mutableCopy() as? NSMutableDictionary else { return nil } guard let json = track.json?.mutableCopy() as? NSMutableDictionary else { return nil }
json["index"] = index // Insert the index into the json dictionary json["index"] = index // Insert the index into the json dictionary
return json return json
} }
return mappedTracks
} }
func handleReadyToPlay() { func handleReadyToPlay() {
@@ -1648,7 +1647,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
} }
} }
// Continue playing (or not if paused) after being paused due to hitting an unbuffered zone. /// Continue playing (or not if paused) after being paused due to hitting an unbuffered zone.
func handlePlaybackLikelyToKeepUp(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<Bool>) { func handlePlaybackLikelyToKeepUp(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<Bool>) {
if _isBuffering { if _isBuffering {
_isBuffering = false _isBuffering = false
@@ -1889,7 +1888,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
} }
} }
// Workaround for #3418 - https://github.com/TheWidlarzGroup/react-native-video/issues/3418#issuecomment-2043508862 /// Workaround for #3418 - https://github.com/TheWidlarzGroup/react-native-video/issues/3418#issuecomment-2043508862
@objc @objc
func setOnClick(_: Any) {} func setOnClick(_: Any) {}
} }

View File

@@ -18,7 +18,9 @@ open class RNVAVPlayerPlugin: RNVPlugin {
* Only one plugin can provide DRM manager at a time * Only one plugin can provide DRM manager at a time
* @return: DRMManagerSpec type if plugin wants to handle DRM, nil otherwise * @return: DRMManagerSpec type if plugin wants to handle DRM, nil otherwise
*/ */
open func getDRMManager() -> DRMManagerSpec? { nil } open func getDRMManager() -> DRMManagerSpec? {
nil
}
/** /**
* Function called when a new AVPlayer instance is created * Function called when a new AVPlayer instance is created
@@ -42,7 +44,9 @@ open class RNVAVPlayerPlugin: RNVPlugin {
* @param asset: The AVAsset prepared by the player * @param asset: The AVAsset prepared by the player
* @return: OverridePlayerAssetResult if you want to override, or nil if you don't * @return: OverridePlayerAssetResult if you want to override, or nil if you don't
*/ */
open func overridePlayerAsset(source _: VideoSource, asset _: AVAsset) async -> OverridePlayerAssetResult? { nil } open func overridePlayerAsset(source _: VideoSource, asset _: AVAsset) async -> OverridePlayerAssetResult? {
nil
}
// MARK: - RNVPlugin methods // MARK: - RNVPlugin methods