|
@@ -173,7 +173,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
btn.adjustsImageWhenHighlighted = false
|
|
|
btn.addTarget(self, action: #selector(startRecord), for: .touchDown)
|
|
|
btn.addTarget(self, action: #selector(endRecord), for: .touchUpInside)
|
|
|
-
|
|
|
+ btn.isEnabled = false
|
|
|
return btn
|
|
|
}()
|
|
|
|
|
@@ -401,6 +401,16 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
assetPlayer?.pause()
|
|
|
recordPlayer?.pause()
|
|
|
}
|
|
|
+
|
|
|
+ @objc func didBecomeActive(){
|
|
|
+ BFLog(message: "进入活跃状态")
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func willResignActive(){
|
|
|
+ BFLog(message: "进入非活跃状态")
|
|
|
+ endRecord()
|
|
|
+ }
|
|
|
|
|
|
override public func viewWillAppear(_ animated: Bool) {
|
|
|
super.viewWillAppear(animated)
|
|
@@ -417,6 +427,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
super.viewDidLoad()
|
|
|
_ = disablePopGesture()
|
|
|
|
|
|
+ //进入活跃状态
|
|
|
+ PQNotification.addObserver(self, selector: #selector(didBecomeActive), name: UIApplication.didBecomeActiveNotification, object: nil)
|
|
|
+
|
|
|
+ //进入非活跃状态
|
|
|
+ PQNotification.addObserver(self, selector: #selector(willResignActive), name: UIApplication.willResignActiveNotification, object: nil)
|
|
|
+
|
|
|
+
|
|
|
checkStatus()
|
|
|
// mdf by ak 切换外放和请求权限分开 否则会导致首次安装时不能执行切换操作
|
|
|
try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)
|
|
@@ -494,7 +511,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.append(newSubtitle)
|
|
|
}
|
|
|
}
|
|
|
- // 录音结束
|
|
|
+ // MARK: - 录音结束
|
|
|
recorderManager?.endRecordHandle = { [weak self] voideModel, _ in
|
|
|
if let sself = self, let model = voideModel, FileManager.default.fileExists(atPath: model.wavFilePath ?? "") {
|
|
|
// 加入到语音数组里
|
|
@@ -507,7 +524,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// 要删除的字幕
|
|
|
var deletedTitlesTemp = [(PQEditSubTitleModel, Int)]()
|
|
|
for (i, m) in sself.itemModels[sself.currItemModelIndex].voiceStickers.enumerated() {
|
|
|
- let originRange = CMTimeRange(start: m.startCMTime, end: CMTime(seconds: m.endCMTime.seconds - 0.001, preferredTimescale: 1000))
|
|
|
+ let originRange = CMTimeRange(start: m.startCMTime, end: CMTime(seconds: m.endCMTime.seconds - 0.02, preferredTimescale: 1000))
|
|
|
if CMTimeRangeGetIntersection(originRange, otherRange: newRange).duration.seconds > 0 {
|
|
|
deletedVoices.append((m, i))
|
|
|
deletedTitlesTemp += sself.deleteTitles(voiceModel: m)
|
|
@@ -854,6 +871,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
default:
|
|
|
+ BFLog(1, message: "pan default")
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -958,8 +976,11 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
if isDragingProgressSlder {
|
|
|
return
|
|
|
}
|
|
|
+ // 开始时间
|
|
|
+ let model = PQVoiceModel()
|
|
|
+ model.startCMTime = currentAssetProgress
|
|
|
isRecording = true
|
|
|
- progressThumV.progressView.isUserInteractionEnabled = false
|
|
|
+// progressThumV.progressView.isUserInteractionEnabled = false
|
|
|
collectionView.isScrollEnabled = false
|
|
|
// 开始录制时清除屏幕上的字幕
|
|
|
subtitleLabel.text = ""
|
|
@@ -972,16 +993,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
view.isUserInteractionEnabled = false
|
|
|
-
|
|
|
- let model = PQVoiceModel()
|
|
|
- // 开始时间
|
|
|
- model.startCMTime = currentAssetProgress
|
|
|
+
|
|
|
model.volume = 100
|
|
|
recorderManager?.voiceModel = model
|
|
|
recorderManager?.startRecord()
|
|
|
recorderManager?.audioRecorder?.startNeoNui(NeoNuiToken ?? "", appid: NeoNuiAPPID ?? "")
|
|
|
isRecording = true
|
|
|
-
|
|
|
+
|
|
|
if !avatarView.isHidden {
|
|
|
avatarView.beginRecord()
|
|
|
}
|
|
@@ -1009,7 +1027,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
return
|
|
|
}
|
|
|
isRecording = false
|
|
|
- progressThumV.progressView.isUserInteractionEnabled = true
|
|
|
+// progressThumV.progressView.isUserInteractionEnabled = true
|
|
|
collectionView.isScrollEnabled = true
|
|
|
|
|
|
view.isUserInteractionEnabled = true
|
|
@@ -1517,8 +1535,10 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
recordStartPlayTime = CMTime.zero
|
|
|
pauseTime = currentAssetProgress.seconds
|
|
|
|
|
|
- assetPlayer?.seek(to: currentAssetProgress, toleranceBefore: CMTime(value: 1, timescale: 1_000_000), toleranceAfter: CMTime(value: 1, timescale: 1_000_000), completionHandler: { _ in
|
|
|
- })
|
|
|
+ //
|
|
|
+// assetPlayer?.seek(to: currentAssetProgress, toleranceBefore: CMTime(value: 1, timescale: 1_000_000), toleranceAfter: CMTime(value: 1, timescale: 1_000_000), completionHandler: { _ in
|
|
|
+// cShowHUB(superView: nil, msg: "end seek: \(self.assetPlayer?.currentItem?.currentTime().seconds ?? 0)")
|
|
|
+// })
|
|
|
// 暂停状态
|
|
|
playBtn.isSelected = (itemModels[currItemModelIndex].mediaType == .IMAGE && itemModels[currItemModelIndex].voiceStickers.count <= 0)
|
|
|
}
|
|
@@ -1590,7 +1610,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
} else {
|
|
|
assetPlayer = AVPlayer(playerItem: item)
|
|
|
assetPlayer?.volume = noSpeakVolume
|
|
|
-
|
|
|
+ recordBtn.isEnabled = true
|
|
|
avplayerTimeObserver?.invalidate()
|
|
|
avplayerTimeObserver = assetPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 1000), queue: DispatchQueue.global()) { [weak self] time in
|
|
|
// 进度监控
|