|
@@ -67,6 +67,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
var isNormalPlaying = false { // 是否正在播放
|
|
var isNormalPlaying = false { // 是否正在播放
|
|
didSet {
|
|
didSet {
|
|
playBtn.isSelected = isNormalPlaying
|
|
playBtn.isSelected = isNormalPlaying
|
|
|
|
+ withDrawBtn.isHidden = isNormalPlaying
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -496,7 +498,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
// 矫正进度
|
|
// 矫正进度
|
|
self?.resetCurrentProgress()
|
|
self?.resetCurrentProgress()
|
|
self?.deleteRecordBtn.isHidden = true
|
|
self?.deleteRecordBtn.isHidden = true
|
|
- self?.recordBtn.isHidden = false
|
|
|
|
|
|
+ self?.recordBtn.isHidden = self?.isEndPlay ?? false
|
|
}
|
|
}
|
|
sself.currentPlayRecordIndex = -3 // 刚录音完,不需要播放录音
|
|
sself.currentPlayRecordIndex = -3 // 刚录音完,不需要播放录音
|
|
// 重置录制开始时间
|
|
// 重置录制开始时间
|
|
@@ -1008,10 +1010,11 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
changeWithDrawBtnLayout(false)
|
|
changeWithDrawBtnLayout(false)
|
|
}
|
|
}
|
|
searchStopAtRecordRange()
|
|
searchStopAtRecordRange()
|
|
- // 重置进度条
|
|
|
|
- indirectionView?.resetAllSubViews(items: itemModels[currItemModelIndex].voiceStickers, percenWidth: progressThumV.thumbImageWidth / 2.0, totalDuration: itemModels[currItemModelIndex].materialDuraion)
|
|
|
|
|
|
+ let itemModel = itemModels[currItemModelIndex]
|
|
// 如果是图片需重置播放按钮
|
|
// 如果是图片需重置播放按钮
|
|
- if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
|
|
|
|
+ if itemModel.mediaType == .IMAGE {
|
|
|
|
+ // 重置进度条
|
|
|
|
+ indirectionView?.resetAllSubViews(items: itemModels[currItemModelIndex].voiceStickers, percenWidth: progressThumV.thumbImageWidth / 2.0, totalDuration: itemModels[currItemModelIndex].materialDuraion)
|
|
(collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = itemModels[currItemModelIndex].voiceStickers.count <= 0
|
|
(collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = itemModels[currItemModelIndex].voiceStickers.count <= 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1057,6 +1060,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
BFLog(1, message: "isDragingProgressSlder : \(isDragingProgressSlder)")
|
|
BFLog(1, message: "isDragingProgressSlder : \(isDragingProgressSlder)")
|
|
searchStopAtRecordRange(needAdsorb: true)
|
|
searchStopAtRecordRange(needAdsorb: true)
|
|
changeWithDrawBtnLayout(false)
|
|
changeWithDrawBtnLayout(false)
|
|
|
|
+ isEndPlay = (progress == 1)
|
|
}
|
|
}
|
|
|
|
|
|
// 是否吸附在录音首尾处
|
|
// 是否吸附在录音首尾处
|
|
@@ -1298,7 +1302,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
subtitleBtn.isHidden = false
|
|
subtitleBtn.isHidden = false
|
|
soundSettingBtn.isHidden = false
|
|
soundSettingBtn.isHidden = false
|
|
withDrawBtn.isHidden = false
|
|
withDrawBtn.isHidden = false
|
|
- recordBtn.isHidden = false
|
|
|
|
|
|
+ recordBtn.isHidden = isEndPlay
|
|
// movie?.cancelProcessing()
|
|
// movie?.cancelProcessing()
|
|
assetPlayer?.pause()
|
|
assetPlayer?.pause()
|
|
recordPlayer?.pause()
|
|
recordPlayer?.pause()
|
|
@@ -1395,16 +1399,10 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: assetPlayer?.currentItem, queue: .main) { [weak self] notify in
|
|
NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: assetPlayer?.currentItem, queue: .main) { [weak self] notify in
|
|
BFLog(1, message: "AVPlayerItemDidPlayToEndTime = \(notify)")
|
|
BFLog(1, message: "AVPlayerItemDidPlayToEndTime = \(notify)")
|
|
-// if (self?.currItemModelIndex ?? 0) < ((self?.itemModels.count ?? 0) - 1) {
|
|
|
|
-// self?.collectionView.setContentOffset(CGPoint(x: CGFloat((self?.currItemModelIndex ?? 0) + 1) * (self?.collectionView.frame.width ?? 0), y: 0), animated: true)
|
|
|
|
-// } else {
|
|
|
|
-// }
|
|
|
|
|
|
+
|
|
self?.isNormalPlaying = false
|
|
self?.isNormalPlaying = false
|
|
- // self?.assetPlayer?.seek(to: CMTime.zero)
|
|
|
|
- // self?.progressThumV.progress = 0
|
|
|
|
self?.isEndPlay = true
|
|
self?.isEndPlay = true
|
|
- // self?.currentPlayRecordIndex = -1
|
|
|
|
- self?.recordBtn.isHidden = true
|
|
|
|
|
|
+
|
|
if self?.isRecording ?? false {
|
|
if self?.isRecording ?? false {
|
|
self?.endRecord()
|
|
self?.endRecord()
|
|
cShowHUB(superView: nil, msg: "此视频已录制到头了哦")
|
|
cShowHUB(superView: nil, msg: "此视频已录制到头了哦")
|
|
@@ -1468,13 +1466,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
// 通过缩略图进度条控制播放进度
|
|
// 通过缩略图进度条控制播放进度
|
|
func changeProgress(isBack: Bool = false, progress: Float) {
|
|
func changeProgress(isBack: Bool = false, progress: Float) {
|
|
- // 偶现拖动过程回调中process为NaN情况
|
|
|
|
- guard !progress.isNaN else {
|
|
|
|
- return
|
|
|
|
|
|
+ var newProgress = progress
|
|
|
|
+ if progress.isNaN || progress.isInfinite {
|
|
|
|
+ newProgress = 0
|
|
}
|
|
}
|
|
if itemModels[currItemModelIndex].mediaType == .VIDEO {
|
|
if itemModels[currItemModelIndex].mediaType == .VIDEO {
|
|
if let duration = assetPlayer?.currentItem?.duration {
|
|
if let duration = assetPlayer?.currentItem?.duration {
|
|
- currentAssetProgress = CMTime(value: CMTimeValue(progress * Float(CMTimeGetSeconds(duration)) * 1000), timescale: 1000)
|
|
|
|
|
|
+ currentAssetProgress = CMTime(value: CMTimeValue(newProgress * Float(CMTimeGetSeconds(duration)) * 1000), timescale: 1000)
|
|
DispatchQueue.main.async { [weak self] in
|
|
DispatchQueue.main.async { [weak self] in
|
|
self!.progreddL.text = String(format: "%@", CMTimeGetSeconds(self!.currentAssetProgress).formatDurationToHMS())
|
|
self!.progreddL.text = String(format: "%@", CMTimeGetSeconds(self!.currentAssetProgress).formatDurationToHMS())
|
|
}
|
|
}
|
|
@@ -1593,7 +1591,19 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
|
|
|
|
public func collectionView(_: UICollectionView, didSelectItemAt _: IndexPath) {}
|
|
public func collectionView(_: UICollectionView, didSelectItemAt _: IndexPath) {}
|
|
|
|
|
|
- public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
|
|
|
|
|
+ public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
|
|
|
|
+ endScrollItem(scrollView)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
|
|
|
|
+ if !decelerate {
|
|
|
|
+ endScrollItem(scrollView)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func endScrollItem(_ scrollView: UIScrollView) {
|
|
|
|
+// public func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
|
|
|
+ BFLog(1, message: "滚动结束")
|
|
let page = Int((scrollView.contentOffset.x + scrollView.frame.width / 2) / scrollView.frame.width)
|
|
let page = Int((scrollView.contentOffset.x + scrollView.frame.width / 2) / scrollView.frame.width)
|
|
if page != currItemModelIndex {
|
|
if page != currItemModelIndex {
|
|
// 暂停
|
|
// 暂停
|