VideoModel.swift 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*****************************************************************************
  2. * VideoModel.swift
  3. *
  4. * Copyright © 2018 VLC authors and VideoLAN
  5. * Copyright © 2018 Videolabs
  6. *
  7. * Authors: Soomin Lee <bubu@mikan.io>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. class VideoModel: MediaLibraryBaseModel {
  12. typealias MLType = VLCMLMedia
  13. var files = [VLCMLMedia]()
  14. var indicatorName: String = NSLocalizedString("MOVIES", comment: "")
  15. var notificaitonName: Notification.Name = .VLCVideosDidChangeNotification
  16. required init(medialibrary: VLCMediaLibraryManager) {
  17. medialibrary.addObserver(self)
  18. }
  19. func isIncluded(_ item: VLCMLMedia) {
  20. }
  21. func append(_ item: VLCMLMedia) {
  22. files.append(item)
  23. }
  24. }
  25. extension VideoModel: MediaLibraryObserver {
  26. func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddVideo video: [VLCMLMedia]) {
  27. video.forEach({ append($0) })
  28. NotificationCenter.default.post(name: notificaitonName, object: nil)
  29. }
  30. }