|
@@ -288,7 +288,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// 显示字幕
|
|
|
lazy var subtitleLabel: PQSubTitleLabel = {
|
|
|
let subtitleLabel = PQSubTitleLabel()
|
|
|
- subtitleLabel.tag = 100100
|
|
|
+ subtitleLabel.tag = 100_100
|
|
|
subtitleLabel.textAlignment = .center
|
|
|
subtitleLabel.numberOfLines = 0
|
|
|
subtitleLabel.lineBreakMode = .byWordWrapping
|
|
@@ -401,13 +401,12 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
assetPlayer?.pause()
|
|
|
recordPlayer?.pause()
|
|
|
}
|
|
|
-
|
|
|
- @objc func didBecomeActive(){
|
|
|
+
|
|
|
+ @objc func didBecomeActive() {
|
|
|
BFLog(message: "进入活跃状态")
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- @objc func willResignActive(){
|
|
|
+
|
|
|
+ @objc func willResignActive() {
|
|
|
BFLog(message: "进入非活跃状态")
|
|
|
endRecord()
|
|
|
}
|
|
@@ -427,13 +426,12 @@ 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)
|
|
@@ -478,7 +476,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
if URL(fileURLWithPath: audioFilePath ?? "b").deletingPathExtension().lastPathComponent.contains(URL(fileURLWithPath: self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").deletingPathExtension().lastPathComponent) {
|
|
|
newSubtitle.timelineIn = (self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0) + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
|
|
|
newSubtitle.timelineOut = (self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0) + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
|
|
|
-
|
|
|
+
|
|
|
if newSubtitle.timelineIn - 0.1 > (self?.recorderManager?.voiceModel?.endCMTime.seconds ?? 0) {
|
|
|
BFLog(1, message: "卡在录音尾巴上了1")
|
|
|
newSubtitle.timelineIn -= 0.1
|
|
@@ -489,13 +487,12 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}) {
|
|
|
newSubtitle.timelineIn = voice.startCMTime.seconds + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
|
|
|
newSubtitle.timelineOut = voice.startCMTime.seconds + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
|
|
|
-
|
|
|
- if newSubtitle.timelineIn - 0.1 > (voice.endCMTime.seconds ) {
|
|
|
+
|
|
|
+ if newSubtitle.timelineIn - 0.1 > voice.endCMTime.seconds {
|
|
|
BFLog(1, message: "卡在录音尾巴上了1")
|
|
|
newSubtitle.timelineIn -= 0.1
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
var showText = ((payload?["result"]) as? String) ?? ""
|
|
|
if showText.count > subtitleMaxlength {
|
|
@@ -511,7 +508,9 @@ 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 ?? "") {
|
|
|
// 加入到语音数组里
|
|
@@ -647,6 +646,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
bottomeView.addSubview(progreddL)
|
|
|
// view.addSubview(toolV)
|
|
|
bottomeView.addSubview(recordBtn)
|
|
|
+ if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
|
+ recordBtn.isEnabled = true
|
|
|
+ }
|
|
|
bottomeView.addSubview(deleteRecordBtn)
|
|
|
bottomeView.addSubview(withDrawBtn)
|
|
|
// bottomeView.addSubview(changeVoiceBtn)
|
|
@@ -872,7 +874,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
default:
|
|
|
BFLog(1, message: "pan default")
|
|
|
- break
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -985,7 +986,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// 开始录制时清除屏幕上的字幕
|
|
|
subtitleLabel.text = ""
|
|
|
subtitleLabel.backgroundColor = UIColor.clear
|
|
|
-
|
|
|
+
|
|
|
pause()
|
|
|
if recorderManager == nil {
|
|
|
BFLog(message: "录音机初始化错误!!!")
|
|
@@ -993,13 +994,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
view.isUserInteractionEnabled = false
|
|
|
-
|
|
|
+
|
|
|
model.volume = 100
|
|
|
recorderManager?.voiceModel = model
|
|
|
recorderManager?.startRecord()
|
|
|
recorderManager?.audioRecorder?.startNeoNui(NeoNuiToken ?? "", appid: NeoNuiAPPID ?? "")
|
|
|
isRecording = true
|
|
|
-
|
|
|
+
|
|
|
if !avatarView.isHidden {
|
|
|
avatarView.beginRecord()
|
|
|
}
|
|
@@ -1013,9 +1014,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
// 录制中不显示播放按钮
|
|
|
playBtn.isSelected = true
|
|
|
-
|
|
|
+
|
|
|
let cell = collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell
|
|
|
- if cell?.contentView.viewWithTag(100100)?.superview == nil {
|
|
|
+ if cell?.contentView.viewWithTag(100_100)?.superview == nil {
|
|
|
cell?.contentView.addSubview(subtitleLabel)
|
|
|
}
|
|
|
}
|
|
@@ -1914,6 +1915,8 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
|
if recordItem.mediaType == .VIDEO {
|
|
|
reloadMaterial()
|
|
|
assetPlayer?.seek(to: .zero, toleranceBefore: CMTime(value: 1, timescale: 1_000_000), toleranceAfter: CMTime(value: 1, timescale: 1_000_000))
|
|
|
+ } else {
|
|
|
+ recordBtn.isEnabled = true
|
|
|
}
|
|
|
if changeItemHandle != nil {
|
|
|
changeItemHandle!(page)
|
|
@@ -2001,6 +2004,9 @@ public extension BFRecordScreenController {
|
|
|
/// 重置进度
|
|
|
func resetCurrentProgress() {
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
+ if !(self?.isRecording ?? false), (self?.currentAssetProgress.seconds ?? 0) > (self?.itemModels[self?.currItemModelIndex ?? 0].materialDuraion ?? 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
BFLog(1, message: "更新录音进度\(#function)-\(self?.currentAssetProgress.seconds ?? 0)")
|
|
|
self?.progreddL.text = String(format: "%@", (self?.currentAssetProgress.seconds ?? 0).formatDurationToHMS())
|
|
|
self?.progressThumV.progress = (self?.currentAssetProgress.seconds ?? 0)
|