|
@@ -258,14 +258,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
// 显示字幕
|
|
|
lazy var subtitleLabel: PQSubTitleLabel = {
|
|
|
- let test = ""
|
|
|
- let leftPoint: CGFloat = 37
|
|
|
- let height = sizeWithText(text: test, font: UIFont.boldSystemFont(ofSize: 70 * 375 / 1080), size: CGSize(width: cScreenWidth - leftPoint * 2, height: 102))
|
|
|
-
|
|
|
- let subtitleLabel = PQSubTitleLabel(frame: CGRect(x: leftPoint, y: cScreenHeigth * 0.70 - height.height, width: cScreenWidth - 37 * 2, height: height.height))
|
|
|
+ let subtitleLabel = PQSubTitleLabel()
|
|
|
subtitleLabel.textAlignment = .center
|
|
|
- subtitleLabel.text = test
|
|
|
-
|
|
|
subtitleLabel.numberOfLines = 0
|
|
|
subtitleLabel.lineBreakMode = .byWordWrapping
|
|
|
subtitleLabel.isUserInteractionEnabled = true
|
|
@@ -404,9 +398,10 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
self?.setSubtitleStyle(settingModel: (self?.subtitleSettingView.subtitle.setting)!)
|
|
|
|
|
|
- //更新数据
|
|
|
- self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers[index].text = newtext
|
|
|
- }
|
|
|
+ //更新缓存数据
|
|
|
+ if(index < (self?.itemModels[(self?.currItemModelIndex ?? 0)].titleStickers.count ?? 0)){
|
|
|
+ self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers[index].text = newtext}
|
|
|
+ }
|
|
|
|
|
|
layoutsubview()
|
|
|
|
|
@@ -414,7 +409,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
@objc func editSubtitle() {
|
|
|
- BFLog(message: "编辑字幕")
|
|
|
+ BFLog(message: "编辑字幕 index:\(showSubtitleIndex)")
|
|
|
subtitleEditView.isHidden = false
|
|
|
subtitleEditView.textView.becomeFirstResponder()
|
|
|
subtitleEditView.setNewText(text: subtitleLabel.text ?? "",index: showSubtitleIndex)
|
|
@@ -450,15 +445,17 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
subtitleLabel.textColor = settingModel.fontColor
|
|
|
|
|
|
let leftPoint: CGFloat = 37
|
|
|
- let height = sizeWithText(text: subtitleLabel.text ?? "", font: UIFont.boldSystemFont(ofSize: CGFloat(settingModel.subtitleSize * 375 / 1080)), size: CGSize(width: cScreenWidth - leftPoint * 2, height: 102))
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ let height = sizeTextFits(attributedText: nil, text: subtitleLabel.text ?? "", numberOfLines: 0, font: subtitleLabel.font, maxSize: CGSize(width: cScreenWidth - leftPoint * 2, height: CGFloat.greatestFiniteMagnitude)).height
|
|
|
+
|
|
|
// 下 //设置位置
|
|
|
if subtitleSettingView.subtitle.setting.subtitlePoint == 0 {
|
|
|
- subtitleLabel.frame = CGRect(x: leftPoint, y: cScreenHeigth * 0.70 - height.height, width: cScreenWidth - 37 * 2, height: height.height)
|
|
|
+ subtitleLabel.frame = CGRect(x: leftPoint, y: cScreenHeigth * 0.70 - height, width: cScreenWidth - 37 * 2, height: height)
|
|
|
} else if subtitleSettingView.subtitle.setting.subtitlePoint == 1 { // 中
|
|
|
- subtitleLabel.frame = CGRect(x: leftPoint, y: cScreenHeigth / 2.0 - height.height / 2.0, width: cScreenWidth - 37 * 2, height: height.height)
|
|
|
+ subtitleLabel.frame = CGRect(x: leftPoint, y: cScreenHeigth / 2.0 - height / 2.0, width: cScreenWidth - 37 * 2, height: height)
|
|
|
} else { // 上
|
|
|
- subtitleLabel.frame = CGRect(x: leftPoint, y: cScreenHeigth * 0.12, width: cScreenWidth - 37 * 2, height: height.height)
|
|
|
+ subtitleLabel.frame = CGRect(x: leftPoint, y: cScreenHeigth * 0.12, width: cScreenWidth - 37 * 2, height: height)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1101,10 +1098,14 @@ extension BFRecordScreenController: PQSpeechTranscriberUtilDelegate {
|
|
|
// 当前已处理的音频时长,单位:毫秒。
|
|
|
|
|
|
newSubtitle.timelineOut = Float64(((payload?["time"]) as? Int) ?? 0) * 1_000.0 + (self.recorderManager.voiceModel?.startTime ?? 0.0) * 1_000_000.0
|
|
|
+ var showText = ((payload?["result"]) as? String) ?? ""
|
|
|
+ if(showText.count > 30){
|
|
|
+ showText = showText.substring(to: 30)
|
|
|
+ showText += "..."
|
|
|
+ }
|
|
|
+ newSubtitle.text = showText
|
|
|
|
|
|
BFLog(message: "添加字幕数据 timelineIn \(newSubtitle.timelineIn) timelineOut \(newSubtitle.timelineOut) text \(newSubtitle.text)")
|
|
|
-
|
|
|
- newSubtitle.text = ((payload?["result"]) as? String) ?? ""
|
|
|
newSubtitle.setting = self.subtitleSettingView.subtitle.setting
|
|
|
|
|
|
self.itemModels[self.currItemModelIndex].titleStickers.append(newSubtitle)
|