|
@@ -98,7 +98,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
var avplayerTimeObserver: NSKeyValueObservation?
|
|
var avplayerTimeObserver: NSKeyValueObservation?
|
|
|
|
|
|
lazy var progreddL : UILabel = {
|
|
lazy var progreddL : UILabel = {
|
|
- let l = UILabel(frame: CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cScreenWidth, height: 14))
|
|
|
|
|
|
+ let l = UILabel()
|
|
l.textAlignment = .center
|
|
l.textAlignment = .center
|
|
l.font = UIFont.systemFont(ofSize: 10)
|
|
l.font = UIFont.systemFont(ofSize: 10)
|
|
l.textColor = .white
|
|
l.textColor = .white
|
|
@@ -140,31 +140,11 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
lazy var progessSildeBackV : UIView = {
|
|
lazy var progessSildeBackV : UIView = {
|
|
let vv = UIView()
|
|
let vv = UIView()
|
|
- vv.backgroundColor = UIColor.hexColor(hexadecimal: "#303030")
|
|
|
|
|
|
+ vv.backgroundColor = .orange // .clear
|
|
|
|
|
|
return vv
|
|
return vv
|
|
}()
|
|
}()
|
|
|
|
|
|
- lazy var progessSilde:BFPlayerSlider = {
|
|
|
|
- let sliderView = BFPlayerSlider()
|
|
|
|
- let tjbV = UIView(frame: CGRect(x: 0, y: 0, width: 4, height: 16))
|
|
|
|
- tjbV.backgroundColor = .white
|
|
|
|
- let thbImage = tjbV.graphicsGetImage()//UIImage(named: "icon_point")
|
|
|
|
- sliderView.setMinimumTrackImage(thbImage, for: .normal)
|
|
|
|
- sliderView.setMaximumTrackImage(thbImage, for: .normal)
|
|
|
|
- sliderView.setThumbImage(thbImage, for: .highlighted)
|
|
|
|
- sliderView.setThumbImage(thbImage, for: .normal)
|
|
|
|
- sliderView.maximumTrackTintColor = .clear // UIColor.hexColor(hexadecimal: "#303030")
|
|
|
|
- sliderView.minimumTrackTintColor = .clear //UIColor.hexColor(hexadecimal: "#303030")
|
|
|
|
-// sliderView.minimumTrackTintColor = UIColor.hexColor(hexadecimal: "#FA6400")
|
|
|
|
- sliderView.addTarget(self, action: #selector(sliderTouchBegan(sender:)), for: .touchDown)
|
|
|
|
- sliderView.addTarget(self, action: #selector(sliderTouchEnded(sender:)), for: .touchUpInside)
|
|
|
|
- sliderView.addTarget(self, action: #selector(sliderTouchEnded(sender:)), for: .touchUpOutside)
|
|
|
|
- sliderView.addTarget(self, action: #selector(sliderTouchEnded(sender:)), for: .touchCancel)
|
|
|
|
- sliderView.addTarget(self, action: #selector(sliderValueDidChanged(sender:)), for: .valueChanged)
|
|
|
|
- return sliderView
|
|
|
|
- }()
|
|
|
|
-
|
|
|
|
lazy var withDrawBtn:UIButton = {
|
|
lazy var withDrawBtn:UIButton = {
|
|
let btn = UIButton(type: .custom)
|
|
let btn = UIButton(type: .custom)
|
|
btn.setImage(imageInRecordScreenKit(by: "withdraw_n"), for: .normal)
|
|
btn.setImage(imageInRecordScreenKit(by: "withdraw_n"), for: .normal)
|
|
@@ -208,8 +188,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}()
|
|
}()
|
|
|
|
|
|
lazy var progressThumV : BFVideoThumbProgressView = {
|
|
lazy var progressThumV : BFVideoThumbProgressView = {
|
|
- let vv = BFVideoThumbProgressView(frame: CGRect(x: 0, y: 20, width: cScreenWidth, height: 50), videoAsset: self.avasset!)
|
|
|
|
- vv.dragScrollProgressHandle = { process in
|
|
|
|
|
|
+ let vv = BFVideoThumbProgressView(frame: CGRect(x: 0, y: 54, width: cScreenWidth, height: 50))
|
|
|
|
+ vv.dragScrollProgressHandle = {[weak self] process in
|
|
DispatchQueue.main.async {[weak self] in
|
|
DispatchQueue.main.async {[weak self] in
|
|
guard let sself = self else {
|
|
guard let sself = self else {
|
|
return
|
|
return
|
|
@@ -232,6 +212,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
sself.currentPlayRecordIndex = -1
|
|
sself.currentPlayRecordIndex = -1
|
|
sself.hadPrepareToPlayRecord = false
|
|
sself.hadPrepareToPlayRecord = false
|
|
}
|
|
}
|
|
|
|
+ vv.isHidden = true
|
|
return vv
|
|
return vv
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -266,27 +247,34 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
view.addSubview(playBtn)
|
|
view.addSubview(playBtn)
|
|
view.addSubview(bottomeView)
|
|
view.addSubview(bottomeView)
|
|
- view.addSubview(progreddL)
|
|
|
|
|
|
+ bottomeView.addSubview(progreddL)
|
|
// view.addSubview(toolV)
|
|
// view.addSubview(toolV)
|
|
bottomeView.addSubview(recordBtn)
|
|
bottomeView.addSubview(recordBtn)
|
|
- bottomeView.addSubview(progessSildeBackV)
|
|
|
|
- bottomeView.addSubview(progessSilde)
|
|
|
|
bottomeView.addSubview(withDrawBtn)
|
|
bottomeView.addSubview(withDrawBtn)
|
|
bottomeView.addSubview(changeVoiceBtn)
|
|
bottomeView.addSubview(changeVoiceBtn)
|
|
-
|
|
|
|
|
|
+ bottomeView.addSubview(progressThumV)
|
|
|
|
+ progressThumV.addSubview(progessSildeBackV)
|
|
|
|
+
|
|
if checkStatus() {
|
|
if checkStatus() {
|
|
try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)
|
|
try? AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: .defaultToSpeaker)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ layoutsubview()
|
|
}
|
|
}
|
|
-
|
|
|
|
- public override func viewWillLayoutSubviews() {
|
|
|
|
- super.viewWillLayoutSubviews()
|
|
|
|
|
|
+ func layoutsubview() {
|
|
|
|
+
|
|
bottomeView.snp.makeConstraints { make in
|
|
bottomeView.snp.makeConstraints { make in
|
|
make.left.bottom.right.equalToSuperview()
|
|
make.left.bottom.right.equalToSuperview()
|
|
make.height.equalTo(adapterWidth(width: 220))
|
|
make.height.equalTo(adapterWidth(width: 220))
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ progreddL.snp.makeConstraints { make in
|
|
|
|
+ make.width.equalTo(100)
|
|
|
|
+ make.centerX.equalToSuperview()
|
|
|
|
+ make.bottom.equalTo(progressThumV.snp.top)
|
|
|
|
+ make.height.equalTo(18)
|
|
|
|
+ }
|
|
|
|
+
|
|
withDrawBtn.snp.makeConstraints { make in
|
|
withDrawBtn.snp.makeConstraints { make in
|
|
make.left.equalToSuperview()
|
|
make.left.equalToSuperview()
|
|
make.width.height.equalTo(65)
|
|
make.width.height.equalTo(65)
|
|
@@ -302,21 +290,15 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
make.right.equalTo(changeVoiceBtn.snp.left)
|
|
make.right.equalTo(changeVoiceBtn.snp.left)
|
|
make.height.equalTo(42)
|
|
make.height.equalTo(42)
|
|
make.top.equalTo(withDrawBtn).offset(6)
|
|
make.top.equalTo(withDrawBtn).offset(6)
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
progessSildeBackV.snp.makeConstraints { make in
|
|
progessSildeBackV.snp.makeConstraints { make in
|
|
- make.left.width.equalTo(recordBtn)
|
|
|
|
- make.top.equalTo(recordBtn).offset(-30)
|
|
|
|
|
|
+ make.left.equalToSuperview()
|
|
|
|
+ make.right.equalToSuperview()
|
|
|
|
+ make.bottom.equalToSuperview()
|
|
make.height.equalTo(8)
|
|
make.height.equalTo(8)
|
|
}
|
|
}
|
|
|
|
|
|
- progessSilde.snp.makeConstraints { make in
|
|
|
|
- make.left.right.centerY.equalTo(progessSildeBackV)
|
|
|
|
- make.height.equalTo(20)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
withDrawBtn.imageEdgeInsets = UIEdgeInsets(top: -withDrawBtn.imageView!.height, left: 0, bottom: 0, right: -withDrawBtn.titleLabel!.width);
|
|
withDrawBtn.imageEdgeInsets = UIEdgeInsets(top: -withDrawBtn.imageView!.height, left: 0, bottom: 0, right: -withDrawBtn.titleLabel!.width);
|
|
withDrawBtn.titleEdgeInsets = UIEdgeInsets(top: withDrawBtn.titleLabel!.height + 2, left: -withDrawBtn.imageView!.width, bottom: 0, right: 0);
|
|
withDrawBtn.titleEdgeInsets = UIEdgeInsets(top: withDrawBtn.titleLabel!.height + 2, left: -withDrawBtn.imageView!.width, bottom: 0, right: 0);
|
|
|
|
|
|
@@ -325,8 +307,17 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// public override func viewWillLayoutSubviews() {
|
|
|
|
+// super.viewWillLayoutSubviews()
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+
|
|
// MARK: - 按钮事件响应
|
|
// MARK: - 按钮事件响应
|
|
|
|
|
|
|
|
+ public override func backBtnClick() {
|
|
|
|
+ pause()
|
|
|
|
+ }
|
|
|
|
+
|
|
// 触发拖曳手势后,执行的动作
|
|
// 触发拖曳手势后,执行的动作
|
|
@objc func pan(recognizer: UIPanGestureRecognizer) {
|
|
@objc func pan(recognizer: UIPanGestureRecognizer) {
|
|
// 设置 UIView 新的位置
|
|
// 设置 UIView 新的位置
|
|
@@ -616,7 +607,10 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
if let urlass = asset as? AVURLAsset {
|
|
if let urlass = asset as? AVURLAsset {
|
|
self?.avasset = urlass
|
|
self?.avasset = urlass
|
|
DispatchQueue.main.async {[weak self] in
|
|
DispatchQueue.main.async {[weak self] in
|
|
- self?.bottomeView.addSubview(self!.progressThumV)
|
|
|
|
|
|
+ self?.progressThumV.videoAsset = urlass
|
|
|
|
+ self?.progressThumV.isHidden = false
|
|
|
|
+// self?.progessSildeBackV.setNeedsLayout()
|
|
|
|
+// self?.progessSildeBackV.layoutIfNeeded()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -659,8 +653,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
BFLog(1, message: "curr:\(CMTimeGetSeconds(time))")
|
|
BFLog(1, message: "curr:\(CMTimeGetSeconds(time))")
|
|
if CMTimeGetSeconds(item.duration) > 0, !(self?.isDragingProgressSlder ?? false) {
|
|
if CMTimeGetSeconds(item.duration) > 0, !(self?.isDragingProgressSlder ?? false) {
|
|
DispatchQueue.main.async { [weak self] in
|
|
DispatchQueue.main.async { [weak self] in
|
|
- self?.progessSilde.value = Float(CMTimeGetSeconds(time) / CMTimeGetSeconds(item.duration))
|
|
|
|
- self?.progreddL.text = String(format: "%.2f / %.2f", CMTimeGetSeconds(time), CMTimeGetSeconds(item.duration))
|
|
|
|
|
|
+ self?.progreddL.text = String(format: "%.2f", CMTimeGetSeconds(time), CMTimeGetSeconds(item.duration))
|
|
self?.progressThumV.progress = time.seconds
|
|
self?.progressThumV.progress = time.seconds
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -698,11 +691,12 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
func changeProgress(progress:Float) {
|
|
func changeProgress(progress:Float) {
|
|
if let duration = assetPlayer?.currentItem?.duration {
|
|
if let duration = assetPlayer?.currentItem?.duration {
|
|
self.currentAssetProgress = CMTime(value: CMTimeValue(progress * Float(CMTimeGetSeconds(duration)) * 100), timescale: 100)
|
|
self.currentAssetProgress = CMTime(value: CMTimeValue(progress * Float(CMTimeGetSeconds(duration)) * 100), timescale: 100)
|
|
|
|
+ DispatchQueue.main.async {[weak self] in
|
|
|
|
+ self!.progreddL.text = String(format: "%.2f", CMTimeGetSeconds(self!.currentAssetProgress))
|
|
|
|
+ }
|
|
|
|
+
|
|
assetPlayer!.seek(to: self.currentAssetProgress, toleranceBefore: CMTime(value: 1, timescale: 1000), toleranceAfter: CMTime(value: 1, timescale: 1000)) { finished in
|
|
assetPlayer!.seek(to: self.currentAssetProgress, toleranceBefore: CMTime(value: 1, timescale: 1000), toleranceAfter: CMTime(value: 1, timescale: 1000)) { finished in
|
|
-// if finished{
|
|
|
|
-// BFLog(1, message: "拖动成功 \(progress)")
|
|
|
|
-// self?.movie?.startProcessing()
|
|
|
|
-// }
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|