|
@@ -31,6 +31,17 @@ struct WithDrawModel {
|
|
|
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ 6个基础操作:
|
|
|
+ 1. 播放启停
|
|
|
+ 2. 撤销
|
|
|
+ 3. 录制启停
|
|
|
+ 4. 拖动
|
|
|
+ 5. 删除
|
|
|
+ 6. 切换素材
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
public class BFRecordScreenController: BFBaseViewController {
|
|
|
// add by ak 是否点击了导出操作用于显示变量进度,预览是当前段落,导出是全部段落。
|
|
|
public var isExportAction:Bool = false
|
|
@@ -188,7 +199,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
public var displayLink: CADisplayLink? // 图片素材播放控制
|
|
|
|
|
|
- var canInsertVideo = false
|
|
|
public var isRecording = false { // 是否正在录音
|
|
|
didSet {
|
|
|
withDrawBtn.isHidden = isRecording
|
|
@@ -225,7 +235,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
soundSettingBtn.isHidden = isNormalPlaying
|
|
|
voiceSettingBtn.isHidden = isNormalPlaying
|
|
|
withDrawBtn.isHidden = isNormalPlaying
|
|
|
- updateRecordBtnStatus(isNormalPlaying)
|
|
|
+ updateRecordBtnStatus(needHidden: isNormalPlaying)
|
|
|
cameraFlipBtn.isHidden = !(!isNormalPlaying && (currMediaType == .Camera) && !isDragingProgressSlder)
|
|
|
}
|
|
|
}
|
|
@@ -459,21 +469,18 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
lazy var cameraFlipBtn: UIButton = {
|
|
|
let btn = UIButton(type: .custom)
|
|
|
btn.setImage(imageInRecordScreenKit(by: "flip"), for: .normal)
|
|
|
-// btn.setTitle("function_cameraFlip".BFLocale, for: .normal)
|
|
|
btn.titleLabel?.font = UIFont.systemFont(ofSize: 10)
|
|
|
btn.addTarget(self, action: #selector(cameraFlipAction), for: .touchUpInside)
|
|
|
- btn.imageEdgeInsets = UIEdgeInsets(top: -20, left: 4, bottom: 0, right: -4)
|
|
|
- btn.titleEdgeInsets = UIEdgeInsets(top: 20, left: -40, bottom: -20, right: 0)
|
|
|
return btn
|
|
|
}()
|
|
|
|
|
|
-
|
|
|
// 字幕设置面板
|
|
|
lazy var subtitleSettingView: BFSubtitleSettingView = {
|
|
|
let subtitleSetting = BFSubtitleSettingView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
|
subtitleSetting.isHidden = true
|
|
|
return subtitleSetting
|
|
|
}()
|
|
|
+
|
|
|
//变音设置面板
|
|
|
lazy var voiceSettingView: BFVoiceSettingView = {
|
|
|
let voiceSettingView = BFVoiceSettingView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
@@ -1154,7 +1161,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
wself.updatePlayBtnStatus()
|
|
|
|
|
|
// 更新录音按钮状态
|
|
|
- wself.updateRecordBtnStatus(false)
|
|
|
+ wself.updateRecordBtnStatus(needHidden: false)
|
|
|
|
|
|
// 录音完,更新撤销按钮
|
|
|
wself.changeWithDrawBtnLayout(2)
|
|
@@ -1389,13 +1396,18 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
@objc func doubleTapAction(tap:UITapGestureRecognizer) {
|
|
|
- if currMediaType == .Camera {
|
|
|
- rscmanager.cameraFlip()
|
|
|
+ if !(bottomeView.bounds.contains(tap.location(in: bottomeView))
|
|
|
+ || navHeadImageView!.bounds.contains(tap.location(in: navHeadImageView!))
|
|
|
+ || !voiceSettingView.isHidden
|
|
|
+ || !subtitleSettingView.isHidden
|
|
|
+ || !audioSettingView.isHidden
|
|
|
+ || recordBtn.isHidden){
|
|
|
+ cameraFlipAction()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @objc func cameraFlipAction(){
|
|
|
- if currMediaType == .Camera {
|
|
|
+ @objc func cameraFlipAction() {
|
|
|
+ if currMediaType == .Camera && !recordBtn.isHidden {
|
|
|
rscmanager.cameraFlip()
|
|
|
}
|
|
|
}
|
|
@@ -1635,11 +1647,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
@objc func withdrawAction() {
|
|
|
pause()
|
|
|
recoverRecord()
|
|
|
- }
|
|
|
-
|
|
|
- @objc func changeVoiceAction() {
|
|
|
- // nextActionHandle?()
|
|
|
- pause()
|
|
|
+ searchStopAtRecordRange()
|
|
|
}
|
|
|
|
|
|
@objc func playbtnDown(btn:UIButton){
|
|
@@ -1726,13 +1734,15 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
// MARK: - 逻辑处理
|
|
|
- // 是否吸附在录音首尾处
|
|
|
+
|
|
|
+ /// 进度指针静止后的按钮状态判断
|
|
|
+ /// - Parameter needAdsorb: 是否会吸附在节点
|
|
|
func searchStopAtRecordRange(needAdsorb: Bool = false) {
|
|
|
// TODO: 滑动,播放暂停,撤销时,判断是否停止录音区间,是则删除相关录音,画笔,头像,字幕
|
|
|
|
|
|
var startTime: CMTime?
|
|
|
var endTime: CMTime?
|
|
|
- canInsertVideo = false
|
|
|
+ var canInsertVideo = false
|
|
|
isStopAtRecordRange = -1
|
|
|
|
|
|
isEndPlay = (CMTimeCompare(currentAssetProgress, rscurrentManager.recordItem?.materialDuraion ?? .zero) >= 0)
|
|
@@ -1759,32 +1769,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
if startTime != nil && endTime != nil {
|
|
|
// TODO: 停在了录音区间,显示删除按钮
|
|
|
-// if needAdsorb {
|
|
|
-// if fabs((endTime! - currentAssetProgress).seconds) < 0.5 {
|
|
|
-// BFLog(1, message: "吸附在录音结尾, \(endTime!.seconds)")
|
|
|
-// // changeWithDrawBtnLayout(false)
|
|
|
-// changeProgress(changCMTime: endTime!)
|
|
|
-// progressThumV.progress = endTime!.seconds
|
|
|
-//
|
|
|
-// searchStopAtRecordRange(needAdsorb: false)
|
|
|
-// return
|
|
|
-// } else {
|
|
|
-// if fabs((startTime! - currentAssetProgress).seconds) < 0.5 {
|
|
|
-// BFLog(1, message: "吸附在录音开始")
|
|
|
-// // changeWithDrawBtnLayout(true)
|
|
|
-// changeProgress(changCMTime: startTime!)
|
|
|
-// progressThumV.progress = startTime!.seconds
|
|
|
-// }
|
|
|
-// deleteRecordBtn.isHidden = false
|
|
|
-// recordBtn.isHidden = true
|
|
|
-// // add by ak 这里 isHidden 无效
|
|
|
-//
|
|
|
-// BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange), currTime:\(currentAssetProgress.seconds), 录音范围:\(startTime!.seconds) - \(endTime!.seconds)")
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-
|
|
|
BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange), currTime:\(currentAssetProgress.seconds), 录音范围:\(startTime!.seconds) - \(endTime!.seconds)")
|
|
|
-// }
|
|
|
+
|
|
|
// 摄像和图片都可以走插入录制功能
|
|
|
if (currMediaType == .Camera && (endTime! - currentAssetProgress).seconds < 2 * 5 / 70.0)
|
|
|
|| (currMediaType == .Image && ((endTime! - currentAssetProgress).seconds < 2 * 2.0 / 70.0))
|
|
@@ -1796,16 +1782,16 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
BFLog(1, message: "可以插入录音")
|
|
|
}
|
|
|
- updateRecordBtnStatus(true)
|
|
|
|
|
|
} else {
|
|
|
- updateRecordBtnStatus(false)
|
|
|
+ canInsertVideo = true
|
|
|
|
|
|
-
|
|
|
isStopAtRecordRange = -1
|
|
|
BFLog(1, message: "停在了录音区间外 \(isStopAtRecordRange), currTime:\(currentAssetProgress.seconds)")
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ updateRecordBtnStatus(needHidden: !canInsertVideo)
|
|
|
|
|
|
updatePlayBtnStatus()
|
|
|
}
|
|
@@ -1828,16 +1814,15 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
/// 更新录音按钮状态
|
|
|
/// - Parameter hidden: 是否隐藏
|
|
|
- func updateRecordBtnStatus(_ hidden:Bool? = nil){
|
|
|
- let su = hidden ?? false
|
|
|
+ func updateRecordBtnStatus(needHidden:Bool? = nil){
|
|
|
+ let su = needHidden ?? false
|
|
|
switch currMediaType {
|
|
|
case .Image:
|
|
|
- recordBtn.isHidden = (isEndPlay || canInsertVideo) ? false : su
|
|
|
+ recordBtn.isHidden = isEndPlay ? false : su
|
|
|
case .Video:
|
|
|
recordBtn.isHidden = isEndPlay ? true : su
|
|
|
case .Camera:
|
|
|
- recordBtn.isHidden = (isEndPlay || canInsertVideo) ? false : su
|
|
|
- cameraFlipBtn.isHidden = recordBtn.isHidden
|
|
|
+ recordBtn.isHidden = isEndPlay ? false : su
|
|
|
}
|
|
|
|
|
|
deleteRecordBtn.isHidden = isEndPlay ? true : !(recordBtn.isHidden)
|