SoundCellViewModel.swift 636 B

123456789101112131415161718192021222324252627
  1. //
  2. // SoundCellViewModel.swift
  3. // Bark
  4. //
  5. // Created by huangfeng on 2020/11/17.
  6. // Copyright © 2020 Fin. All rights reserved.
  7. //
  8. import AVKit
  9. import Foundation
  10. import RxCocoa
  11. import RxSwift
  12. class SoundCellViewModel: ViewModel {
  13. let name = BehaviorRelay<String>(value: "")
  14. let duration = BehaviorRelay<CMTime>(value: .zero)
  15. let copyNameAction = PublishRelay<String>()
  16. let playAction = PublishRelay<CFURL>()
  17. let model: AVURLAsset
  18. init(model: AVURLAsset) {
  19. self.model = model
  20. name.accept(model.url.deletingPathExtension().lastPathComponent)
  21. duration.accept(model.duration)
  22. }
  23. }