Commit 978ea73f authored by Soomin Lee's avatar Soomin Lee

VLCMediaLibraryManager: Update callback methods

parent 74c14767
......@@ -32,8 +32,8 @@ class AlbumModel: MLBaseModel {
}
extension AlbumModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddAlbum album: [VLCMLAlbum]) {
album.forEach({ append($0) })
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddAlbums albums: [VLCMLAlbum]) {
albums.forEach({ append($0) })
updateView?()
}
}
......@@ -32,8 +32,8 @@ class ArtistModel: MLBaseModel {
}
extension ArtistModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddArtist artist: [VLCMLArtist]) {
artist.forEach({ append($0) })
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddArtists artists: [VLCMLArtist]) {
artists.forEach({ append($0) })
updateView?()
}
}
......@@ -44,8 +44,8 @@ extension AudioModel {
// MARK: - MediaLibraryObserver
extension AudioModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddAudio audio: [VLCMLMedia]) {
audio.forEach({ append($0) })
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddAudios audios: [VLCMLMedia]) {
audios.forEach({ append($0) })
updateView?()
}
}
......@@ -32,8 +32,8 @@ class GenreModel: MLBaseModel {
}
extension GenreModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddGenre genre: [VLCMLGenre]) {
genre.forEach({ append($0) })
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddGenres genres: [VLCMLGenre]) {
genres.forEach({ append($0) })
updateView?()
}
}
......@@ -31,8 +31,8 @@ class ShowEpisodeModel: MLBaseModel {
}
extension ShowEpisodeModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddShowEpisode showEpisode: [VLCMLMedia]) {
showEpisode.forEach({ append($0) })
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddShowEpisodes showEpisodes: [VLCMLMedia]) {
showEpisodes.forEach({ append($0) })
updateView?()
}
}
......@@ -43,8 +43,8 @@ extension VideoModel {
// MARK: - MediaLibraryObserver
extension VideoModel: MediaLibraryObserver {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddVideo video: [VLCMLMedia]) {
video.forEach({ append($0) })
func medialibrary(_ medialibrary: VLCMediaLibraryManager, didAddVideos videos: [VLCMLMedia]) {
videos.forEach({ append($0) })
updateView?()
}
}
......
......@@ -20,30 +20,31 @@ extension NSNotification {
}
@objc protocol MediaLibraryObserver: class {
// Video
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didUpdateVideo video: [VLCMLMedia])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddVideo video: [VLCMLMedia])
didAddVideos videos: [VLCMLMedia])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddShowEpisode showEpisode: [VLCMLMedia])
didAddShowEpisodes showEpisodes: [VLCMLMedia])
// Audio
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAudio audio: [VLCMLMedia])
didAddAudios audios: [VLCMLMedia])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAlbumTrack audio: [VLCMLMedia])
didAddAlbumTracks tracks: [VLCMLMedia])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddArtist artist: [VLCMLArtist])
didAddArtists artists: [VLCMLArtist])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAlbum album: [VLCMLAlbum])
didAddAlbums albums: [VLCMLAlbum])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddGenre genre: [VLCMLGenre])
didAddGenres genres: [VLCMLGenre])
}
class VLCMediaLibraryManager: NSObject {
......@@ -167,28 +168,28 @@ extension VLCMediaLibraryManager {
// MARK: VLCMediaLibraryDelegate
extension VLCMediaLibraryManager: VLCMediaLibraryDelegate {
func medialibrary(_ medialibrary: VLCMediaLibrary, didAddMedia media: [VLCMLMedia]) {
let video = media.filter {( $0.type() == .video )}
let videos = media.filter {( $0.type() == .video )}
let audio = media.filter {( $0.type() == .audio )}
let showEpisode = media.filter {( $0.subtype() == .showEpisode )}
let showEpisodes = media.filter {( $0.subtype() == .showEpisode )}
let albumTrack = media.filter {( $0.subtype() == .albumTrack )}
for observer in observers {
observer.value.observer?.medialibrary?(self, didAddVideo: video)
observer.value.observer?.medialibrary?(self, didAddAudio: audio)
observer.value.observer?.medialibrary?(self, didAddShowEpisode: showEpisode)
observer.value.observer?.medialibrary?(self, didAddAlbumTrack: albumTrack)
observer.value.observer?.medialibrary?(self, didAddVideos: videos)
observer.value.observer?.medialibrary?(self, didAddAudios: audio)
observer.value.observer?.medialibrary?(self, didAddShowEpisodes: showEpisodes)
observer.value.observer?.medialibrary?(self, didAddAlbumTracks: albumTrack)
}
}
func medialibrary(_ medialibrary: VLCMediaLibrary, didAdd artists: [VLCMLArtist]) {
for observer in observers {
observer.value.observer?.medialibrary?(self, didAddArtist: artists)
observer.value.observer?.medialibrary?(self, didAddArtists: artists)
}
}
func medialibrary(_ medialibrary: VLCMediaLibrary, didAdd albums: [VLCMLAlbum]) {
for observer in observers {
observer.value.observer?.medialibrary?(self, didAddAlbum: albums)
observer.value.observer?.medialibrary?(self, didAddAlbums: albums)
}
}
......
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