When I am trying to play the video I am getting this exception below.
*** Assertion failure in -[CustomSlider _setValue:minValue:maxValue:andSendAction:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3698.119.2/UISlider.m:1477
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to set a slider's minimumValue (0.000000) to be larger than the maximumValue (nan)'
libc++abi.dylib: terminating with uncaught exception of type NSException
This is my code:
This piece of code is working fine when I run on the iOS 13 devices but getting crash when I run this on the iOS 12.3.1 device.
SDK: iOS 13
Tool: XCode 11.3.1
Target Device: iPhone 6S Plus running iOS 12.3.1
func updateUIforPlayerItemStatus() {
guard let currentItem = player.currentItem else { return }
switch currentItem.status {
case .readyToPlay:
playPauseButton.isEnabled = true
guard player.currentItem!.duration >= CMTime.zero else {
return
}
let newDurationSeconds = Float(currentItem.duration.seconds)
let currentTime = Float(player.currentTime().seconds)
timeSlider.minimumValue = 0.0
timeSlider.maximumValue = newDurationSeconds
timeSlider.value = currentTime
timeSlider.isEnabled = true
durationLabel.isEnabled = true
durationLabel.text = createTimeString(time: newDurationSeconds)
player.playImmediately(atRate: playbackRate)
default:
playPauseButton.isEnabled = false
timeSlider.isEnabled = false
durationLabel.isEnabled = false
}
}