Skip to content
This repository was archived by the owner on Jan 16, 2023. It is now read-only.

Commit 959f026

Browse files
authored
Merge pull request #428 from clappr/fix/live_edge_button
Adjust seek to live position on iOS 14
2 parents 6bff063 + 38a477d commit 959f026

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Sources/Clappr/Classes/Plugin/Playback/AVFoundationPlayback.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,13 @@ open class AVFoundationPlayback: Playback, AVPlayerItemInfoDelegate {
580580
}
581581

582582
open override func seekToLivePosition() {
583-
guard canSeek else { return }
584583
play()
585-
seek(.infinity)
584+
if canSeek, let liveCurrentSeekableTimeRange = player.currentItem?.seekableTimeRanges.last {
585+
let livePosition = liveCurrentSeekableTimeRange.timeRangeValue.end.seconds
586+
seek(livePosition) { [weak self] in
587+
self?.triggerDvrStatusIfNeeded()
588+
}
589+
}
586590
}
587591

588592
open override func mute(_ enabled: Bool) {

Tests/Clappr_Tests/Classes/Plugin/Playback/AVFoundationPlaybackTests.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,9 @@ class AVFoundationPlaybackTests: QuickSpec {
13471347
}
13481348

13491349
playback.seekToLivePosition()
1350+
let endPosition = playback.seekableTimeRanges.last?.timeRangeValue.end.seconds
13501351

1351-
expect(updatedPosition).to(equal(Double.infinity))
1352+
expect(updatedPosition).to(equal(endPosition))
13521353
}
13531354
}
13541355

0 commit comments

Comments
 (0)