|
@@ -148,9 +148,13 @@ class INVideoExportController: BFBaseViewController {
|
|
|
let avplayer = AVPlayer()
|
|
|
avplayerTimeObserver = avplayer.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 100), queue: DispatchQueue.global()) { [weak self, weak avplayer] _ in
|
|
|
// 进度监控
|
|
|
- if let item = avplayer?.currentItem {
|
|
|
- DispatchQueue.main.async { [weak self] in
|
|
|
- self?.sliderView?.progress = CMTimeGetSeconds(item.currentTime()) / CMTimeGetSeconds(item.duration)
|
|
|
+ if let item = avplayer?.currentItem, !(self?.sliderView?.isDragingProgressSlder ?? false) {
|
|
|
+ DispatchQueue.main.async { [weak self, weak avplayer] in
|
|
|
+ if avplayer?.currentItem?.status != .readyToPlay {
|
|
|
+ self?.sliderView?.progress = 0
|
|
|
+ }else{
|
|
|
+ self?.sliderView?.progress = CMTimeGetSeconds(item.currentTime()) / CMTimeGetSeconds(item.duration)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} as? NSKeyValueObservation
|
|
@@ -360,7 +364,7 @@ class INVideoExportController: BFBaseViewController {
|
|
|
sliderView?.valueChangeBloc = { [weak self] sender in
|
|
|
let cmtime = CMTime(value: CMTimeValue(Float64(sender.value) * Float64(self?.avplayer.currentItem?.asset.duration.seconds ?? 0) * 1000.0), timescale: CMTimeScale(1000.0))
|
|
|
BFLog(message: "cmtime == \(cmtime),\(cmtime.seconds)")
|
|
|
- self?.avplayer.seek(to: cmtime)
|
|
|
+ self?.avplayer.seek(to: cmtime, toleranceBefore: CMTime(seconds: 1, preferredTimescale: 1000), toleranceAfter: CMTime(seconds: 1, preferredTimescale: 1000))
|
|
|
}
|
|
|
sliderView?.btnClickBloc = { [weak self] sender in
|
|
|
// 按钮点击
|
|
@@ -445,9 +449,13 @@ class INVideoExportController: BFBaseViewController {
|
|
|
if !hasExportAll {
|
|
|
exportNow()
|
|
|
} else {
|
|
|
+ avplayer.pause()
|
|
|
let item = AVPlayerItem(url: saveAllUlr)
|
|
|
avplayer.replaceCurrentItem(with: item)
|
|
|
- avplayer.play()
|
|
|
+ if let btn = sliderView?.viewWithTag(1) as? UIButton {
|
|
|
+ btn.isSelected = false
|
|
|
+ avplayer.play()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -461,9 +469,13 @@ class INVideoExportController: BFBaseViewController {
|
|
|
if !hasExportOnly {
|
|
|
exportNow()
|
|
|
} else {
|
|
|
+ avplayer.pause()
|
|
|
let item = AVPlayerItem(url: saveOnlyUlr)
|
|
|
avplayer.replaceCurrentItem(with: item)
|
|
|
- avplayer.play()
|
|
|
+ if let btn = sliderView?.viewWithTag(1) as? UIButton {
|
|
|
+ btn.isSelected = false
|
|
|
+ avplayer.play()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|