Skip to content

Commit 13cb1d9

Browse files
authored
Merge pull request #164 from YoussefHachicha/issue-126-loop-not-smooth-on-ios
fix: loop no smooth on Ios player
2 parents b499fa7 + b64cc1c commit 13cb1d9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

mediaplayer/src/iosMain/kotlin/io/github/kdroidfilter/composemediaplayer/VideoPlayerState.ios.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,18 @@ open class DefaultVideoPlayerState: VideoPlayerState {
252252
queue = null
253253
) { _ ->
254254
if (_loop) {
255-
player.seekToTime(CMTimeMakeWithSeconds(0.0, 1))
256-
player.playImmediatelyAtRate(_playbackSpeed)
255+
val zeroTime = CMTimeMake(0, 1)
256+
player.seekToTime(
257+
time = CMTimeMakeWithSeconds(0.0, NSEC_PER_SEC.toInt()),
258+
toleranceBefore = zeroTime,
259+
toleranceAfter = zeroTime
260+
) { finished ->
261+
if (finished) {
262+
dispatch_async(dispatch_get_main_queue()) {
263+
player.playImmediatelyAtRate(_playbackSpeed)
264+
}
265+
}
266+
}
257267
} else {
258268
player.pause()
259269
_isPlaying = false

0 commit comments

Comments
 (0)