Commit 92e66651 authored by Soomin Lee's avatar Soomin Lee

Add ArtistModel

parent 5bd13edd
/*****************************************************************************
* ArtistModel.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 ArtistModel: MediaLibraryBaseModel {
typealias MLType = VLCMLArtist
var files = [VLCMLArtist]()
var indicatorName: String = NSLocalizedString("ARTISTS", comment: "")
var notificaitonName: Notification.Name = .VLCArtistsDidChangeNotification
required init(medialibrary: VLCMediaLibraryManager) {
medialibrary.addObserver(self)
files = medialibrary.getArtists()
}
func isIncluded(_ item: VLCMLArtist) {
}
func append(_ item: VLCMLArtist) {
files.append(item)
}
}
extension ArtistModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddArtist artist: [VLCMLArtist]) {
artist.forEach({ append($0) })
NotificationCenter.default.post(name: notificaitonName, object: nil)
}
}
......@@ -26,6 +26,10 @@
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAlbumTrack audio: [VLCMLMedia])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddArtist artist: [VLCMLArtist])
}
class VLCMediaLibraryManager: NSObject {
......@@ -144,10 +148,8 @@ extension VLCMediaLibraryManager {
// genresFromAudio()
}
private func getArtists() {
// let albumtracks = MLAlbumTrack.allTracks() as! [MLAlbumTrack]
// let tracksWithArtist = albumtracks.filter { $0.artist != nil && $0.artist != "" }
// artists = tracksWithArtist.map { $0.artist }
func getArtists() -> [VLCMLArtist] {
return medialib.artists(with: .artist, desc: false, all: true)
}
private func getAlbums() {
......@@ -221,6 +223,13 @@ extension VLCMediaLibraryManager: VLCMediaLibraryDelegate {
}
}
func medialibrary(_ medialibrary: VLCMediaLibrary, didAdd artists: [VLCMLArtist]) {
print("VLCMediaLibraryDelegate: Did add artists: \(artists), with count: \(artists.count)")
for observer in observers {
observer.value.observer?.medialibrary?(self, didAddArtist: artists)
}
}
func medialibrary(_ medialibrary: VLCMediaLibrary, didStartDiscovery entryPoint: String) {
}
......
......@@ -45,9 +45,9 @@ class VLCGenreCategoryViewController: VLCMediaCategoryViewController<String, Vid
}
}
class VLCArtistCategoryViewController: VLCMediaCategoryViewController<String, VideoModel> {
class VLCArtistCategoryViewController: VLCMediaCategoryViewController<String, ArtistModel> {
init(_ services: Services) {
let model = VideoModel(medialibrary: services.medialibraryManager)
let model = ArtistModel(medialibrary: services.medialibraryManager)
super.init(services: services, category: model)
}
}
......
......@@ -260,6 +260,7 @@
8DE1887621089BB100A091D2 /* VideoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE1887521089BB100A091D2 /* VideoModel.swift */; };
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 */; };
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 */; };
......@@ -951,6 +952,7 @@
8DE1887521089BB100A091D2 /* VideoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoModel.swift; sourceTree = "<group>"; };
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>"; };
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; };
......@@ -2148,6 +2150,7 @@
8DE1887521089BB100A091D2 /* VideoModel.swift */,
8DE1888B210B459000A091D2 /* ShowEpisodeModel.swift */,
8DE1888F210B53E000A091D2 /* AudioModel.swift */,
8DE18891210B5BAD00A091D2 /* ArtistModel.swift */,
);
path = MediaLibraryModel;
sourceTree = "<group>";
......@@ -3341,6 +3344,7 @@
8DE18890210B53E000A091D2 /* AudioModel.swift in Sources */,
419A2C661F37A4B70069D224 /* VLCStringsForLocalization.m in Sources */,
DDA1B9091CE902EE0076BC45 /* VLCNetworkServerLoginInformation+Keychain.m in Sources */,
8DE18892210B5BAD00A091D2 /* ArtistModel.swift in Sources */,
7D30F3DF183AB31E00FFC021 /* VLCWiFiUploadTableViewCell.m in Sources */,
7D30F3EA183AB34200FFC021 /* VLCGoogleDriveController.m in Sources */,
417D7F601F7BA26200DDF36A /* VLCRemoteControlService.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