|
@@ -31,6 +31,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
public var recordRndHandle: ((_ currentRecord: PQVoiceModel?) -> Void)?
|
|
public var recordRndHandle: ((_ currentRecord: PQVoiceModel?) -> Void)?
|
|
// 字幕按钮点击上报
|
|
// 字幕按钮点击上报
|
|
public var subTitleBtnClickHandle: ((_ isOn: Bool) -> Void)?
|
|
public var subTitleBtnClickHandle: ((_ isOn: Bool) -> Void)?
|
|
|
|
+
|
|
// MARK: - 录制参数
|
|
// MARK: - 录制参数
|
|
|
|
|
|
public var assets = [PHAsset]()
|
|
public var assets = [PHAsset]()
|
|
@@ -98,12 +99,11 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
AVEncoderBitDepthHintKey: 16, // 位深
|
|
AVEncoderBitDepthHintKey: 16, // 位深
|
|
AVEncoderAudioQualityKey: AVAudioQuality.medium.rawValue] // 音频质量
|
|
AVEncoderAudioQualityKey: AVAudioQuality.medium.rawValue] // 音频质量
|
|
|
|
|
|
- public var haveSpeakVolume : Float = 0.0
|
|
|
|
- public var noSpeakVolume : Float = 1.0
|
|
|
|
-
|
|
|
|
- //录音管理器
|
|
|
|
- var recorderManager : BFVoiceRecordManager?
|
|
|
|
-
|
|
|
|
|
|
+ public var haveSpeakVolume: Float = 0.0
|
|
|
|
+ public var noSpeakVolume: Float = 1.0
|
|
|
|
+
|
|
|
|
+ // 录音管理器
|
|
|
|
+ var recorderManager: BFVoiceRecordManager?
|
|
|
|
|
|
// MARK: - 视图参数
|
|
// MARK: - 视图参数
|
|
|
|
|
|
@@ -293,7 +293,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
return audioSettingView
|
|
return audioSettingView
|
|
}()
|
|
}()
|
|
|
|
|
|
-
|
|
|
|
lazy var progressThumV: BFVideoThumbProgressView = {
|
|
lazy var progressThumV: BFVideoThumbProgressView = {
|
|
let vv = BFVideoThumbProgressView(frame: CGRect(x: 0, y: 54, width: cScreenWidth, height: 50))
|
|
let vv = BFVideoThumbProgressView(frame: CGRect(x: 0, y: 54, width: cScreenWidth, height: 50))
|
|
vv.dragStartHandle = { [weak self] in
|
|
vv.dragStartHandle = { [weak self] in
|
|
@@ -386,20 +385,20 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
BFRecordScreenViewModel.getNlsAccessToken { [weak self] token, appkey in
|
|
BFRecordScreenViewModel.getNlsAccessToken { [weak self] token, appkey in
|
|
BFLog(message: "nls appkey is \(appkey), token is \(token)")
|
|
BFLog(message: "nls appkey is \(appkey), token is \(token)")
|
|
|
|
|
|
- self?.recorderManager = BFVoiceRecordManager.init(token: token, appid: appkey)
|
|
|
|
-
|
|
|
|
- //录音取消
|
|
|
|
|
|
+ self?.recorderManager = BFVoiceRecordManager(token: token, appid: appkey)
|
|
|
|
+
|
|
|
|
+ // 录音取消
|
|
self?.recorderManager?.cancelRecordHandle = { _ in
|
|
self?.recorderManager?.cancelRecordHandle = { _ in
|
|
}
|
|
}
|
|
- //录音进度
|
|
|
|
- self?.recorderManager?.recorderProgrossHandle = {[weak self] progress in
|
|
|
|
- BFLog(1, message: "curr:录音进度--\(progress) \(self?.recordStartTime ) \(self?.isRecording)")
|
|
|
|
- self?.drawProgressIndication(progress:progress ?? 0)
|
|
|
|
|
|
+ // 录音进度
|
|
|
|
+ self?.recorderManager?.recorderProgrossHandle = { [weak self] progress in
|
|
|
|
+ BFLog(1, message: "curr:录音进度--\(progress) \(self?.recordStartTime) \(self?.isRecording)")
|
|
|
|
+ self?.drawProgressIndication(progress: progress ?? 0)
|
|
}
|
|
}
|
|
-
|
|
|
|
- //录音字幕回调
|
|
|
|
- self?.recorderManager?.subtitleRecordHandle = {[weak self] asrResult in
|
|
|
|
- if(asrResult == nil){
|
|
|
|
|
|
+
|
|
|
|
+ // 录音字幕回调
|
|
|
|
+ self?.recorderManager?.subtitleRecordHandle = { [weak self] asrResult in
|
|
|
|
+ if asrResult == nil {
|
|
BFLog(message: "识别结果为空????不能生成字幕数据")
|
|
BFLog(message: "识别结果为空????不能生成字幕数据")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -407,16 +406,15 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
let payload = dicResult?["payload"] as? [String: Any]
|
|
let payload = dicResult?["payload"] as? [String: Any]
|
|
|
|
|
|
-
|
|
|
|
BFLog(message: "识别结果:) \((payload?["result"])!) startTime:\(self?.recorderManager?.voiceModel?.startTime ?? 0.0)")
|
|
BFLog(message: "识别结果:) \((payload?["result"])!) startTime:\(self?.recorderManager?.voiceModel?.startTime ?? 0.0)")
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
// 1,保存字幕数据 begin_time是开始出现文字的时间,time 是结束文字出现的时间 单位都为毫秒,都是相对于录制音频数据整段时间。self.recorderManager.voiceModel?.startTime 为开始的录制的时间,开始和结束都要加上这个时差
|
|
// 1,保存字幕数据 begin_time是开始出现文字的时间,time 是结束文字出现的时间 单位都为毫秒,都是相对于录制音频数据整段时间。self.recorderManager.voiceModel?.startTime 为开始的录制的时间,开始和结束都要加上这个时差
|
|
|
|
|
|
let newSubtitle = PQEditSubTitleModel()
|
|
let newSubtitle = PQEditSubTitleModel()
|
|
-
|
|
|
|
- //这里加300ms 是因为返回结果为了切到字,时长提前一些时间,具体时间官方没说和原音频有关系。这里我们先延后300ms 单位:毫秒。
|
|
|
|
|
|
+
|
|
|
|
+ // 这里加300ms 是因为返回结果为了切到字,时长提前一些时间,具体时间官方没说和原音频有关系。这里我们先延后300ms 单位:毫秒。
|
|
newSubtitle.timelineIn = (self?.recorderManager?.voiceModel?.startTime ?? 0.0) + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
|
|
newSubtitle.timelineIn = (self?.recorderManager?.voiceModel?.startTime ?? 0.0) + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
|
|
-
|
|
|
|
|
|
+
|
|
newSubtitle.timelineOut = (self?.recorderManager?.voiceModel?.startTime ?? 0.0) + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
|
|
newSubtitle.timelineOut = (self?.recorderManager?.voiceModel?.startTime ?? 0.0) + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
|
|
var showText = ((payload?["result"]) as? String) ?? ""
|
|
var showText = ((payload?["result"]) as? String) ?? ""
|
|
if showText.count > subtitleMaxlength {
|
|
if showText.count > subtitleMaxlength {
|
|
@@ -430,9 +428,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.append(newSubtitle)
|
|
self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.append(newSubtitle)
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
- //录音结束
|
|
|
|
|
|
+ // 录音结束
|
|
self?.recorderManager?.endRecordHandle = { [weak self] voideModel, _ in
|
|
self?.recorderManager?.endRecordHandle = { [weak self] voideModel, _ in
|
|
if let sself = self, let model = voideModel, FileManager.default.fileExists(atPath: model.wavFilePath ?? "") {
|
|
if let sself = self, let model = voideModel, FileManager.default.fileExists(atPath: model.wavFilePath ?? "") {
|
|
// 加入到语音数组里
|
|
// 加入到语音数组里
|
|
@@ -455,7 +452,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
return CMTimeRangeGetIntersection(originRange, otherRange: newRange).duration.seconds > 0
|
|
return CMTimeRangeGetIntersection(originRange, otherRange: newRange).duration.seconds > 0
|
|
}
|
|
}
|
|
BFLog(1, message: "添加录音文件:\(model.startTime) -- \(model.endTime)")
|
|
BFLog(1, message: "添加录音文件:\(model.startTime) -- \(model.endTime)")
|
|
-
|
|
|
|
|
|
+
|
|
var event = sself.events.last
|
|
var event = sself.events.last
|
|
if event != nil {
|
|
if event != nil {
|
|
event!.deletedVoices = deletedVoices
|
|
event!.deletedVoices = deletedVoices
|
|
@@ -473,7 +470,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
model.endTime = sself.currentAssetProgress.seconds
|
|
model.endTime = sself.currentAssetProgress.seconds
|
|
self?.isEndPlay = true
|
|
self?.isEndPlay = true
|
|
}
|
|
}
|
|
- DispatchQueue.main.async {[weak self] in
|
|
|
|
|
|
+ DispatchQueue.main.async { [weak self] in
|
|
// 录音完,重绘撤销按钮,更新录音按钮,
|
|
// 录音完,重绘撤销按钮,更新录音按钮,
|
|
self?.changeWithDrawBtnLayout(true)
|
|
self?.changeWithDrawBtnLayout(true)
|
|
// 注:在录制结束时矫正当前位置,避免跟指针无法对其
|
|
// 注:在录制结束时矫正当前位置,避免跟指针无法对其
|
|
@@ -486,6 +483,16 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
sself.recordStartTime = 0
|
|
sself.recordStartTime = 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ self?.recorderManager?.cancelRecordHandle = { [weak self] _ in
|
|
|
|
+ // 取消录制以后重置进度
|
|
|
|
+ self?.withdrawAction()
|
|
|
|
+ // 重置录制开始时间
|
|
|
|
+ self?.recordStartTime = 0
|
|
|
|
+ /// 重置进度
|
|
|
|
+ self?.resetCurrentProgress()
|
|
|
|
+ // 移除
|
|
|
|
+ self?.indirectionView?.deleteItem(isCurrent: true)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
view.backgroundColor = .black
|
|
view.backgroundColor = .black
|
|
@@ -517,8 +524,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)
|
|
try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
avatarView.recordEndCallBack = { _, materialsModel in
|
|
avatarView.recordEndCallBack = { _, materialsModel in
|
|
BFLog(message: "新录制完成::::\(materialsModel?.locationPath ?? "")")
|
|
BFLog(message: "新录制完成::::\(materialsModel?.locationPath ?? "")")
|
|
}
|
|
}
|
|
@@ -573,7 +578,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
/// 更新字幕,在回放时使用
|
|
/// 更新字幕,在回放时使用
|
|
/// - Parameter time: 当前播放的进度
|
|
/// - Parameter time: 当前播放的进度
|
|
func updateSubtitle(time: CMTime) {
|
|
func updateSubtitle(time: CMTime) {
|
|
-
|
|
|
|
BFLog(message: "currTime is \(CMTimeGetSeconds(time))")
|
|
BFLog(message: "currTime is \(CMTimeGetSeconds(time))")
|
|
var findShowSubtitle: PQEditSubTitleModel?
|
|
var findShowSubtitle: PQEditSubTitleModel?
|
|
for (index, subtitle) in itemModels[currItemModelIndex].titleStickers.enumerated() {
|
|
for (index, subtitle) in itemModels[currItemModelIndex].titleStickers.enumerated() {
|
|
@@ -812,12 +816,11 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
pause()
|
|
pause()
|
|
isRecording = true
|
|
isRecording = true
|
|
|
|
|
|
- if(self.recorderManager == nil){
|
|
|
|
|
|
+ if recorderManager == nil {
|
|
BFLog(message: "录音机初始化错误!!!")
|
|
BFLog(message: "录音机初始化错误!!!")
|
|
return
|
|
return
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
let model = PQVoiceModel()
|
|
let model = PQVoiceModel()
|
|
// 开始时间
|
|
// 开始时间
|
|
model.startTime = currentAssetProgress.seconds
|
|
model.startTime = currentAssetProgress.seconds
|
|
@@ -832,7 +835,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
isRecording = true
|
|
isRecording = true
|
|
|
|
|
|
-
|
|
|
|
if !avatarView.isHidden {
|
|
if !avatarView.isHidden {
|
|
avatarView.beginRecord()
|
|
avatarView.beginRecord()
|
|
}
|
|
}
|
|
@@ -851,7 +853,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
|
|
|
|
@objc func endRecord() {
|
|
@objc func endRecord() {
|
|
-
|
|
|
|
// 存储录音
|
|
// 存储录音
|
|
isRecording = false
|
|
isRecording = false
|
|
pause()
|
|
pause()
|
|
@@ -901,7 +902,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
jumpTime = model.startTime
|
|
jumpTime = model.startTime
|
|
-
|
|
|
|
|
|
+
|
|
if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
itemModels[currItemModelIndex].materialDuraion = jumpTime
|
|
itemModels[currItemModelIndex].materialDuraion = jumpTime
|
|
}
|
|
}
|
|
@@ -930,7 +931,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
} else {}
|
|
} else {}
|
|
events.removeLast()
|
|
events.removeLast()
|
|
-
|
|
|
|
|
|
+
|
|
let dur = itemModels[currItemModelIndex].materialDuraion
|
|
let dur = itemModels[currItemModelIndex].materialDuraion
|
|
if dur > 0 {
|
|
if dur > 0 {
|
|
changeProgress(progress: Float(jumpTime / dur))
|
|
changeProgress(progress: Float(jumpTime / dur))
|
|
@@ -992,7 +993,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
|
|
|
|
// 是否吸附在录音首尾处
|
|
// 是否吸附在录音首尾处
|
|
- func searchStopAtRecordRange(needAdsorb:Bool = false) {
|
|
|
|
|
|
+ func searchStopAtRecordRange(needAdsorb: Bool = false) {
|
|
pauseTime = currentAssetProgress.seconds
|
|
pauseTime = currentAssetProgress.seconds
|
|
|
|
|
|
// TODO: 滑动,播放暂停,撤销时,判断是否停止录音区间,是则删除相关录音,画笔,头像,字幕
|
|
// TODO: 滑动,播放暂停,撤销时,判断是否停止录音区间,是则删除相关录音,画笔,头像,字幕
|
|
@@ -1007,7 +1008,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
if needAdsorb {
|
|
if needAdsorb {
|
|
if fabs(elems[0].1.endTime - currentAssetProgress.seconds) < 0.5 {
|
|
if fabs(elems[0].1.endTime - currentAssetProgress.seconds) < 0.5 {
|
|
BFLog(1, message: "吸附在录音结尾")
|
|
BFLog(1, message: "吸附在录音结尾")
|
|
- // changeWithDrawBtnLayout(false)
|
|
|
|
|
|
+ // changeWithDrawBtnLayout(false)
|
|
changeProgress(progress: Float(elems[0].1.endTime / itemModels[currItemModelIndex].materialDuraion))
|
|
changeProgress(progress: Float(elems[0].1.endTime / itemModels[currItemModelIndex].materialDuraion))
|
|
progressThumV.progress = elems[0].1.endTime
|
|
progressThumV.progress = elems[0].1.endTime
|
|
|
|
|
|
@@ -1018,7 +1019,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
} else {
|
|
} else {
|
|
if fabs(elems[0].1.startTime - currentAssetProgress.seconds) < 0.5 {
|
|
if fabs(elems[0].1.startTime - currentAssetProgress.seconds) < 0.5 {
|
|
BFLog(1, message: "吸附在录音开始")
|
|
BFLog(1, message: "吸附在录音开始")
|
|
- // changeWithDrawBtnLayout(true)
|
|
|
|
|
|
+ // changeWithDrawBtnLayout(true)
|
|
changeProgress(progress: Float(elems[0].1.startTime / itemModels[currItemModelIndex].materialDuraion))
|
|
changeProgress(progress: Float(elems[0].1.startTime / itemModels[currItemModelIndex].materialDuraion))
|
|
progressThumV.progress = elems[0].1.startTime
|
|
progressThumV.progress = elems[0].1.startTime
|
|
}
|
|
}
|
|
@@ -1028,15 +1029,14 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange)")
|
|
BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange)")
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
deleteRecordBtn.isHidden = false
|
|
deleteRecordBtn.isHidden = false
|
|
recordBtn.isHidden = true
|
|
recordBtn.isHidden = true
|
|
|
|
|
|
isStopAtRecordRange = elems.first!.0
|
|
isStopAtRecordRange = elems.first!.0
|
|
BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange)")
|
|
BFLog(1, message: "停在了录音区间里 \(isStopAtRecordRange)")
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
deleteRecordBtn.isHidden = true
|
|
deleteRecordBtn.isHidden = true
|
|
recordBtn.isHidden = false
|
|
recordBtn.isHidden = false
|
|
@@ -1192,7 +1192,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
func play() {
|
|
func play() {
|
|
BFLog(1, message: "开始播放 \(currentAssetProgress.seconds)")
|
|
BFLog(1, message: "开始播放 \(currentAssetProgress.seconds)")
|
|
-
|
|
|
|
|
|
+
|
|
isNormalPlaying = true
|
|
isNormalPlaying = true
|
|
if isEndPlay {
|
|
if isEndPlay {
|
|
isEndPlay = false
|
|
isEndPlay = false
|
|
@@ -1215,7 +1215,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
// 处理图片音频播放
|
|
// 处理图片音频播放
|
|
imageRecordPlay()
|
|
imageRecordPlay()
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
deleteRecordBtn.isHidden = true
|
|
deleteRecordBtn.isHidden = true
|
|
recordBtn.isHidden = false
|
|
recordBtn.isHidden = false
|
|
}
|
|
}
|
|
@@ -1299,8 +1299,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
assetPlayer?.replaceCurrentItem(with: item)
|
|
assetPlayer?.replaceCurrentItem(with: item)
|
|
} else {
|
|
} else {
|
|
assetPlayer = AVPlayer(playerItem: item)
|
|
assetPlayer = AVPlayer(playerItem: item)
|
|
- assetPlayer?.volume = self.noSpeakVolume
|
|
|
|
-
|
|
|
|
|
|
+ assetPlayer?.volume = noSpeakVolume
|
|
|
|
+
|
|
avplayerTimeObserver?.invalidate()
|
|
avplayerTimeObserver?.invalidate()
|
|
avplayerTimeObserver = assetPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 1000), queue: DispatchQueue.global()) { [weak self] time in
|
|
avplayerTimeObserver = assetPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 1000), queue: DispatchQueue.global()) { [weak self] time in
|
|
// 进度监控
|
|
// 进度监控
|
|
@@ -1411,10 +1411,10 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- func drawProgressIndication(progress:Double) {
|
|
|
|
|
|
+
|
|
|
|
+ func drawProgressIndication(progress: Double) {
|
|
if indirectionView == nil {
|
|
if indirectionView == nil {
|
|
- indirectionView = BFIndirectionProgressView(frame: progressThumV.progessIndicateBackV.bounds , percenWidth: itemModels[currItemModelIndex].mediaType == .IMAGE ? (progressThumV.thumbImageWidth ) / 2 : 0, totalDuration: itemModels[currItemModelIndex ].materialDuraion )
|
|
|
|
|
|
+ indirectionView = BFIndirectionProgressView(frame: progressThumV.progessIndicateBackV.bounds, percenWidth: itemModels[currItemModelIndex].mediaType == .IMAGE ? progressThumV.thumbImageWidth / 2 : 0, totalDuration: itemModels[currItemModelIndex].materialDuraion)
|
|
progressThumV.progessIndicateBackV.addSubview((indirectionView)!)
|
|
progressThumV.progessIndicateBackV.addSubview((indirectionView)!)
|
|
}
|
|
}
|
|
// 更新录制进度
|
|
// 更新录制进度
|
|
@@ -1422,21 +1422,20 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
// 注:在录制停止时,视频播放器进度依然在走,误差在80毫秒左右
|
|
// 注:在录制停止时,视频播放器进度依然在走,误差在80毫秒左右
|
|
if isRecording {
|
|
if isRecording {
|
|
let ratioX = 0.08
|
|
let ratioX = 0.08
|
|
- indirectionView?.setProgress(start: recordStartTime , progress: (progress) - ratioX)
|
|
|
|
|
|
+ indirectionView?.setProgress(start: recordStartTime, progress: progress - ratioX)
|
|
}
|
|
}
|
|
- if itemModels[currItemModelIndex ].mediaType == .IMAGE {
|
|
|
|
|
|
+ if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
imageRecordProgress(isRecord: true, progress: progress)
|
|
imageRecordProgress(isRecord: true, progress: progress)
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// 修正视频旋转方向,因为自己录制的竖屏视频会预览为横屏
|
|
// 修正视频旋转方向,因为自己录制的竖屏视频会预览为横屏
|
|
func reloadMaterial(recordItem: BFRecordItemModel) {
|
|
func reloadMaterial(recordItem: BFRecordItemModel) {
|
|
if let path = recordItem.localPath, let cell: BFImageCoverViewCell = collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell {
|
|
if let path = recordItem.localPath, let cell: BFImageCoverViewCell = collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell {
|
|
setVideoPlay(item: recordItem.playItem, imageView: cell.playView)
|
|
setVideoPlay(item: recordItem.playItem, imageView: cell.playView)
|
|
setAudioPlay(item: recordItem.playItem)
|
|
setAudioPlay(item: recordItem.playItem)
|
|
playBtn = cell.playBtn
|
|
playBtn = cell.playBtn
|
|
-
|
|
|
|
|
|
+
|
|
let degress = degressFromVideoFile(url: URL(fileURLWithPath: path))
|
|
let degress = degressFromVideoFile(url: URL(fileURLWithPath: path))
|
|
switch degress {
|
|
switch degress {
|
|
case 90:
|
|
case 90:
|
|
@@ -1450,7 +1449,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
extension BFRecordScreenController: GPUImageMovieDelegate {
|
|
extension BFRecordScreenController: GPUImageMovieDelegate {
|
|
@@ -1472,9 +1470,6 @@ extension BFRecordScreenController: AVAudioPlayerDelegate {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// MARK: - UICollectionViewDelegate
|
|
// MARK: - UICollectionViewDelegate
|
|
|
|
|
|
/// UICollectionViewDelegate
|
|
/// UICollectionViewDelegate
|
|
@@ -1541,7 +1536,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
itemModels[currItemModelIndex].events = events
|
|
itemModels[currItemModelIndex].events = events
|
|
events = itemModels[page].events
|
|
events = itemModels[page].events
|
|
searchStopAtRecordRange()
|
|
searchStopAtRecordRange()
|
|
-
|
|
|
|
|
|
+
|
|
// 更新当前page
|
|
// 更新当前page
|
|
pauseTime = 0
|
|
pauseTime = 0
|
|
currItemModelIndex = page
|
|
currItemModelIndex = page
|
|
@@ -1552,9 +1547,8 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
if changeItemHandle != nil {
|
|
if changeItemHandle != nil {
|
|
changeItemHandle!(page)
|
|
changeItemHandle!(page)
|
|
}
|
|
}
|
|
-
|
|
|
|
-// movie?.startProcessing()
|
|
|
|
|
|
|
|
|
|
+// movie?.startProcessing()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1609,11 +1603,17 @@ public extension BFRecordScreenController {
|
|
}
|
|
}
|
|
BFLog(1, message: "图片录音进度:\(progress),currentAssetProgress=\(currentAssetProgress),\(itemModels[currItemModelIndex].materialDuraion)")
|
|
BFLog(1, message: "图片录音进度:\(progress),currentAssetProgress=\(currentAssetProgress),\(itemModels[currItemModelIndex].materialDuraion)")
|
|
if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
- DispatchQueue.main.async { [weak self] in
|
|
|
|
- self?.progreddL.text = String(format: "%@", (self?.currentAssetProgress.seconds ?? 0).formatDurationToHMS())
|
|
|
|
- self?.progressThumV.progress = (self?.currentAssetProgress.seconds ?? 0)
|
|
|
|
- self?.updateSubtitle(time: self?.currentAssetProgress ?? CMTime.zero)
|
|
|
|
- }
|
|
|
|
|
|
+ /// 重置进度
|
|
|
|
+ resetCurrentProgress()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 重置进度
|
|
|
|
+ func resetCurrentProgress() {
|
|
|
|
+ DispatchQueue.main.async { [weak self] in
|
|
|
|
+ self?.progreddL.text = String(format: "%@", (self?.currentAssetProgress.seconds ?? 0).formatDurationToHMS())
|
|
|
|
+ self?.progressThumV.progress = (self?.currentAssetProgress.seconds ?? 0)
|
|
|
|
+ self?.updateSubtitle(time: self?.currentAssetProgress ?? CMTime.zero)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|