|
@@ -444,6 +444,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
self?.setSubtitleStyle(settingModel: subtitileModel.setting)
|
|
self?.setSubtitleStyle(settingModel: subtitileModel.setting)
|
|
}
|
|
}
|
|
|
|
+ // 编辑字幕完成
|
|
subtitleEditView.editSubtitleDone = { [weak self] newtext, index in
|
|
subtitleEditView.editSubtitleDone = { [weak self] newtext, index in
|
|
// 1,刷新 UI
|
|
// 1,刷新 UI
|
|
self?.subtitleLabel.text = newtext
|
|
self?.subtitleLabel.text = newtext
|
|
@@ -452,7 +453,14 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
// 更新缓存数据
|
|
// 更新缓存数据
|
|
if index < (self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.count ?? 0) {
|
|
if index < (self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.count ?? 0) {
|
|
- self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers[index].text = newtext
|
|
|
|
|
|
+ if newtext.count == 0 {
|
|
|
|
+ // 删除数据
|
|
|
|
+ BFLog(message: "清空字幕操作要删除原字幕 sticker 数据")
|
|
|
|
+ self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.remove(at: index)
|
|
|
|
+ } else {
|
|
|
|
+ // 更新数据
|
|
|
|
+ self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers[index].text = newtext
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -463,9 +471,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
@objc func editSubtitle() {
|
|
@objc func editSubtitle() {
|
|
BFLog(message: "编辑字幕 index:\(showSubtitleIndex)")
|
|
BFLog(message: "编辑字幕 index:\(showSubtitleIndex)")
|
|
- subtitleEditView.isHidden = false
|
|
|
|
- subtitleEditView.textView.becomeFirstResponder()
|
|
|
|
- subtitleEditView.setNewText(text: subtitleLabel.text ?? "", index: showSubtitleIndex)
|
|
|
|
|
|
+ if !isNormalPlaying {
|
|
|
|
+ subtitleEditView.isHidden = false
|
|
|
|
+ subtitleEditView.textView.becomeFirstResponder()
|
|
|
|
+ subtitleEditView.setNewText(text: subtitleLabel.text ?? "", index: showSubtitleIndex)
|
|
|
|
+ } else {
|
|
|
|
+ BFLog(message: "播放状态不可以编辑字幕")
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/// 更新字幕,在回放时使用
|
|
/// 更新字幕,在回放时使用
|
|
@@ -909,7 +921,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
// MARK: - 音视频处理
|
|
// MARK: - 音视频处理
|
|
|
|
|
|
- func playRecord(at currentT: CMTime, periodicTimeObserver: @escaping (_ time: CMTime, _ currentItem: AVPlayerItem) -> Void, didPlayToEndTime: @escaping (_ currentT: CMTime, _ currentItem: AVPlayerItem) -> Void,playFailut: @escaping () -> Void) {
|
|
|
|
|
|
+ func playRecord(at currentT: CMTime, periodicTimeObserver: @escaping (_ time: CMTime, _ currentItem: AVPlayerItem) -> Void, didPlayToEndTime: @escaping (_ currentT: CMTime, _ currentItem: AVPlayerItem) -> Void, playFailut: @escaping () -> Void) {
|
|
if currentPlayRecordIndex == -3 { // 刚录音完,不需要播放
|
|
if currentPlayRecordIndex == -3 { // 刚录音完,不需要播放
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -949,7 +961,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
self?.currentPlayRecordIndex = -1
|
|
self?.currentPlayRecordIndex = -1
|
|
didPlayToEndTime(currentT, newItem)
|
|
didPlayToEndTime(currentT, newItem)
|
|
}
|
|
}
|
|
- _ = recordPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 100), queue: DispatchQueue.global()) { [weak self] time in
|
|
|
|
|
|
+ _ = recordPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: 100), queue: DispatchQueue.global()) { [weak self] time in
|
|
periodicTimeObserver(time, newItem)
|
|
periodicTimeObserver(time, newItem)
|
|
} as? NSKeyValueObservation
|
|
} as? NSKeyValueObservation
|
|
}
|
|
}
|
|
@@ -1091,6 +1103,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
|
|
|
|
func setAudioPlay(item: AVPlayerItem?) {
|
|
func setAudioPlay(item: AVPlayerItem?) {
|
|
|
|
+ guard let item = item else {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
if let playItem = assetPlayer?.currentItem {
|
|
if let playItem = assetPlayer?.currentItem {
|
|
NotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, object: playItem)
|
|
NotificationCenter.default.removeObserver(self, name: .AVPlayerItemDidPlayToEndTime, object: playItem)
|
|
assetPlayer?.replaceCurrentItem(with: item)
|
|
assetPlayer?.replaceCurrentItem(with: item)
|
|
@@ -1106,9 +1121,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
BFLog(message: "播放一段进度:\(currentT),\(currentItem)")
|
|
BFLog(message: "播放一段进度:\(currentT),\(currentItem)")
|
|
}, didPlayToEndTime: { startT, currentItem in
|
|
}, didPlayToEndTime: { startT, currentItem in
|
|
BFLog(message: "播放一段结束:\(startT),\(currentItem)")
|
|
BFLog(message: "播放一段结束:\(startT),\(currentItem)")
|
|
- }, playFailut: {
|
|
|
|
-
|
|
|
|
- })
|
|
|
|
|
|
+ }, playFailut: {})
|
|
}
|
|
}
|
|
} as? NSKeyValueObservation
|
|
} as? NSKeyValueObservation
|
|
}
|
|
}
|
|
@@ -1340,11 +1353,11 @@ public extension BFRecordScreenController {
|
|
isNormalPlaying = true
|
|
isNormalPlaying = true
|
|
playRecord(at: currentAssetProgress, periodicTimeObserver: { [weak self] currentT, currentItem in
|
|
playRecord(at: currentAssetProgress, periodicTimeObserver: { [weak self] currentT, currentItem in
|
|
BFLog(message: "播放一段进度:\(currentT),\(currentItem)")
|
|
BFLog(message: "播放一段进度:\(currentT),\(currentItem)")
|
|
- self?.imageRecordProgress(progress:CMTimeGetSeconds(currentT))
|
|
|
|
|
|
+ self?.imageRecordProgress(progress: CMTimeGetSeconds(currentT))
|
|
}, didPlayToEndTime: { [weak self] startT, currentItem in
|
|
}, didPlayToEndTime: { [weak self] startT, currentItem in
|
|
BFLog(message: "播放一段结束:\(startT),\(currentItem)")
|
|
BFLog(message: "播放一段结束:\(startT),\(currentItem)")
|
|
self?.imageRecordPlay()
|
|
self?.imageRecordPlay()
|
|
- }) {[weak self] in
|
|
|
|
|
|
+ }) { [weak self] in
|
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) {
|
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 3) {
|
|
self?.imageRecordPlay()
|
|
self?.imageRecordPlay()
|
|
}
|
|
}
|