|
@@ -77,11 +77,12 @@ class BFVideoThumbProgressView: UIView {
|
|
|
}
|
|
|
|
|
|
progressView.contentView.addSubview(progessIndicateBackV)
|
|
|
- progessIndicateBackV.snp.remakeConstraints { make in
|
|
|
+ progessIndicateBackV.snp.makeConstraints { make in
|
|
|
make.left.equalTo(width * 0.5)
|
|
|
make.right.equalTo(width * -0.5)
|
|
|
make.bottom.equalToSuperview()
|
|
|
make.height.equalTo(6)
|
|
|
+ make.width.equalTo(1)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -104,6 +105,7 @@ class BFVideoThumbProgressView: UIView {
|
|
|
}
|
|
|
self.addThumbImages(images: recordItem!.thumbImgs)
|
|
|
if recordItem!.thumbImgs.count > 0{
|
|
|
+ // 代表已经获取过了,不用在重新去获得
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -111,12 +113,28 @@ class BFVideoThumbProgressView: UIView {
|
|
|
let dur = videoAsset.duration.seconds
|
|
|
if dur > 0 {
|
|
|
let count = fetchThumbStrategy.frameNumberOfVideo(assetDuration: dur)
|
|
|
+ progessIndicateBackV.snp.remakeConstraints { make in
|
|
|
+ make.left.equalTo(width * 0.5)
|
|
|
+ make.right.equalTo(width * -0.5)
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
+ make.height.equalTo(6)
|
|
|
+ make.width.equalTo(CGFloat(count) * thumbImageWidth)
|
|
|
+ }
|
|
|
+
|
|
|
let fps = Double(count) / dur
|
|
|
splitVideoFileUrlFps(urlAsset: videoAsset, fps: fps, firstImagesCount: Int(ceil(width/2.0/thumbImageWidth))) { [weak self] hadGetAll, images in
|
|
|
+ guard let sself = self, let recordItem = sself.recordItem else {
|
|
|
+ return
|
|
|
+ }
|
|
|
BFLog(1, message: "获取缩略图:\(hadGetAll), \(Date().timeIntervalSince(date))")
|
|
|
- self?.recordItem!.thumbImgs.removeAll()
|
|
|
- self?.recordItem!.thumbImgs.append(contentsOf: images)
|
|
|
- self?.addThumbImages(images: images)
|
|
|
+ recordItem.thumbImgs.removeAll()
|
|
|
+ recordItem.thumbImgs.append(contentsOf: images)
|
|
|
+
|
|
|
+ // 不足数则补充足够帧数
|
|
|
+ while (hadGetAll && recordItem.thumbImgs.count < count && images.count > 0) {
|
|
|
+ recordItem.thumbImgs.append(images.last!)
|
|
|
+ }
|
|
|
+ sself.addThumbImages(images: recordItem.thumbImgs)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -139,9 +157,8 @@ class BFVideoThumbProgressView: UIView {
|
|
|
}
|
|
|
}
|
|
|
if images.count > 0 {
|
|
|
- self?.thumbImgs = images
|
|
|
+// self?.thumbImgs = images
|
|
|
if let sself = self {
|
|
|
- var lastiv = UIImageView()
|
|
|
for (i, img) in images.enumerated() {
|
|
|
let iv = UIImageView(image: img)
|
|
|
iv.contentMode = .scaleAspectFill
|
|
@@ -153,19 +170,7 @@ class BFVideoThumbProgressView: UIView {
|
|
|
make.height.equalTo(50)
|
|
|
make.width.equalTo(sself.thumbImageWidth)
|
|
|
}
|
|
|
- lastiv = iv
|
|
|
- }
|
|
|
- lastiv.snp.makeConstraints { make in
|
|
|
- make.right.equalTo(sself.width * -0.5)
|
|
|
}
|
|
|
-
|
|
|
-// 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)
|
|
|
-// }
|
|
|
}
|
|
|
}
|
|
|
}
|