diff --git a/Sources/Clappr/Classes/Plugin/Playback/AVFoundationPlayback.swift b/Sources/Clappr/Classes/Plugin/Playback/AVFoundationPlayback.swift index b76d817e9..b56bb548a 100644 --- a/Sources/Clappr/Classes/Plugin/Playback/AVFoundationPlayback.swift +++ b/Sources/Clappr/Classes/Plugin/Playback/AVFoundationPlayback.swift @@ -580,9 +580,13 @@ open class AVFoundationPlayback: Playback, AVPlayerItemInfoDelegate { } open override func seekToLivePosition() { - guard canSeek else { return } play() - seek(.infinity) + if canSeek, let liveCurrentSeekableTimeRange = player.currentItem?.seekableTimeRanges.last { + let livePosition = liveCurrentSeekableTimeRange.timeRangeValue.end.seconds + seek(livePosition) { [weak self] in + self?.triggerDvrStatusIfNeeded() + } + } } open override func mute(_ enabled: Bool) { diff --git a/Tests/Clappr_Tests/Classes/Plugin/Playback/AVFoundationPlaybackTests.swift b/Tests/Clappr_Tests/Classes/Plugin/Playback/AVFoundationPlaybackTests.swift index 6268c5e41..a382c8f98 100644 --- a/Tests/Clappr_Tests/Classes/Plugin/Playback/AVFoundationPlaybackTests.swift +++ b/Tests/Clappr_Tests/Classes/Plugin/Playback/AVFoundationPlaybackTests.swift @@ -1347,8 +1347,9 @@ class AVFoundationPlaybackTests: QuickSpec { } playback.seekToLivePosition() + let endPosition = playback.seekableTimeRanges.last?.timeRangeValue.end.seconds - expect(updatedPosition).to(equal(Double.infinity)) + expect(updatedPosition).to(equal(endPosition)) } }