BFVideoThumbProgressStrategy.swift 818 B

1234567891011121314151617181920212223242526272829303132
  1. //
  2. // BFVideoThumbProgressStrategy.swift
  3. // BFRecordScreenKit
  4. //
  5. // Created by 胡志强 on 2021/12/6.
  6. //
  7. import AVFoundation
  8. import Foundation
  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. }