|
@@ -132,8 +132,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
make.edges.equalToSuperview()
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
} else {
|
|
|
cell.playView.setInputRotation(GPUImageRotationMode(rawValue: 0), at: 0)
|
|
|
progressThumV.isHidden = false
|
|
@@ -172,7 +170,17 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var isEndPlay = false
|
|
|
+ var isEndPlay = false {
|
|
|
+ didSet{
|
|
|
+ recordBtn.isHidden = (itemModels[currItemModelIndex].mediaType != .Video) ? false : true
|
|
|
+
|
|
|
+ subtitleBtn.isHidden = false
|
|
|
+ soundSettingBtn.isHidden = false
|
|
|
+
|
|
|
+ playBtn.isSelected = false
|
|
|
+ playBtn.isHidden = playBtn.isSelected
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public var isNormalPlaying = false { // 是否正在播放
|
|
|
didSet {
|
|
@@ -931,7 +939,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// 矫正进度
|
|
|
wself.resetCurrentProgress()
|
|
|
wself.deleteRecordBtn.isHidden = true
|
|
|
- wself.recordBtn.isHidden = (wself.itemModels[wself.currItemModelIndex ?? 0].mediaType != .Video && (wself.isEndPlay ?? false)) ? false : (wself.isEndPlay ?? false)
|
|
|
+ wself.recordBtn.isHidden = (wself.itemModels[wself.currItemModelIndex ].mediaType != .Video && (wself.isEndPlay )) ? false : (wself.isEndPlay ?? false)
|
|
|
}
|
|
|
wself.currentPlayRecordIndex = -3 // 刚录音完,不需要播放录音
|
|
|
BFLog(3, message: "重置播放index-\(#function) = \(wself.currentPlayRecordIndex)")
|
|
@@ -1275,7 +1283,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
@objc func endRecord() {
|
|
|
- pause()
|
|
|
+// pause()
|
|
|
// 存储录音
|
|
|
if !isRecording {
|
|
|
return
|
|
@@ -1823,20 +1831,26 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
// BFLog(1, message: "判断是否开始录音播放** hadPrepareToPlayRecord:\(hadPrepareToPlayRecord), currentPlayRecordIndex:\(currentPlayRecordIndex), isNormalPlaying :\(wself.isNormalPlaying),\(recordPlayer.currentItem?.duration.timescale ?? 0),\(CMTimeGetSeconds(currentT) >= recordedAudio.startCMTime.seconds),\(CMTimeGetSeconds(currentT) <= recordedAudio.endCMTime.seconds - 0.2)")
|
|
|
|
|
|
- if !hadPrepareToPlayRecord,
|
|
|
+ if !wself.hadPrepareToPlayRecord,
|
|
|
CMTimeGetSeconds(currentT) >= (recordedAudio.startCMTime.seconds - 0.1),
|
|
|
CMTimeGetSeconds(currentT) <= recordedAudio.endCMTime.seconds - 0.2 // 这个条件是避免录音结束后有小幅度回退导致播放最新录音
|
|
|
{
|
|
|
- if itemModels[currItemModelIndex].mediaType == .Video, recordPlayer.currentItem?.duration.timescale == 0 {
|
|
|
+ if wself.itemModels[wself.currItemModelIndex].mediaType == .Video, wself.recordPlayer.currentItem?.duration.timescale == 0 {
|
|
|
return
|
|
|
}
|
|
|
// 应当开始播放了
|
|
|
// 两个逻辑:如果在播,则跳过;如果暂停拖动到中间,则seek
|
|
|
- if currentPlayRecordIndex == -1, wself.isNormalPlaying {
|
|
|
+ if wself.currentPlayRecordIndex == -1, wself.isNormalPlaying {
|
|
|
let second = currentT - recordedAudio.startCMTime
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
+
|
|
|
+ guard let wself = self else { return }
|
|
|
+
|
|
|
wself.recordPlayer.seek(to: second, toleranceBefore: CMTime(value: 1, timescale: 1_000_000), toleranceAfter: CMTime(value: 1, timescale: 1_000_000), completionHandler: { [weak self] finished in
|
|
|
- if finished, wself.isNormalPlaying ?? false {
|
|
|
+
|
|
|
+ guard let wself = self else { return }
|
|
|
+
|
|
|
+ if finished, wself.isNormalPlaying {
|
|
|
wself.recordPlayer.play()
|
|
|
// wself.recordPlayer.volume = 1
|
|
|
// wself.assetPlayer.volume = wself.haveSpeakVolume ?? 0
|
|
@@ -1863,19 +1877,19 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
guard let wself = self, wself.isNormalPlaying else {
|
|
|
return
|
|
|
}
|
|
|
-// BFLog(1, message: "判断是否开始录音播放** hadPrepareToPlayRecord:\(hadPrepareToPlayRecord), currentPlayRecordIndex:\(currentPlayRecordIndex), isNormalPlaying :\(wself.isNormalPlaying),\(recordPlayer.currentItem?.duration.timescale ?? 0),\(CMTimeGetSeconds(currentT) >= recordedAudio.startCMTime.seconds),\(CMTimeGetSeconds(currentT) <= recordedAudio.endCMTime.seconds - 0.2)")
|
|
|
|
|
|
if CMTimeGetSeconds(currentT) >= (recordedAudio.startCMTime.seconds - 0.1),
|
|
|
- CMTimeCompare(currentT, recordedAudio.endCMTime) <= 0 // 这个条件是避免录音结束后有小幅度回退导致播放最新录音
|
|
|
- {
|
|
|
+ CMTimeCompare(currentT, recordedAudio.endCMTime) <= 0 {
|
|
|
// 应当开始播放了
|
|
|
// 两个逻辑:如果在播,则跳过;如果暂停拖动到中间,则seek
|
|
|
if wself.isNormalPlaying {
|
|
|
let second = currentT - recordedAudio.startCMTime
|
|
|
- wself.recordPlayer.seek(to: second, toleranceBefore: CMTime(seconds: 1, preferredTimescale: 1000), toleranceAfter: CMTime(seconds: 1, preferredTimescale: 1000), completionHandler: { isFinished in
|
|
|
+ wself.recordPlayer.seek(to: second, toleranceBefore: CMTime(seconds: 1, preferredTimescale: 1000), toleranceAfter: CMTime(seconds: 1, preferredTimescale: 1000), completionHandler: { [weak self] isFinished in
|
|
|
+ guard let wself = self else { return }
|
|
|
+
|
|
|
+ wself.recordPlayer.play()
|
|
|
})
|
|
|
- wself.recordPlayer.play()
|
|
|
- BFLog(3, message: "录音开始播放2, \(second), \(CMTimeGetSeconds(recordPlayer.currentItem?.duration ?? .zero)),index = \(currentPlayRecordIndex)")
|
|
|
+ BFLog(3, message: "录音开始播放2, \(second), \(CMTimeGetSeconds(recordPlayer.currentItem?.duration ?? .zero)),index = \(wself.currentPlayRecordIndex)")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2031,17 +2045,12 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
wself.isNormalPlaying = false
|
|
|
wself.isEndPlay = true
|
|
|
- wself.recordBtn.isHidden = (wself.itemModels[wself.currItemModelIndex].mediaType == .Image) ? false : true
|
|
|
|
|
|
- wself.subtitleBtn.isHidden = false
|
|
|
- wself.soundSettingBtn.isHidden = false
|
|
|
|
|
|
if wself.isRecording {
|
|
|
wself.endRecord()
|
|
|
cShowHUB(superView: nil, msg: "tips_full".BFLocale)
|
|
|
}
|
|
|
- wself.playBtn.isSelected = false
|
|
|
- wself.playBtn.isHidden = wself.playBtn.isSelected
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2146,7 +2155,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
guard let wself = self else { return }
|
|
|
|
|
|
- BFLog(message: "更新录音进度\(#function)- \(wself.currentAssetProgress.seconds ?? 0)")
|
|
|
+// BFLog(1,message: "更新进度- \(wself.currentAssetProgress.seconds)")
|
|
|
wself.progreddL.text = String(format: "%@", CMTimeGetSeconds(self!.currentAssetProgress).formatDurationToHMS())
|
|
|
}
|
|
|
BFLog(message: "progress = \(progress),currentAssetProgress = \(currentAssetProgress.seconds),materialDuraion = \(itemModels[currItemModelIndex].materialDuraion.seconds)")
|
|
@@ -2325,7 +2334,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
|
|
|
|
func endScrollItem(page: Int) {
|
|
|
BFLog(1, message: "endScrollItem")
|
|
|
- // 切换素材时先把录制状态切为不可用,延迟可点,避免在缩略图未加载出来时即可录制
|
|
|
+ // 切换素材时先把录制状态切为不可用,延迟可点,避免在缩略图未加载出来时即刻录制
|
|
|
currItemModelIndex = page
|
|
|
// 暂停
|
|
|
pause()
|
|
@@ -2353,7 +2362,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
|
wself.recordBtn.isEnabled = true
|
|
|
}
|
|
|
// 更新缩略图
|
|
|
- // progressThumV.isHidden = false
|
|
|
+ // progressThumV.isHidden = false
|
|
|
|
|
|
searchStopAtRecordRange()
|
|
|
// 切换要更新当前录制index,避免在录制完以后切换素材这种时候为-3会拦截
|