@@ -86,16 +86,18 @@ public struct VideoSplashScreenViewModifier<VideoPlayerView: View>: ViewModifier
8686private extension VideoSplashScreenViewModifier {
8787
8888 @ViewBuilder var playerView : some View {
89- videoPlayerView (
90- VideoPlayer (
91- videoURL: videoURL,
92- controllerConfiguration: { controller in
93- controller. showsPlaybackControls = false
94- } ,
95- didPlayToEndAction: dismissSplashScreen
89+ if let videoURL {
90+ videoPlayerView (
91+ VideoPlayer (
92+ videoURL: videoURL,
93+ controllerConfiguration: { controller in
94+ controller. showsPlaybackControls = false
95+ } ,
96+ didPlayToEndAction: dismissSplashScreen
97+ )
9698 )
97- )
98- . ignoresSafeArea ( )
99+ . ignoresSafeArea ( )
100+ }
99101 }
100102}
101103
@@ -139,43 +141,39 @@ public extension VideoSplashScreenConfiguration {
139141
140142public extension View {
141143
142- /// Apply a video splash screen that uses a plain ``VideoPlayer`` view.
144+ /// Apply a video splash screen that uses a plain ``VideoPlayer`` view
145+ /// and a standard configuration.
143146 ///
144147 /// The splash screen will be presented when the view is loaded and dismiss
145148 /// itself to reveal the underlying view once the video finishes playing.
146149 ///
147150 /// - Parameters:
148- /// - videoURL: The video URL to play.
149- /// - isEnabled: Whether the splash screen is enabled, by default `true`.
150- /// - configuration: The configuration to apply, by default ``VideoSplashScreenConfiguration/standard``.
151+ /// - videoURL: The video URL to play, if any.
151152 @ViewBuilder
152153 func videoSplashScreen( videoURL: URL ? ) -> some View {
153154 self . videoSplashScreen (
154155 videoURL: videoURL,
155- isEnabled: true ,
156156 configuration: nil ,
157157 videoPlayerView: { $0 }
158158 )
159159 }
160160
161- /// Apply a video splash screen that uses a plain ``VideoPlayer`` view.
161+ /// Apply a video splash screen that uses a plain ``VideoPlayer`` view
162+ /// and a custom configuration.
162163 ///
163164 /// The splash screen will be presented when the view is loaded and dismiss
164165 /// itself to reveal the underlying view once the video finishes playing.
165166 ///
166167 /// - Parameters:
167- /// - videoURL: The video URL to play.
168- /// - isEnabled: Whether the splash screen is enabled, by default `true`.
169- /// - configuration: The configuration to apply, by default ``VideoSplashScreenConfiguration/standard``.
168+ /// - videoURL: The video URL to play, if any.
169+ /// - configuration: The configuration to apply.
170170 @ViewBuilder
171171 func videoSplashScreen(
172172 videoURL: URL ? ,
173- isEnabled: Bool = true ,
174173 configuration: VideoSplashScreenConfiguration
175174 ) -> some View {
176175 self . videoSplashScreen (
177176 videoURL: videoURL,
178- isEnabled: isEnabled,
179177 configuration: configuration,
180178 videoPlayerView: { $0 }
181179 )
@@ -187,28 +185,22 @@ public extension View {
187185 /// itself to reveal the underlying view once the video finishes playing.
188186 ///
189187 /// - Parameters:
190- /// - videoURL: The video URL to play.
191- /// - isEnabled: Whether the splash screen is enabled, by default `true`.
188+ /// - videoURL: The video URL to play, if any.
192189 /// - configuration: The configuration to apply, by default ``VideoSplashScreenConfiguration/standard``.
193190 /// - videoPlayerView: A custom video player content builder.
194191 @ViewBuilder
195192 func videoSplashScreen< VideoPlayerView: View > (
196193 videoURL: URL ? ,
197- isEnabled: Bool = true ,
198194 configuration: VideoSplashScreenConfiguration ? = nil ,
199195 @ViewBuilder videoPlayerView: @escaping ( VideoPlayer ) -> VideoPlayerView
200196 ) -> some View {
201- if isEnabled {
202- self . modifier (
203- VideoSplashScreenViewModifier (
204- videoURL: videoURL,
205- configuration: configuration,
206- videoPlayerView: videoPlayerView
207- )
197+ self . modifier (
198+ VideoSplashScreenViewModifier (
199+ videoURL: videoURL,
200+ configuration: configuration,
201+ videoPlayerView: videoPlayerView
208202 )
209- } else {
210- self
211- }
203+ )
212204 }
213205}
214206
0 commit comments