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

Commit

Permalink
Merge pull request #428 from clappr/fix/live_edge_button
Browse files Browse the repository at this point in the history
Adjust seek to live position on iOS 14
  • Loading branch information
VitorFerraz authored Feb 24, 2021
2 parents 6bff063 + 38a477d commit 959f026
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down

0 comments on commit 959f026

Please sign in to comment.