|
@@ -62,8 +62,6 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
|
|
|
var movieWrite: GPUImageMovieWriter?
|
|
|
|
|
|
- var recordVoicePlayer:BFAudioPlayer = BFAudioPlayer.init()
|
|
|
-
|
|
|
lazy var camera: GPUImageStillCamera? = {
|
|
|
let camera = GPUImageStillCamera(sessionPreset: AVCaptureSession.Preset.hd1920x1080.rawValue, cameraPosition: AVCaptureDevice.Position.back)
|
|
|
camera?.outputImageOrientation = UIInterfaceOrientation.portrait
|
|
@@ -78,10 +76,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
}()
|
|
|
|
|
|
var groupCount = 0
|
|
|
-
|
|
|
- // 录音文件是否正在播放
|
|
|
- var audioPlayerIsPlaying:Bool = false
|
|
|
-
|
|
|
+
|
|
|
lazy var avplayer: AVPlayer = {
|
|
|
let p = AVPlayer(playerItem: nil)
|
|
|
|
|
@@ -436,77 +431,6 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
|
|
|
startTimer(isPlay: true)
|
|
|
}
|
|
|
-
|
|
|
- func playRecordVoice(needPlay: Bool = true) {
|
|
|
-
|
|
|
- // 三种状态值ff
|
|
|
-// case paused = 0
|
|
|
-// case waitingToPlayAtSpecifiedRate = 1
|
|
|
-// case playing = 2
|
|
|
- if (recordVoicePlayer.player?.isPlaying ?? false || audioPlayerIsPlaying){
|
|
|
-// BFLog(2, message: "is playering 本次查找无效,有播放任务")
|
|
|
- return
|
|
|
- }
|
|
|
-// BFLog(2,message: "开始查找!!!!当前进度:\(currentAssetProgress.seconds)")
|
|
|
-
|
|
|
- // 播放音频
|
|
|
- var useVoiceStickers = [PQVoiceModel]()
|
|
|
- if (recordItem?.voiceChangeStickers.count ?? 0) > 0 {
|
|
|
- useVoiceStickers = recordItem?.voiceChangeStickers ?? [PQVoiceModel]()
|
|
|
- } else {
|
|
|
- useVoiceStickers = recordItem?.voiceStickers ?? [PQVoiceModel]()
|
|
|
- }
|
|
|
-
|
|
|
- if let mod = useVoiceStickers.first(where: { m in
|
|
|
- CMTimeCompare(m.startCMTime, currentAssetProgress) <= 0 && CMTimeCompare(m.endCMTime, currentAssetProgress) > 0
|
|
|
-
|
|
|
- }) {
|
|
|
- BFLog(message: "找到音频开始时间:\(mod.startCMTime.seconds)结束 \(mod.endCMTime.seconds) currentAssetProgress is \(currentAssetProgress.seconds) wavFilePath:\(mod.wavFilePath ?? "")")
|
|
|
-
|
|
|
- // 当前播放的文件
|
|
|
- if playingVoiceMode == mod {
|
|
|
- BFLog(2,message: "找查到mod的已经播放完成同一个 wavFilePath:\(mod.wavFilePath ?? "")")
|
|
|
- return
|
|
|
- }
|
|
|
- playingVoiceMode = mod
|
|
|
-
|
|
|
- let cureentPalyURlString = recordVoicePlayer.currentAudioPathURL?.absoluteString ?? ""
|
|
|
- if cureentPalyURlString.replacingOccurrences(of: "file://", with: "") == mod.wavFilePath && audioPlayerIsPlaying{
|
|
|
- BFLog(2, message: "命中的和播放的文件路径一样? wavFilePath:\(mod.wavFilePath ?? "")")
|
|
|
-// audioPlayerIsPlaying = true
|
|
|
-// recordVoicePlayer.playOrPause()
|
|
|
-
|
|
|
-// if !(audioPlayerIsPlaying) {
|
|
|
-//// audioPlayerIsPlaying = true
|
|
|
- recordVoicePlayer.seekTime((currentAssetProgress - mod.startCMTime).seconds)
|
|
|
-//// recordVoicePlayer.playOrPause()
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- recordVoicePlayer.delegate = self
|
|
|
- recordVoicePlayer.configPlayer(audioPathURL: URL(fileURLWithPath: mod.wavFilePath))
|
|
|
-
|
|
|
- let tt = currentAssetProgress - mod.startCMTime
|
|
|
- BFLog(1, message: "record - tt: \(tt.seconds), curr:\(currentAssetProgress.seconds) \(needPlay) rate:\(recordVoicePlayer.player?.rate ?? -1) \(mod.wavFilePath ?? "")")
|
|
|
- if CMTimeCompare(tt, .zero) == 0 {
|
|
|
- if needPlay {
|
|
|
- audioPlayerIsPlaying = true
|
|
|
- recordVoicePlayer.playOrPause()
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
- audioPlayerIsPlaying = true
|
|
|
- recordVoicePlayer.seekTime(tt.seconds)
|
|
|
- recordVoicePlayer.playOrPause()
|
|
|
-
|
|
|
- } else {
|
|
|
- BFLog(message: "没有找到即将播放的录制音频文件?\(currentAssetProgress.seconds)")
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
func prepareToPlayNext(needPlay: Bool = true) {
|
|
|
|
|
|
if let mod = recordItem?.videoStickers.first(where: { mode in
|
|
@@ -581,10 +505,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
|
|
|
BFLog(1, message: "endPlay:\(wself.currentAssetProgress.seconds), 总时长:\(wself.recordItem!.materialDuraion.seconds), currplayer:\(wself.avplayer.currentItem?.currentTime().seconds ?? 0)")
|
|
|
|
|
|
- // 判断录音是否还在播放,如果在播放停止
|
|
|
- if wself.recordVoicePlayer.player?.isPlaying ?? false {
|
|
|
- wself.recordPlayer?.pause()
|
|
|
- }
|
|
|
+
|
|
|
// // 如果离结束大于0.7s,代表还有下一段视频
|
|
|
// if ((wself.recordItem?.materialDuraion ?? .zero) - wself.currentAssetProgress).seconds > 0.7 {
|
|
|
//// wself.findNextModel()
|
|
@@ -605,11 +526,6 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
super.pause()
|
|
|
dispatchWorkItemIsCancel = true
|
|
|
avplayer.pause()
|
|
|
-
|
|
|
- recordVoicePlayer.pause()
|
|
|
-
|
|
|
- audioPlayerIsPlaying = false
|
|
|
-
|
|
|
playingVoiceMode = nil
|
|
|
|
|
|
timerr?.invalidate()
|
|
@@ -725,8 +641,6 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
checkCurrentPlayStatus()
|
|
|
// 检测视频的
|
|
|
prepareToPlayNext()
|
|
|
- // 新的检测录音的
|
|
|
-// playRecordVoice()
|
|
|
}
|
|
|
|
|
|
func timerForRecord(currTime _: CMTime) {
|
|
@@ -798,23 +712,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
movieWrite = GPUImageMovieWriter(movieURL: URL(fileURLWithPath: vpath), size: videoSize)
|
|
|
filter.addTarget(movieWrite)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- // 播放完成
|
|
|
- override func audioPlayerDidFinish(audioPlayer:BFAudioPlayer){
|
|
|
- BFLog(message: "audioPlayerDidFinish")
|
|
|
- audioPlayerIsPlaying = false
|
|
|
- recordVoicePlayer.pause()
|
|
|
- }
|
|
|
-
|
|
|
- // 播放开始
|
|
|
- override func audioPlayerStart(audioPlayer:BFAudioPlayer){
|
|
|
- }
|
|
|
- // 播放进度
|
|
|
- override func playProgress(audioPlayer:BFAudioPlayer,currentTime: TimeInterval, progress: Double){
|
|
|
-
|
|
|
-// BFLog(message: "currentTime is \(currentTime) progress\(progress) \(recordVoicePlayer.currentAudioPathURL?.absoluteString ?? "")")
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
extension BFRecordScreenCameraManager: GPUImageVideoCameraDelegate {
|