@@ -156,18 +156,27 @@ internal extension ExtPlayerProtocol {
156
156
#endif
157
157
}
158
158
159
- /// Updates the player with a new asset and applies specified video settings.
160
- /// Initializes playback or performs a specified action once the asset is ready.
159
+ /// Updates the player with a new asset and applies the specified video settings.
161
160
///
162
- /// This method sets a new `AVURLAsset` to be played based on the provided settings.
163
- /// It can configure looping and muting options, and automatically starts playback if specified.
164
- /// A callback is executed when the asset transitions to the `.readyToPlay` status, allowing for
165
- /// further actions dependent on the readiness of the asset.
161
+ /// This method sets a new `AVURLAsset` for playback and configures it according to the provided settings.
162
+ /// It can adjust options such as playback gravity, looping, and muting. If `doUpdate` is `true`, the player is
163
+ /// updated immediately with the new asset. The method also provides an optional callback that is executed when
164
+ /// the asset transitions to the `.readyToPlay` status, enabling additional actions to be performed once the
165
+ /// player item is ready for playback.
166
166
///
167
167
/// - Parameters:
168
- /// - settings: A `VideoSettings` struct containing configurations such as playback gravity,
169
- /// whether to loop the content, and whether to mute the audio.
170
- func update( settings: VideoSettings , doUpdate : Bool = false ) {
168
+ /// - settings: A `VideoSettings` struct containing configurations such as playback gravity, looping behavior,
169
+ /// and whether the audio should be muted.
170
+ /// - doUpdate: A `Bool` value indicating whether the player should update immediately with the new asset.
171
+ /// Defaults to `false`, meaning the player will not change unless explicitly triggered.
172
+ /// - callback: An optional closure that takes an `AVPlayerItem` as its parameter. This is called when the
173
+ /// player item transitions to the `.readyToPlay` status, allowing for additional customization
174
+ /// or actions once the asset is prepared.
175
+ func update(
176
+ settings: VideoSettings ,
177
+ doUpdate : Bool = false ,
178
+ callback : ( ( AVPlayerItem ) -> Void ) ? = nil
179
+ ) {
171
180
172
181
if doUpdate == false && settings. isEqual ( currentSettings) {
173
182
return
@@ -181,6 +190,8 @@ internal extension ExtPlayerProtocol {
181
190
return
182
191
}
183
192
193
+ callback ? ( newItem)
194
+
184
195
insert ( newItem)
185
196
186
197
if settings. loop {
0 commit comments