|
@@ -51,7 +51,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
recordBtn.setTitle(isRecording ? "松手 暂停" : "按住 录音", for: .normal)
|
|
|
recordBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#389AFF", alpha: isRecording ? 0.6 : 1)
|
|
|
- playBtn.isSelected = isRecording
|
|
|
// if !isRecording {
|
|
|
// BFLog(1, message: "stop")
|
|
|
// }
|
|
@@ -67,7 +66,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
var isNormalPlaying = false { // 是否正在播放
|
|
|
didSet {
|
|
|
- playBtn.isSelected = isNormalPlaying
|
|
|
withDrawBtn.isHidden = isNormalPlaying
|
|
|
}
|
|
|
}
|
|
@@ -144,11 +142,13 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}()
|
|
|
|
|
|
lazy var playBtn: UIButton = {
|
|
|
- let btn = UIButton(frame: view.bounds)
|
|
|
+ let btn = UIButton(frame: CGRect.init(x: 0, y: 0, width: 150, height: 156))
|
|
|
btn.setImage(imageInRecordScreenKit(by: "preview_play"), for: .normal)
|
|
|
let vv = UIView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
|
|
btn.setImage(vv.graphicsGetImage(), for: .selected)
|
|
|
+ btn.setImage(nil, for: .highlighted)
|
|
|
btn.addTarget(self, action: #selector(playVideo(btn:)), for: .touchUpInside)
|
|
|
+ btn.center = view.center
|
|
|
return btn
|
|
|
}()
|
|
|
|
|
@@ -504,7 +504,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
sself.itemModels[sself.currItemModelIndex].materialDuraion = Double(String(format: "%.3f", duration)) ?? 0
|
|
|
self?.isEndPlay = true
|
|
|
// 录制结束显示播放按钮
|
|
|
- (sself.collectionView.cellForItem(at: IndexPath(item: sself.currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = sself.itemModels[sself.currItemModelIndex].voiceStickers.count <= 0
|
|
|
+ sself.playBtn.isSelected = sself.itemModels[sself.currItemModelIndex].voiceStickers.count <= 0
|
|
|
}
|
|
|
DispatchQueue.main.async { [weak self] in
|
|
|
// 录音完,重绘撤销按钮,更新录音按钮,
|
|
@@ -555,7 +555,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
// playView = GPUImageView(frame: view.bounds)
|
|
|
// view.addSubview(playView!)
|
|
|
fetchVideo()
|
|
|
- // view.addSubview(playBtn)
|
|
|
+ view.addSubview(playBtn)
|
|
|
view.addSubview(bottomeView)
|
|
|
view.addSubview(avatarView)
|
|
|
// view.addSubview(openCameraBtn)
|
|
@@ -925,7 +925,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
assetPlayer?.play()
|
|
|
}
|
|
|
// 录制中不显示播放按钮
|
|
|
- (collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = true
|
|
|
+ playBtn.isSelected = true
|
|
|
}
|
|
|
|
|
|
@objc func endRecord() {
|
|
@@ -1046,7 +1046,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
// 如果是图片需重置播放按钮
|
|
|
if itemModel.mediaType == .IMAGE {
|
|
|
- (collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = itemModels[currItemModelIndex].voiceStickers.count <= 0
|
|
|
+ playBtn.isSelected = itemModels[currItemModelIndex].voiceStickers.count <= 0
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1057,6 +1057,11 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
@objc func playVideo(btn: UIButton) {
|
|
|
+ if itemModels[currItemModelIndex].mediaType == .IMAGE && itemModels[currItemModelIndex].voiceStickers.count <= 0 {
|
|
|
+ BFLog(message: "图片没有录音无法播放")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ btn.isSelected = !btn.isSelected
|
|
|
if !btn.isSelected {
|
|
|
pause()
|
|
|
searchStopAtRecordRange()
|
|
@@ -1405,7 +1410,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
assetPlayer?.seek(to: currentAssetProgress, toleranceBefore: CMTime(value: 1, timescale: 1_000_000), toleranceAfter: CMTime(value: 1, timescale: 1_000_000), completionHandler: { _ in
|
|
|
})
|
|
|
// 暂停状态
|
|
|
- (collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = (itemModels[currItemModelIndex].mediaType == .IMAGE && itemModels[currItemModelIndex].voiceStickers.count <= 0)
|
|
|
+ playBtn.isSelected = (itemModels[currItemModelIndex].mediaType == .IMAGE && itemModels[currItemModelIndex].voiceStickers.count <= 0)
|
|
|
}
|
|
|
|
|
|
func fetchVideo() {
|
|
@@ -1430,6 +1435,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
collectionView.reloadData()
|
|
|
}
|
|
|
+ // 暂停状态--如果是图片素材同时没有录音文件时不显示播放按钮
|
|
|
+ playBtn.isSelected = (itemModels.first?.mediaType == .IMAGE && (itemModels.first?.voiceStickers.count ?? 0) <= 0)
|
|
|
}
|
|
|
|
|
|
func setCoverImage(img: UIImage) {
|
|
@@ -1495,7 +1502,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
self?.endRecord()
|
|
|
cShowHUB(superView: nil, msg: "此视频已录制到头了哦")
|
|
|
}
|
|
|
- (self?.collectionView.cellForItem(at: IndexPath(item: self!.currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = false
|
|
|
+ self?.playBtn.isSelected = false
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1611,9 +1618,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
if let vasset = recordItem.videoAsset, let cell: BFImageCoverViewCell = collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell {
|
|
|
setVideoPlay(item: recordItem.playItem, imageView: cell.playView)
|
|
|
setAudioPlay(item: recordItem.playItem)
|
|
|
- playBtn = cell.playBtn
|
|
|
-// recordItem.videoAsset
|
|
|
-
|
|
|
let degress = degressFromVideoFile(asset: vasset)
|
|
|
switch degress {
|
|
|
case 90:
|
|
@@ -1721,6 +1725,8 @@ extension BFRecordScreenController: UICollectionViewDelegate, UICollectionViewDa
|
|
|
events = itemModels[currItemModelIndex].events
|
|
|
|
|
|
let recordItem = itemModels[currItemModelIndex]
|
|
|
+ // 暂停状态--如果是图片素材同时没有录音文件时不显示播放按钮
|
|
|
+ playBtn.isSelected = (recordItem.mediaType == .IMAGE && recordItem.voiceStickers.count <= 0)
|
|
|
// 重绘录音区域
|
|
|
progressThumV.recordItem = recordItem
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
|
|
@@ -1773,7 +1779,7 @@ public extension BFRecordScreenController {
|
|
|
// 播放对应的录音音频
|
|
|
if itemModels[currItemModelIndex].mediaType == .IMAGE {
|
|
|
if itemModels[currItemModelIndex].materialDuraion <= 0 || currentAssetProgress.seconds >= itemModels[currItemModelIndex].materialDuraion {
|
|
|
- (collectionView.cellForItem(at: IndexPath(item: currItemModelIndex, section: 0)) as? BFImageCoverViewCell)?.playBtn.isSelected = false
|
|
|
+ playBtn.isSelected = true
|
|
|
return
|
|
|
}
|
|
|
isNormalPlaying = true
|