Commit 1163d8cb authored by Soomin Lee's avatar Soomin Lee

Add AlbumModel

parent 92e66651
/*****************************************************************************
* AlbumModel.swift
*
* Copyright © 2018 VLC authors and VideoLAN
* Copyright © 2018 Videolabs
*
* Authors: Soomin Lee <bubu@mikan.io>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
class AlbumModel: MediaLibraryBaseModel {
typealias MLType = VLCMLAlbum
var files = [VLCMLAlbum]()
var indicatorName: String = NSLocalizedString("ALBUMS", comment: "")
var notificaitonName: Notification.Name = .VLCAlbumsDidChangeNotification
required init(medialibrary: VLCMediaLibraryManager) {
medialibrary.addObserver(self)
// created too late so missed the callback asking if he has anything
files = medialibrary.getAlbums()
}
func isIncluded(_ item: VLCMLAlbum) {
}
func append(_ item: VLCMLAlbum) {
// need to check more for duplicate and stuff
files.append(item)
}
}
extension AlbumModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddAlbum album: [VLCMLAlbum]) {
album.forEach({ append($0) })
NotificationCenter.default.post(name: notificaitonName, object: nil)
}
}
......@@ -30,6 +30,8 @@
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddArtist artist: [VLCMLArtist])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAlbum album: [VLCMLAlbum])
}
class VLCMediaLibraryManager: NSObject {
......@@ -152,8 +154,8 @@ extension VLCMediaLibraryManager {
return medialib.artists(with: .artist, desc: false, all: true)
}
private func getAlbums() {
// albums = MLAlbum.allAlbums() as! [MLAlbum]
func getAlbums() -> [VLCMLAlbum] {
return medialib.albums(with: .album, desc: false)
}
private func getAudioPlaylists() {
......@@ -230,6 +232,13 @@ extension VLCMediaLibraryManager: VLCMediaLibraryDelegate {
}
}
func medialibrary(_ medialibrary: VLCMediaLibrary, didAdd albums: [VLCMLAlbum]) {
print("VLCMediaLibraryDelegate: Did add albums: \(albums), with count: \(albums.count)")
for observer in observers {
observer.value.observer?.medialibrary?(self, didAddAlbum: albums)
}
}
func medialibrary(_ medialibrary: VLCMediaLibrary, didStartDiscovery entryPoint: String) {
}
......
......@@ -52,9 +52,9 @@ class VLCArtistCategoryViewController: VLCMediaCategoryViewController<String, Ar
}
}
class VLCAlbumCategoryViewController: VLCMediaCategoryViewController<MLAlbum, VideoModel> {
class VLCAlbumCategoryViewController: VLCMediaCategoryViewController<MLAlbum, AlbumModel> {
init(_ services: Services) {
let model = VideoModel(medialibrary: services.medialibraryManager)
let model = AlbumModel(medialibrary: services.medialibraryManager)
super.init(services: services, category: model)
}
}
......
......@@ -261,6 +261,7 @@
8DE1888C210B459000A091D2 /* ShowEpisodeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1888B210B459000A091D2 /* ShowEpisodeModel.swift */; };
8DE18890210B53E000A091D2 /* AudioModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1888F210B53E000A091D2 /* AudioModel.swift */; };
8DE18892210B5BAD00A091D2 /* ArtistModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE18891210B5BAD00A091D2 /* ArtistModel.swift */; };
8DE18894210B5F8200A091D2 /* AlbumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE18893210B5F8200A091D2 /* AlbumModel.swift */; };
8F91EC79195CEC7900F5BCBA /* VLCOpenInActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F91EC78195CEC7900F5BCBA /* VLCOpenInActivity.m */; };
8F91EC7F195E1DAB00F5BCBA /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F91EC7E195E1DAB00F5BCBA /* AssetsLibrary.framework */; };
9B088308183D7BEC004B5C2A /* VLCCloudStorageTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B088307183D7BEC004B5C2A /* VLCCloudStorageTableViewController.m */; };
......@@ -953,6 +954,7 @@
8DE1888B210B459000A091D2 /* ShowEpisodeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowEpisodeModel.swift; sourceTree = "<group>"; };
8DE1888F210B53E000A091D2 /* AudioModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioModel.swift; sourceTree = "<group>"; };
8DE18891210B5BAD00A091D2 /* ArtistModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArtistModel.swift; sourceTree = "<group>"; };
8DE18893210B5F8200A091D2 /* AlbumModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlbumModel.swift; sourceTree = "<group>"; };
8F91EC77195CEC7900F5BCBA /* VLCOpenInActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCOpenInActivity.h; path = Sources/VLCOpenInActivity.h; sourceTree = SOURCE_ROOT; };
8F91EC78195CEC7900F5BCBA /* VLCOpenInActivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCOpenInActivity.m; path = Sources/VLCOpenInActivity.m; sourceTree = SOURCE_ROOT; };
8F91EC7E195E1DAB00F5BCBA /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
......@@ -2151,6 +2153,7 @@
8DE1888B210B459000A091D2 /* ShowEpisodeModel.swift */,
8DE1888F210B53E000A091D2 /* AudioModel.swift */,
8DE18891210B5BAD00A091D2 /* ArtistModel.swift */,
8DE18893210B5F8200A091D2 /* AlbumModel.swift */,
);
path = MediaLibraryModel;
sourceTree = "<group>";
......@@ -3305,6 +3308,7 @@
DD3EAC091BE2192A003668DA /* VLCServerBrowsingController.m in Sources */,
7D3784C9183A9972009EE944 /* UIDevice+VLC.m in Sources */,
DDEAECCD1BDECCB800756C83 /* VLCNetworkListViewController.m in Sources */,
8DE18894210B5F8200A091D2 /* AlbumModel.swift in Sources */,
7D3784E9183A9A15009EE944 /* main.m in Sources */,
7D30F3C2183AB24C00FFC021 /* VLCHTTPConnection.m in Sources */,
DD3EFF371BDEBCE500B68579 /* VLCLocalNetworkServiceNetService.m in Sources */,
......
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