Skip to content

Commit 7c90403

Browse files
committed
added new settings
1 parent 7531a2d commit 7c90403

File tree

6 files changed

+38
-0
lines changed

6 files changed

+38
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Please note that using videos from URLs requires ensuring that you have the righ
4646
| **Loop** | Whether the video should automatically restart when it reaches the end. If not explicitly passed, the video will not loop. | - |
4747
| **EColor** | Error message text color. | .red |
4848
| **EFontSize** | Size of the error text. | 17.0 |
49+
| **ErrorWidgetOff** | Do not show inner error showcase component. In case you'd like to implement your own error Alert widget' | false |
4950

5051
*Additional Notes on Settings*
5152

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

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public enum Setting: Equatable, SettingsConvertible{
1919
[self]
2020
}
2121

22+
/// Loop video
2223
case loop
2324

2425
/// File name
@@ -43,6 +44,9 @@ public enum Setting: Equatable, SettingsConvertible{
4344
/// Color of the error text
4445
case errorColor(Color)
4546

47+
/// Do not show inner error showcase component
48+
case errorWidgetOff
49+
4650
/// Case name
4751
var caseName: String {
4852
Mirror(reflecting: self).children.first?.label ?? "\(self)"

Sources/swiftui-loop-videoplayer/protocol/view/LoopPlayerViewProtocol.swift

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public extension LoopPlayerViewProtocol{
6969
/// - error: The optional error which, if present, triggers the creation and addition of an error-specific view.
7070
@MainActor
7171
func makeErrorView(_ view: View, error: VPErrors?) {
72+
73+
/// Check if error widget is off in settings
74+
guard settings.errorWidgetOff == false else{ return }
75+
7276
if let error = error {
7377
let errorView = errorTpl(error, settings.errorColor, settings.errorFontSize)
7478
view.addSubview(errorView)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// ErrorWidgetOff.swift
3+
//
4+
//
5+
// Created by Igor on 04.09.24.
6+
//
7+
8+
import Foundation
9+
10+
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
11+
public struct ErrorWidgetOff: SettingsConvertible{
12+
13+
// MARK: - Life circle
14+
15+
public init() {}
16+
17+
/// Fetch settings
18+
@_spi(Private)
19+
public func asSettings() -> [Setting] {
20+
[.errorWidgetOff]
21+
}
22+
}

Sources/swiftui-loop-videoplayer/utils/VideoSettings.swift

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public struct VideoSettings: Equatable{
1919
/// Video extension
2020
public let ext: String
2121

22+
/// Loop video
2223
public let loop: Bool
2324

2425
/// A CMTime value representing the interval at which the player's current time should be published.
@@ -33,6 +34,9 @@ public struct VideoSettings: Equatable{
3334

3435
/// Size of the error text Default : 17.0
3536
public let errorFontSize : CGFloat
37+
38+
/// Do not show inner error showcase component
39+
public let errorWidgetOff: Bool
3640

3741
/// Are the params unique
3842
public var areUnique : Bool {
@@ -65,6 +69,8 @@ public struct VideoSettings: Equatable{
6569
timePublishing = settings.fetch(by : "timePublishing", defaulted: nil)
6670

6771
loop = settings.contains(.loop)
72+
73+
errorWidgetOff = settings.contains(.errorWidgetOff)
6874
}
6975
}
7076

Sources/swiftui-loop-videoplayer/view/main/LoopPlayerMultiPlatform.swift

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ extension LoopPlayerMultiPlatform: NSViewRepresentable{
150150
player.delegate = context.coordinator
151151
}
152152

153+
153154
makeErrorView(container, error: error)
154155

155156
return container

0 commit comments

Comments
 (0)