Commit ca58d7ac authored by Soomin Lee's avatar Soomin Lee

MLModel: Cache medialibrary service

parent 51a617e4
......@@ -16,9 +16,12 @@ class AlbumModel: MLBaseModel {
var files = [VLCMLAlbum]()
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("ALBUMS", comment: "")
required init(medialibrary: VLCMediaLibraryManager) {
self.medialibrary = medialibrary
medialibrary.addObserver(self)
// created too late so missed the callback asking if he has anything
files = medialibrary.getAlbums()
......
......@@ -16,9 +16,12 @@ class ArtistModel: MLBaseModel {
var files = [VLCMLArtist]()
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("ARTISTS", comment: "")
required init(medialibrary: VLCMediaLibraryManager) {
self.medialibrary = medialibrary
medialibrary.addObserver(self)
files = medialibrary.getArtists()
}
......
......@@ -16,9 +16,12 @@ class AudioModel: MLBaseModel {
var files = [VLCMLMedia]()
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("SONGS", comment: "")
required init(medialibrary: VLCMediaLibraryManager) {
self.medialibrary = medialibrary
medialibrary.addObserver(self)
// created too late so missed the callback asking if he has anything
files = medialibrary.media(ofType: .audio)
......
......@@ -16,9 +16,12 @@ class GenreModel: MLBaseModel {
var files = [VLCMLGenre]()
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("GENRE", comment: "")
required init(medialibrary: VLCMediaLibraryManager) {
self.medialibrary = medialibrary
medialibrary.addObserver(self)
// created too late so missed the callback asking if he has anything
files = medialibrary.genre()
......
......@@ -31,6 +31,8 @@ protocol MLBaseModel: MediaLibraryBaseModel {
var files: [MLType] { get set }
var medialibrary: VLCMediaLibraryManager { get }
var updateView: (() -> Void)? { get set }
var indicatorName: String { get }
......
......@@ -16,10 +16,12 @@ class ShowEpisodeModel: MLBaseModel {
var files = [VLCMLMedia]()
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("EPISODES", comment: "")
required init(medialibrary: VLCMediaLibraryManager) {
self.medialibrary = medialibrary
medialibrary.addObserver(self)
}
......
......@@ -16,9 +16,12 @@ class VideoModel: MLBaseModel {
var files = [VLCMLMedia]()
var medialibrary: VLCMediaLibraryManager
var indicatorName: String = NSLocalizedString("MOVIES", comment: "")
required init(medialibrary: VLCMediaLibraryManager) {
self.medialibrary = medialibrary
medialibrary.addObserver(self)
files = medialibrary.media(ofType: .video)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment