@@ -23,20 +23,29 @@ public struct PlayerView: UIViewRepresentable {
23
23
24
24
/// A structure that defines how a layer displays a player’s visual content within the layer’s bounds
25
25
public let videoGravity : AVLayerVideoGravity
26
+
27
+ /// Size of the error text Default : 17.0
28
+ public let errorTextSize : CGFloat
26
29
30
+
27
31
/// - Parameters:
28
32
/// - resourceName: Name of the video to play
29
33
/// - 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
30
37
public init (
31
38
resourceName: String ,
32
39
extention: String = " mp4 " ,
33
40
errorText : String = " Resource is not found " ,
34
- videoGravity: AVLayerVideoGravity = . resizeAspect
41
+ videoGravity: AVLayerVideoGravity = . resizeAspect,
42
+ errorTextSize : CGFloat = 17.0
35
43
) {
36
44
self . resourceName = resourceName
37
45
self . extention = extention
38
46
self . errorText = errorText
39
47
self . videoGravity = videoGravity
48
+ self . errorTextSize = errorTextSize
40
49
}
41
50
42
51
/// Inherited from UIViewRepresentable
@@ -53,17 +62,23 @@ public struct PlayerView: UIViewRepresentable {
53
62
}
54
63
return view
55
64
}
65
+
66
+ // MARK: - Private
56
67
57
68
/// - Returns: Error view
58
69
private func errorTpl( ) -> ErrorMsgTextView {
59
70
let textView = ErrorMsgTextView ( )
60
71
textView. backgroundColor = . clear
61
72
textView. text = errorText
62
73
textView. textAlignment = . center
74
+ textView. font = UIFont . systemFont ( ofSize: errorTextSize)
63
75
return textView
64
76
}
65
77
}
66
78
79
+
80
+ // MARK: - Helpers
81
+
67
82
/// https://stackoverflow.com/questions/12591192/center-text-vertically-in-a-uitextview
68
83
fileprivate class ErrorMsgTextView : UITextView {
69
84
0 commit comments