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()
}
// 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) {

View File

@@ -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 {

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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() {

View File

@@ -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) {

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() {
guard let timeObserver = _timeObserver else { return }
player?.removeTimeObserver(timeObserver)

View File

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

View File

@@ -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.

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 {
return player.observe(\.rate) { [weak self] player, change in
guard let self else { return }

View File

@@ -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<AVPlayerItem.Status>) {
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<Bool>) {
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) {}
}

View File

@@ -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