Skip to content

Commit 30a4c82

Browse files
committed
added comments
1 parent 210dd77 commit 30a4c82

27 files changed

+118
-41
lines changed

Sources/swiftui-loop-videoplayer/ExtVideoPlayer.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public struct ExtVideoPlayer: View{
102102

103103
// MARK: - API
104104

105+
/// The body property defines the view hierarchy for the user interface.
105106
public var body: some View {
106107

107108
LoopPlayerMultiPlatform(

Sources/swiftui-loop-videoplayer/enum/PlaybackCommand.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import CoreImage
1414
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
1515
public enum PlaybackCommand: Equatable {
1616

17+
/// The idle command to do nothing
1718
case idle
1819

1920
/// Command to play the video.

Sources/swiftui-loop-videoplayer/enum/Setting.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import AVKit
1515
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
1616
public enum Setting: Equatable, SettingsConvertible{
1717

18+
/// Converts the current setting to an array containing only this setting.
19+
/// - Returns: An array of `Setting` containing the single instance of this setting.
1820
public func asSettings() -> [Setting] {
1921
[self]
2022
}

Sources/swiftui-loop-videoplayer/enum/VPErrors.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ public enum VPErrors: Error, CustomStringConvertible, Sendable{
4444

4545
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
4646
extension VPErrors: Equatable {
47+
48+
/// Compares two `VPErrors` instances for equality based on specific error conditions.
49+
/// - Parameters:
50+
/// - lhs: The left-hand side `VPErrors` instance to compare.
51+
/// - rhs: The right-hand side `VPErrors` instance to compare.
52+
/// - Returns: A Boolean value indicating whether the two `VPErrors` instances are considered equal.
4753
public static func ==(lhs: VPErrors, rhs: VPErrors) -> Bool {
4854
switch (lhs, rhs) {
4955
case (.remoteVideoError(let a), .remoteVideoError(let b)):

Sources/swiftui-loop-videoplayer/ext+/CMTime+.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
import AVKit
1010
#endif
1111

12-
extension CMTime : SettingsConvertible{
12+
/// Extends `CMTime` to conform to the `SettingsConvertible` protocol.
13+
extension CMTime : SettingsConvertible {
14+
15+
/// Converts the `CMTime` instance into a settings array containing a time publishing setting.
16+
/// - Returns: An array of `Setting` with the `timePublishing` case initialized with this `CMTime` instance.
1317
public func asSettings() -> [Setting] {
1418
[.timePublishing(self)]
1519
}

Sources/swiftui-loop-videoplayer/ext+/URL+.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
import Foundation
99

10-
/// Validates a string as a well-formed HTTP or HTTPS URL and returns a URL object if valid.
11-
///
12-
/// - Parameter urlString: The string to validate as a URL.
13-
/// - Returns: An optional URL object if the string is a valid URL.
14-
/// - Throws: An error if the URL is not valid or cannot be created.
10+
1511
extension URL {
12+
13+
/// Validates a string as a well-formed HTTP or HTTPS URL and returns a URL object if valid.
14+
///
15+
/// - Parameter urlString: The string to validate as a URL.
16+
/// - Returns: An optional URL object if the string is a valid URL.
17+
/// - Throws: An error if the URL is not valid or cannot be created.
1618
static func validURLFromString(_ string: String) -> URL? {
1719
let pattern = "^(https?:\\/\\/)(([a-zA-Z0-9-]+\\.)*[a-zA-Z0-9-]+\\.[a-zA-Z]{2,})(:\\d{1,5})?(\\/[\\S]*)?$"
1820
let regex = try? NSRegularExpression(pattern: pattern, options: [])

Sources/swiftui-loop-videoplayer/protocol/helpers/SettingsConvertible.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
import Foundation
99

10-
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
10+
1111
/// Protocol for building blocks
12+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
1213
public protocol SettingsConvertible {
1314

1415
/// Fetch settings

Sources/swiftui-loop-videoplayer/protocol/player/AbstractPlayer.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import AVFoundation
1010
import CoreImage
1111
#endif
1212

13+
/// Defines an abstract player protocol to be implemented by player objects, ensuring main-thread safety and compatibility with specific OS versions.
14+
/// This protocol is designed for use with classes (reference types) only.
1315
@available(iOS 14, macOS 11, tvOS 14, *)
1416
@MainActor @preconcurrency
1517
public protocol AbstractPlayer: AnyObject {

Sources/swiftui-loop-videoplayer/protocol/player/LoopingPlayerProtocol.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ import AppKit
2121
public protocol LoopingPlayerProtocol: AbstractPlayer, LayerMakerProtocol{
2222

2323
#if canImport(UIKit)
24-
var layer : CALayer { get }
24+
/// Provides a non-optional `CALayer` for use within UIKit environments.
25+
var layer: CALayer { get }
2526
#elseif canImport(AppKit)
26-
var layer : CALayer? { get set }
27-
var wantsLayer : Bool { get set }
27+
/// Provides an optional `CALayer` which can be set, and a property to indicate if the layer is wanted, for use within AppKit environments.
28+
var layer: CALayer? { get set }
29+
var wantsLayer: Bool { get set }
2830
#endif
29-
30-
var playerLayer : AVPlayerLayer { get }
31+
32+
/// Provides a `AVPlayerLayer` specific to the player implementation, applicable across all platforms.
33+
var playerLayer: AVPlayerLayer { get }
3134

3235
/// An optional NSKeyValueObservation to monitor errors encountered by the video player.
3336
/// This observer should be configured to detect and handle errors from the AVQueuePlayer,

Sources/swiftui-loop-videoplayer/protocol/vector/ShapeLayerBuilderProtocol.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import QuartzCore
1818
@available(iOS 14, macOS 11, tvOS 14, *)
1919
public protocol ShapeLayerBuilderProtocol: Identifiable {
2020

21+
/// Unique identifier
2122
var id : UUID { get }
2223

2324
/// Builds a CAShapeLayer using specified geometry.

0 commit comments

Comments
 (0)