Skip to content

Commit 8c21f97

Browse files
committed
Update PlayerView.swift
1 parent 3a9b80b commit 8c21f97

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/swiftui-loop-videoplayer/PlayerView.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,29 @@ public struct PlayerView: UIViewRepresentable {
2323

2424
/// A structure that defines how a layer displays a player’s visual content within the layer’s bounds
2525
public let videoGravity: AVLayerVideoGravity
26+
27+
/// Size of the error text Default : 17.0
28+
public let errorTextSize : CGFloat
2629

30+
2731
/// - Parameters:
2832
/// - resourceName: Name of the video to play
2933
/// - extention: Video extension
34+
/// - errorText: Error message text
35+
/// - videoGravity: A structure that defines how a layer displays a player’s visual content within the layer’s bounds
36+
/// - errorTextSize: Size of the error text Default : 17
3037
public init(
3138
resourceName: String,
3239
extention: String = "mp4",
3340
errorText : String = "Resource is not found",
34-
videoGravity: AVLayerVideoGravity = .resizeAspect
41+
videoGravity: AVLayerVideoGravity = .resizeAspect,
42+
errorTextSize : CGFloat = 17.0
3543
) {
3644
self.resourceName = resourceName
3745
self.extention = extention
3846
self.errorText = errorText
3947
self.videoGravity = videoGravity
48+
self.errorTextSize = errorTextSize
4049
}
4150

4251
/// Inherited from UIViewRepresentable
@@ -53,17 +62,23 @@ public struct PlayerView: UIViewRepresentable {
5362
}
5463
return view
5564
}
65+
66+
// MARK: - Private
5667

5768
/// - Returns: Error view
5869
private func errorTpl() -> ErrorMsgTextView{
5970
let textView = ErrorMsgTextView()
6071
textView.backgroundColor = .clear
6172
textView.text = errorText
6273
textView.textAlignment = .center
74+
textView.font = UIFont.systemFont(ofSize: errorTextSize)
6375
return textView
6476
}
6577
}
6678

79+
80+
// MARK: - Helpers
81+
6782
/// https://stackoverflow.com/questions/12591192/center-text-vertically-in-a-uitextview
6883
fileprivate class ErrorMsgTextView: UITextView {
6984

0 commit comments

Comments
 (0)