|
@@ -52,7 +52,10 @@ class BFRecordScreenCameraManager : BFRecordScreenBaseManager{
|
|
|
fileprivate var timerr:Timer?
|
|
|
|
|
|
var writerlock = false
|
|
|
-
|
|
|
+
|
|
|
+ // 录制时音频结果
|
|
|
+ var recordFinishedResult = false
|
|
|
+
|
|
|
var movieWrite : GPUImageMovieWriter?
|
|
|
|
|
|
lazy var camera : GPUImageStillCamera? = {
|
|
@@ -193,7 +196,7 @@ class BFRecordScreenCameraManager : BFRecordScreenBaseManager{
|
|
|
cameraProgressV?.isHidden = false
|
|
|
}
|
|
|
movieWrite.startRecording()
|
|
|
-
|
|
|
+ timerr?.invalidate()
|
|
|
timerr = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true, block: {[weak self] _ in
|
|
|
guard let wself = self else { return }
|
|
|
if BFRecordScreenCameraManager.firstOpenCamera {
|
|
@@ -202,11 +205,13 @@ class BFRecordScreenCameraManager : BFRecordScreenBaseManager{
|
|
|
//MARK: 进度计时器
|
|
|
|
|
|
let currDur = CMTime(seconds: wself.videoModel.timelineCMIn.seconds + movieWrite.duration.seconds, preferredTimescale: 1000)
|
|
|
- wself.currentAssetProgress = currDur
|
|
|
- wself.videoModel.timelineCMOut = currDur
|
|
|
- wself.recordProgressCallBack?(currDur)
|
|
|
- wself.updateUI(progress: currDur)
|
|
|
-// BFLog(1, message: "currTime: \(wself.currentAssetProgress.seconds)")
|
|
|
+ if CMTimeCompare(currDur, wself.currentAssetProgress) > 0 {
|
|
|
+ wself.currentAssetProgress = currDur
|
|
|
+ wself.videoModel.timelineCMOut = currDur
|
|
|
+ wself.recordProgressCallBack?(currDur)
|
|
|
+ wself.updateUI(progress: currDur)
|
|
|
+// BFLog(1, message: "currTime: \(wself.currentAssetProgress.seconds)")
|
|
|
+ }
|
|
|
|
|
|
// wself.getThumImage()
|
|
|
})
|
|
@@ -231,8 +236,15 @@ class BFRecordScreenCameraManager : BFRecordScreenBaseManager{
|
|
|
wself.videoModel.timelineCMOut = wself.videoModel.timelineCMIn + CMTime(seconds: dur.duration.seconds, preferredTimescale: 1000)
|
|
|
BFLog(1, message: "拍摄文件时长:\(wself.videoModel.timelineCMIn.seconds)~\(wself.videoModel.timelineCMOut.seconds), \(dur.duration.seconds)")
|
|
|
wself.videoModel.locationPath = finalPath
|
|
|
- if (wself.videoModel.timelineCMOut - wself.videoModel.timelineCMIn).seconds < 1 {
|
|
|
- wself.recordFinished(isSuccess: false)
|
|
|
+ if (wself.videoModel.timelineCMOut - wself.videoModel.timelineCMIn).seconds <= 1 {
|
|
|
+// wself.recordFinished(isSuccess: false)
|
|
|
+ }else{
|
|
|
+ if wself.recordFinishedResult {
|
|
|
+ // 代表录制成功了
|
|
|
+ wself.currentAssetProgress = wself.videoModel.timelineCMOut
|
|
|
+ wself.recordEndCallBack?(true, wself.videoModel)
|
|
|
+ BFLog(1, message: "摄像成功")
|
|
|
+ }
|
|
|
}
|
|
|
}else{
|
|
|
// 录制失败后恢复原样
|
|
@@ -255,12 +267,14 @@ class BFRecordScreenCameraManager : BFRecordScreenBaseManager{
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- override func recordFinished(isSuccess:Bool){
|
|
|
+ override func recordFinished(isSuccess:Bool) {
|
|
|
+ recordFinishedResult = isSuccess
|
|
|
if isSuccess {
|
|
|
currentAssetProgress = videoModel.timelineCMOut
|
|
|
- recordEndCallBack?(true, videoModel)
|
|
|
+ // 屏蔽是因为成功要以摄像头为准
|
|
|
+// recordEndCallBack?(true, videoModel)
|
|
|
}else{
|
|
|
- if (videoModel.thumImgs?.count ?? 0) > 0 {
|
|
|
+ if (videoModel.thumImgs?.count ?? 0) > 0 { //用图片数量来判断是否已经删除了当次录制
|
|
|
revertLast()
|
|
|
recordEndCallBack?(false, nil)
|
|
|
}
|
|
@@ -332,7 +346,9 @@ class BFRecordScreenCameraManager : BFRecordScreenBaseManager{
|
|
|
if modIndex >= 0 && modIndex < recordItem?.videoStickers.count ?? 0{
|
|
|
vmod = recordItem?.videoStickers[modIndex]
|
|
|
}else{
|
|
|
- vmod = recordItem?.videoStickers.last
|
|
|
+ vmod = recordItem?.videoStickers.first(where: { mod in
|
|
|
+ CMTimeCompare(mod.timelineCMIn, currentAssetProgress) >= 0
|
|
|
+ })
|
|
|
}
|
|
|
if vmod != nil {
|
|
|
vmod!.timelineCMOut = vmod!.timelineCMIn
|
|
@@ -446,6 +462,9 @@ class BFRecordScreenCameraManager : BFRecordScreenBaseManager{
|
|
|
locationTo(time: currentAssetProgress)
|
|
|
}
|
|
|
playerCoverIV.isHidden = (CMTimeCompare(currentAssetProgress, recordItem?.materialDuraion ?? .zero) >= 0)
|
|
|
+ if !playerCoverIV.isHidden {
|
|
|
+ BFLog(1, message: "stor")
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -562,8 +581,8 @@ class BFRecordScreenCameraManager : BFRecordScreenBaseManager{
|
|
|
}
|
|
|
progreddL?.text = CMTimeGetSeconds(currentAssetProgress).formatDurationToHMS()
|
|
|
|
|
|
- cameraProgressV?.collectionV.contentOffset = CGPoint(x: currentAssetProgress.seconds * 70.0 / 5.0, y: 0)
|
|
|
-
|
|
|
+ let p = CGPoint(x: currentAssetProgress.seconds * 70.0 / 5.0, y: 0)
|
|
|
+ cameraProgressV?.collectionV.contentOffset = p
|
|
|
}
|
|
|
|
|
|
func updateUI(progress:CMTime){
|