|
@@ -61,6 +61,8 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
var hadDeleteVideoOfFailed = false
|
|
|
|
|
|
var movieWrite: GPUImageMovieWriter?
|
|
|
+
|
|
|
+ var recordVoicePlayer:BFAudioPlayer = BFAudioPlayer.init()
|
|
|
|
|
|
lazy var camera: GPUImageStillCamera? = {
|
|
|
let camera = GPUImageStillCamera(sessionPreset: AVCaptureSession.Preset.hd1920x1080.rawValue, cameraPosition: AVCaptureDevice.Position.back)
|
|
@@ -416,6 +418,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
|
|
|
// 使用avplayer进行播放视频和音频
|
|
|
override func play() {
|
|
|
+ super.play()
|
|
|
guard playView != nil else {
|
|
|
return
|
|
|
}
|
|
@@ -440,7 +443,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
// case paused = 0
|
|
|
// case waitingToPlayAtSpecifiedRate = 1
|
|
|
// case playing = 2
|
|
|
- if (BFAudioPlayer.shared.player?.isPlaying ?? false || audioPlayerIsPlaying){
|
|
|
+ if (recordVoicePlayer.player?.isPlaying ?? false || audioPlayerIsPlaying){
|
|
|
// BFLog(2, message: "is playering 本次查找无效,有播放任务")
|
|
|
return
|
|
|
}
|
|
@@ -467,37 +470,37 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
}
|
|
|
playingVoiceMode = mod
|
|
|
|
|
|
- let cureentPalyURlString = BFAudioPlayer.shared.currentAudioPathURL?.absoluteString ?? ""
|
|
|
+ let cureentPalyURlString = recordVoicePlayer.currentAudioPathURL?.absoluteString ?? ""
|
|
|
if cureentPalyURlString.replacingOccurrences(of: "file://", with: "") == mod.wavFilePath && audioPlayerIsPlaying{
|
|
|
BFLog(2, message: "命中的和播放的文件路径一样? wavFilePath:\(mod.wavFilePath ?? "")")
|
|
|
// audioPlayerIsPlaying = true
|
|
|
-// BFAudioPlayer.shared.playOrPause()
|
|
|
+// recordVoicePlayer.playOrPause()
|
|
|
|
|
|
// if !(audioPlayerIsPlaying) {
|
|
|
//// audioPlayerIsPlaying = true
|
|
|
- BFAudioPlayer.shared.setPlayingTime((currentAssetProgress - mod.startCMTime).seconds)
|
|
|
-//// BFAudioPlayer.shared.playOrPause()
|
|
|
+ recordVoicePlayer.seekTime((currentAssetProgress - mod.startCMTime).seconds)
|
|
|
+//// recordVoicePlayer.playOrPause()
|
|
|
// }
|
|
|
|
|
|
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- BFAudioPlayer.shared.delegate = self
|
|
|
- BFAudioPlayer.shared.configPlayer(audioPathURL: URL(fileURLWithPath: mod.wavFilePath))
|
|
|
+ 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:\(BFAudioPlayer.shared.player?.rate ?? -1) \(mod.wavFilePath ?? "")")
|
|
|
+ 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
|
|
|
- BFAudioPlayer.shared.playOrPause()
|
|
|
+ recordVoicePlayer.playOrPause()
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
audioPlayerIsPlaying = true
|
|
|
- BFAudioPlayer.shared.setPlayingTime(tt.seconds)
|
|
|
- BFAudioPlayer.shared.playOrPause()
|
|
|
+ recordVoicePlayer.seekTime(tt.seconds)
|
|
|
+ recordVoicePlayer.playOrPause()
|
|
|
|
|
|
} else {
|
|
|
BFLog(message: "没有找到即将播放的录制音频文件?\(currentAssetProgress.seconds)")
|
|
@@ -579,7 +582,7 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
BFLog(1, message: "endPlay:\(wself.currentAssetProgress.seconds), 总时长:\(wself.recordItem!.materialDuraion.seconds), currplayer:\(wself.avplayer.currentItem?.currentTime().seconds ?? 0)")
|
|
|
|
|
|
// 判断录音是否还在播放,如果在播放停止
|
|
|
- if BFAudioPlayer.shared.player?.isPlaying ?? false {
|
|
|
+ if wself.recordVoicePlayer.player?.isPlaying ?? false {
|
|
|
wself.recordPlayer?.pause()
|
|
|
}
|
|
|
// // 如果离结束大于0.7s,代表还有下一段视频
|
|
@@ -599,10 +602,11 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
}
|
|
|
|
|
|
override func pause() {
|
|
|
+ super.pause()
|
|
|
dispatchWorkItemIsCancel = true
|
|
|
avplayer.pause()
|
|
|
|
|
|
- BFAudioPlayer.shared.pause()
|
|
|
+ recordVoicePlayer.pause()
|
|
|
|
|
|
audioPlayerIsPlaying = false
|
|
|
|
|
@@ -718,11 +722,11 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
}
|
|
|
|
|
|
// 检测录音的
|
|
|
-// checkCurrentPlayStatus()
|
|
|
+ checkCurrentPlayStatus()
|
|
|
// 检测视频的
|
|
|
prepareToPlayNext()
|
|
|
// 新的检测录音的
|
|
|
- playRecordVoice()
|
|
|
+// playRecordVoice()
|
|
|
}
|
|
|
|
|
|
func timerForRecord(currTime _: CMTime) {
|
|
@@ -794,27 +798,23 @@ class BFRecordScreenCameraManager: BFRecordScreenBaseManager {
|
|
|
movieWrite = GPUImageMovieWriter(movieURL: URL(fileURLWithPath: vpath), size: videoSize)
|
|
|
filter.addTarget(movieWrite)
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-extension BFRecordScreenCameraManager: BFAudioPlayerDelegate{
|
|
|
+
|
|
|
|
|
|
// 播放完成
|
|
|
- func audioPlayerDidFinish(){
|
|
|
+ override func audioPlayerDidFinish(audioPlayer:BFAudioPlayer){
|
|
|
BFLog(message: "audioPlayerDidFinish")
|
|
|
audioPlayerIsPlaying = false
|
|
|
- BFAudioPlayer.shared.pause()
|
|
|
+ recordVoicePlayer.pause()
|
|
|
}
|
|
|
|
|
|
// 播放开始
|
|
|
- func audioPlayerStart(){
|
|
|
-
|
|
|
+ override func audioPlayerStart(audioPlayer:BFAudioPlayer){
|
|
|
}
|
|
|
// 播放进度
|
|
|
- func playProgress(currentTime: TimeInterval, progress: Double){
|
|
|
+ override func playProgress(audioPlayer:BFAudioPlayer,currentTime: TimeInterval, progress: Double){
|
|
|
|
|
|
-// BFLog(message: "currentTime is \(currentTime) progress\(progress) \(BFAudioPlayer.shared.currentAudioPathURL?.absoluteString ?? "")")
|
|
|
+// BFLog(message: "currentTime is \(currentTime) progress\(progress) \(recordVoicePlayer.currentAudioPathURL?.absoluteString ?? "")")
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
extension BFRecordScreenCameraManager: GPUImageVideoCameraDelegate {
|