From 11962d9e028259ae474b7d90cb4d809d08ef3250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Moska=C5=82a?= <91079590+moskalakamil@users.noreply.github.com> Date: Sun, 15 Mar 2026 12:56:47 +0100 Subject: [PATCH] chore: swift lint (#4856) --- ios/Video/AudioSessionManager.swift | 4 ++-- ios/Video/DataStructures/AdParams.swift | 19 +++++++++++++++---- .../DataStructures/OverridePlayerAsset.swift | 4 ++-- ios/Video/DataStructures/SubtitleStyle.swift | 2 +- ios/Video/Features/DRMManager.swift | 2 +- ios/Video/Features/RCTIMAAdsManager.swift | 10 +++++----- ios/Video/Features/RCTPlayerObserver.swift | 2 +- ios/Video/Features/RCTPlayerOperations.swift | 2 +- ios/Video/Features/RCTVideoUtils.swift | 8 ++++---- ios/Video/NowPlayingInfoCenterManager.swift | 2 +- ios/Video/RCTVideo.swift | 17 ++++++++--------- ios/Video/RNVAVPlayerPlugin.swift | 8 ++++++-- 12 files changed, 47 insertions(+), 33 deletions(-) diff --git a/ios/Video/AudioSessionManager.swift b/ios/Video/AudioSessionManager.swift index dfe16de0..93a8a9f9 100644 --- a/ios/Video/AudioSessionManager.swift +++ b/ios/Video/AudioSessionManager.swift @@ -86,7 +86,7 @@ class AudioSessionManager { configureAudioSession() } - // Handle remote control events from NowPlayingInfoCenterManager + /// Handle remote control events from NowPlayingInfoCenterManager func setRemoteControlEventsActive(_ active: Bool) { if isAudioSessionManagementDisabled { // 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) { // Only update if this is a registered view if videoViews.contains(view) { diff --git a/ios/Video/DataStructures/AdParams.swift b/ios/Video/DataStructures/AdParams.swift index 749f4888..1c77d1fa 100644 --- a/ios/Video/DataStructures/AdParams.swift +++ b/ios/Video/DataStructures/AdParams.swift @@ -12,10 +12,21 @@ public struct AdParams { let json: NSDictionary? - var isCSAI: Bool { type == "csai" && adTagUrl != nil } - var isDAI: Bool { type == "ssai" } - var isDAIVod: Bool { type == "ssai" && streamType == "vod" } - var isDAILive: Bool { type == "ssai" && streamType == "live" } + var isCSAI: Bool { + type == "csai" && adTagUrl != nil + } + + var isDAI: Bool { + type == "ssai" + } + + var isDAIVod: Bool { + type == "ssai" && streamType == "vod" + } + + var isDAILive: Bool { + type == "ssai" && streamType == "live" + } init(_ json: NSDictionary!) { guard json != nil else { diff --git a/ios/Video/DataStructures/OverridePlayerAsset.swift b/ios/Video/DataStructures/OverridePlayerAsset.swift index 07504e0d..b5c2a4f9 100644 --- a/ios/Video/DataStructures/OverridePlayerAsset.swift +++ b/ios/Video/DataStructures/OverridePlayerAsset.swift @@ -3,9 +3,9 @@ import AVFoundation // MARK: - 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 - // Return fully modified asset, that will skip the default prepare process + /// Return fully modified asset, that will skip the default prepare process case full } diff --git a/ios/Video/DataStructures/SubtitleStyle.swift b/ios/Video/DataStructures/SubtitleStyle.swift index 76bd8632..d265e925 100644 --- a/ios/Video/DataStructures/SubtitleStyle.swift +++ b/ios/Video/DataStructures/SubtitleStyle.swift @@ -1,5 +1,5 @@ struct SubtitleStyle { - // Extend with more style properties as needed. + /// Extend with more style properties as needed. private(set) var opacity: CGFloat enum SubtitleStyleKeys { diff --git a/ios/Video/Features/DRMManager.swift b/ios/Video/Features/DRMManager.swift index 93f95a98..458bf466 100644 --- a/ios/Video/Features/DRMManager.swift +++ b/ios/Video/Features/DRMManager.swift @@ -16,7 +16,7 @@ class DRMManager: NSObject, DRMManagerSpec { var onVideoError: RCTDirectEventBlock? var onGetLicense: RCTDirectEventBlock? - // Licenses handled by onGetLicense (from JS side) + /// Licenses handled by onGetLicense (from JS side) var pendingLicenses: [String: AVContentKeyRequest] = [:] override init() { diff --git a/ios/Video/Features/RCTIMAAdsManager.swift b/ios/Video/Features/RCTIMAAdsManager.swift index d36fb5cb..c547dfc5 100644 --- a/ios/Video/Features/RCTIMAAdsManager.swift +++ b/ios/Video/Features/RCTIMAAdsManager.swift @@ -6,15 +6,15 @@ private weak var _video: RCTVideo? 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! - /* 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! - /* 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? - /* 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? - /* 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? init(video: RCTVideo!, isPictureInPictureActive: @escaping () -> Bool) { diff --git a/ios/Video/Features/RCTPlayerObserver.swift b/ios/Video/Features/RCTPlayerObserver.swift index 6462c512..339932f4 100644 --- a/ios/Video/Features/RCTPlayerObserver.swift +++ b/ios/Video/Features/RCTPlayerObserver.swift @@ -236,7 +236,7 @@ class RCTPlayerObserver: NSObject, AVPlayerItemMetadataOutputPushDelegate, AVPla ) } - /* Cancels the previously registered time observer. */ + /** Cancels the previously registered time observer. */ func removePlayerTimeObserver() { guard let timeObserver = _timeObserver else { return } player?.removeTimeObserver(timeObserver) diff --git a/ios/Video/Features/RCTPlayerOperations.swift b/ios/Video/Features/RCTPlayerOperations.swift index c559132a..9f639d61 100644 --- a/ios/Video/Features/RCTPlayerOperations.swift +++ b/ios/Video/Features/RCTPlayerOperations.swift @@ -5,7 +5,7 @@ let RCTVideoUnset = -1 // MARK: - RCTPlayerOperations -/*! +/** ! * Collection of mutating functions */ enum RCTPlayerOperations { diff --git a/ios/Video/Features/RCTVideoUtils.swift b/ios/Video/Features/RCTVideoUtils.swift index 329b26ff..7bef5400 100644 --- a/ios/Video/Features/RCTVideoUtils.swift +++ b/ios/Video/Features/RCTVideoUtils.swift @@ -38,11 +38,11 @@ enum RCTVideoAssetsUtils { // MARK: - RCTVideoUtils -/*! +/** ! * Collection of pure functions */ enum RCTVideoUtils { - /*! + /** ! * 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. @@ -195,7 +195,7 @@ enum RCTVideoUtils { return textTracks } - // UNUSED + /// UNUSED static func getCurrentTime(playerItem: AVPlayerItem?) -> Float { return Float(CMTimeGetSeconds(playerItem?.currentTime() ?? .zero)) } @@ -310,7 +310,7 @@ enum RCTVideoUtils { return validTextTracks } - /* + /** * 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 is needed because there is a bug where sideloaded texttracks cannot be disabled in the AVPlayer. Loading this VTT file instead solves that problem. diff --git a/ios/Video/NowPlayingInfoCenterManager.swift b/ios/Video/NowPlayingInfoCenterManager.swift index a52e930e..7927c373 100644 --- a/ios/Video/NowPlayingInfoCenterManager.swift +++ b/ios/Video/NowPlayingInfoCenterManager.swift @@ -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 { return player.observe(\.rate) { [weak self] player, change in guard let self else { return } diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 48c4df73..5f2f5f66 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -26,7 +26,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH private var _pendingSeekTime: Float = 0.0 private var _lastSeekTime: Float = 0.0 - /* For sending videoProgress events */ + /** For sending videoProgress events */ private var _controls = false /* Keep track of any modifiers, need to be applied after each play */ @@ -85,9 +85,9 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH /* IMA Ads */ #if USE_GOOGLE_IMA 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? - /* 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? #endif 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]) { 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) { guard let _playerItem else { return @@ -1544,12 +1544,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH return nil } // 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 } json["index"] = index // Insert the index into the json dictionary return json } - return mappedTracks } 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) { if _isBuffering { _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 func setOnClick(_: Any) {} } diff --git a/ios/Video/RNVAVPlayerPlugin.swift b/ios/Video/RNVAVPlayerPlugin.swift index c6c528e8..7030deff 100644 --- a/ios/Video/RNVAVPlayerPlugin.swift +++ b/ios/Video/RNVAVPlayerPlugin.swift @@ -18,7 +18,9 @@ open class RNVAVPlayerPlugin: RNVPlugin { * Only one plugin can provide DRM manager at a time * @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 @@ -42,7 +44,9 @@ open class RNVAVPlayerPlugin: RNVPlugin { * @param asset: The AVAsset prepared by the player * @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