BFVideoThumbProgressStrategy.swift 843 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // BFVideoThumbProgressStrategy.swift
  3. // BFRecordScreenKit
  4. //
  5. // Created by 胡志强 on 2021/12/6.
  6. //
  7. import Foundation
  8. import AVFoundation
  9. protocol BFVideoThumbProgressStrategyProtocol {
  10. // 根据视频时长获取需要的缩略图数量
  11. func frameNumberOfVideo(assetDuration: Double) -> Int
  12. }
  13. class BFVideoThumbProgressStrategy : BFVideoThumbProgressStrategyProtocol {
  14. func frameNumberOfVideo(assetDuration: Double) -> Int {
  15. var count = -1
  16. if assetDuration > 0 && assetDuration <= 10 {
  17. count = 5
  18. }else if assetDuration >= 10 && assetDuration < 60 {
  19. count = 10
  20. }else if assetDuration >= 60 && assetDuration < 300 {
  21. count = 20
  22. }else if assetDuration >= 300{
  23. count = 30
  24. }
  25. return count
  26. }
  27. }