소스 검색

add image audio duration

wenweiwei 3 년 전
부모
커밋
664a60bc58

+ 1 - 0
BFRecordScreenKit/Classes/BFVoiceRecordManager.swift

@@ -103,6 +103,7 @@ class BFVoiceRecordManager {
                 NXNoiseReduction().denoise(url, outFile: noiseFilePath)
                 if let model = self?.voiceModel {
                     model.wavFilePath = noiseFilePath
+                    model.duration = "\(duration)"
                     self?.endRecordHandle?(model, nil)
                 }
 

+ 8 - 7
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -117,9 +117,10 @@ public class BFRecordScreenController: BFBaseViewController {
                     sself.events.removeLast()
                     sself.events.append(event!)
                 }
-
                 sself.itemModels[sself.currItemModelIndex].voiceStickers.append(model)
-
+                if sself.itemModels[sself.currItemModelIndex].mediaType == .IMAGE {
+                    sself.itemModels[sself.currItemModelIndex].materialDuraion = sself.itemModels[sself.currItemModelIndex].materialDuraion + (Double(model.duration ?? "0") ?? 0)
+                }
                 sself.drawOrUpdateRecordProgessLable()
 
                 sself.currentPlayRecordIndex = -3 // 刚录音完,不需要播放录音
@@ -479,7 +480,7 @@ public class BFRecordScreenController: BFBaseViewController {
                 break
             }
         }
-        if findShowSubtitle != nil && subtitleSettingView.subtitle.setting.subtitleIsShow {
+        if findShowSubtitle != nil, subtitleSettingView.subtitle.setting.subtitleIsShow {
             subtitleLabel.text = findShowSubtitle?.text
             setSubtitleStyle(settingModel: subtitleSettingView.subtitle.setting)
 
@@ -1234,7 +1235,7 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
         } else {
             cell = BFImageCoverViewCell.gpuImageViewCell(collectionView: collectionView, indexPath: indexPath)
         }
-        recordItem.fetchCoverImg = { [weak self,weak cell] _ in
+        recordItem.fetchCoverImg = { [weak self, weak cell] _ in
             cell?.addData()
             if recordItem.mediaType == .IMAGE {
                 self?.progressThumV.recordItem = recordItem
@@ -1274,9 +1275,9 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
                 let currCell: BFVideoCoverViewCell? = collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFVideoCoverViewCell
                 setAudioPlay(item: recordItem.playItem)
                 setVideoPlay(item: recordItem.playItem, imageView: currCell?.playView)
-                if changeItemHandle != nil {
-                    changeItemHandle!(currItemModelIndex)
-                }
+            }
+            if changeItemHandle != nil {
+                changeItemHandle!(currItemModelIndex)
             }
         }
     }