|
@@ -30,7 +30,7 @@ class BFVideoThumbProgressView: UIView {
|
|
var dragStartHandle: (() -> Void)?
|
|
var dragStartHandle: (() -> Void)?
|
|
var isDrag = false
|
|
var isDrag = false
|
|
|
|
|
|
- let thumbImageWidth = 70.0
|
|
|
|
|
|
+ let thumbImageWidth : CGFloat = 70.0
|
|
|
|
|
|
let fetchThumbStrategy: BFVideoThumbProgressStrategyProtocol = BFVideoThumbProgressStrategy()
|
|
let fetchThumbStrategy: BFVideoThumbProgressStrategyProtocol = BFVideoThumbProgressStrategy()
|
|
|
|
|
|
@@ -75,6 +75,14 @@ class BFVideoThumbProgressView: UIView {
|
|
make.width.equalTo(3)
|
|
make.width.equalTo(3)
|
|
make.center.height.equalToSuperview()
|
|
make.center.height.equalToSuperview()
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ progressView.contentView.addSubview(progessIndicateBackV)
|
|
|
|
+ progessIndicateBackV.snp.remakeConstraints { make in
|
|
|
|
+ make.left.equalTo(width * 0.5)
|
|
|
|
+ make.right.equalTo(width * -0.5)
|
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
|
+ make.height.equalTo(6)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
required init?(coder _: NSCoder) {
|
|
required init?(coder _: NSCoder) {
|
|
@@ -102,8 +110,9 @@ class BFVideoThumbProgressView: UIView {
|
|
let date = Date()
|
|
let date = Date()
|
|
let dur = videoAsset.duration.seconds
|
|
let dur = videoAsset.duration.seconds
|
|
if dur > 0 {
|
|
if dur > 0 {
|
|
- let fps = Double(fetchThumbStrategy.frameNumberOfVideo(assetDuration: dur)) / dur
|
|
|
|
- splitVideoFileUrlFps(urlAsset: videoAsset, fps: fps, firstImagesCount: 4) { [weak self] hadGetAll, images in
|
|
|
|
|
|
+ let count = fetchThumbStrategy.frameNumberOfVideo(assetDuration: dur)
|
|
|
|
+ let fps = Double(count) / dur
|
|
|
|
+ splitVideoFileUrlFps(urlAsset: videoAsset, fps: fps, firstImagesCount: Int(ceil(width/2.0/thumbImageWidth))) { [weak self] hadGetAll, images in
|
|
BFLog(1, message: "获取缩略图:\(hadGetAll), \(Date().timeIntervalSince(date))")
|
|
BFLog(1, message: "获取缩略图:\(hadGetAll), \(Date().timeIntervalSince(date))")
|
|
self?.recordItem!.thumbImgs.removeAll()
|
|
self?.recordItem!.thumbImgs.removeAll()
|
|
self?.recordItem!.thumbImgs.append(contentsOf: images)
|
|
self?.recordItem!.thumbImgs.append(contentsOf: images)
|
|
@@ -125,7 +134,9 @@ class BFVideoThumbProgressView: UIView {
|
|
func addThumbImages(images: [UIImage]) {
|
|
func addThumbImages(images: [UIImage]) {
|
|
DispatchQueue.main.async { [weak self] in
|
|
DispatchQueue.main.async { [weak self] in
|
|
self?.progressView.contentView.subviews.forEach { subview in
|
|
self?.progressView.contentView.subviews.forEach { subview in
|
|
- subview.removeFromSuperview()
|
|
|
|
|
|
+ if subview is UIImageView {
|
|
|
|
+ subview.removeFromSuperview()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if images.count > 0 {
|
|
if images.count > 0 {
|
|
self?.thumbImgs = images
|
|
self?.thumbImgs = images
|
|
@@ -135,7 +146,7 @@ class BFVideoThumbProgressView: UIView {
|
|
let iv = UIImageView(image: img)
|
|
let iv = UIImageView(image: img)
|
|
iv.contentMode = .scaleAspectFill
|
|
iv.contentMode = .scaleAspectFill
|
|
iv.clipsToBounds = true
|
|
iv.clipsToBounds = true
|
|
- sself.progressView.contentView.addSubview(iv)
|
|
|
|
|
|
+ sself.progressView.contentView.insertSubview(iv, belowSubview: sself.progessIndicateBackV)
|
|
iv.snp.makeConstraints { make in
|
|
iv.snp.makeConstraints { make in
|
|
make.left.equalTo(CGFloat(i) * CGFloat(sself.thumbImageWidth) + sself.width * 0.5)
|
|
make.left.equalTo(CGFloat(i) * CGFloat(sself.thumbImageWidth) + sself.width * 0.5)
|
|
make.top.bottom.equalToSuperview()
|
|
make.top.bottom.equalToSuperview()
|
|
@@ -148,13 +159,13 @@ class BFVideoThumbProgressView: UIView {
|
|
make.right.equalTo(sself.width * -0.5)
|
|
make.right.equalTo(sself.width * -0.5)
|
|
}
|
|
}
|
|
|
|
|
|
- sself.progressView.contentView.addSubview(sself.progessIndicateBackV)
|
|
|
|
- sself.progessIndicateBackV.snp.makeConstraints { make in
|
|
|
|
- make.left.equalTo(sself.width * 0.5)
|
|
|
|
- make.right.equalTo(sself.width * -0.5)
|
|
|
|
- make.bottom.equalToSuperview()
|
|
|
|
- make.height.equalTo(6)
|
|
|
|
- }
|
|
|
|
|
|
+// sself.progressView.contentView.addSubview(sself.progessIndicateBackV)
|
|
|
|
+// sself.progessIndicateBackV.snp.remakeConstraints { make in
|
|
|
|
+// make.left.equalTo(sself.width * 0.5)
|
|
|
|
+// make.right.equalTo(sself.width * -0.5)
|
|
|
|
+// make.bottom.equalToSuperview()
|
|
|
|
+// make.height.equalTo(6)
|
|
|
|
+// }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|