Commit 1bc267a0 authored by Soomin Lee's avatar Soomin Lee

VLCMediaLibraryManager: Add additional medialib cb

parent 06bffb5f
...@@ -38,21 +38,29 @@ extension NSNotification { ...@@ -38,21 +38,29 @@ extension NSNotification {
didAddAudios audios: [VLCMLMedia]) didAddAudios audios: [VLCMLMedia])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager, @objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAlbumTracks tracks: [VLCMLMedia]) didAddArtists artists: [VLCMLArtist])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager, @objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddArtists artists: [VLCMLArtist]) didDeleteArtistsWithIds artistsIds: [NSNumber])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager, @objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAlbums albums: [VLCMLAlbum]) didAddAlbums albums: [VLCMLAlbum])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didDeleteAlbumsWithIds albumsIds: [NSNumber])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddAlbumTracks albumTracks: [VLCMLMedia])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager, @objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddGenres genres: [VLCMLGenre]) didAddGenres genres: [VLCMLGenre])
// Playlist // Playlist
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager, @objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didAddPlaylists playlists: [VLCMLPlaylist]) didAddPlaylists playlists: [VLCMLPlaylist])
@objc optional func medialibrary(_ medialibrary: VLCMediaLibraryManager,
didDeletePlaylistsWithIds playlistsIds: [NSNumber])
} }
class VLCMediaLibraryManager: NSObject { class VLCMediaLibraryManager: NSObject {
...@@ -196,12 +204,18 @@ extension VLCMediaLibraryManager: VLCMediaLibraryDelegate { ...@@ -196,12 +204,18 @@ extension VLCMediaLibraryManager: VLCMediaLibraryDelegate {
func medialibrary(_ medialibrary: VLCMediaLibrary, didAddMedia media: [VLCMLMedia]) { func medialibrary(_ medialibrary: VLCMediaLibrary, didAddMedia media: [VLCMLMedia]) {
let videos = media.filter {( $0.type() == .video )} let videos = media.filter {( $0.type() == .video )}
let audio = media.filter {( $0.type() == .audio )} let audio = media.filter {( $0.type() == .audio )}
let showEpisodes = media.filter {( $0.subtype() == .showEpisode )}
let albumTrack = media.filter {( $0.subtype() == .albumTrack )}
for observer in observers { for observer in observers {
observer.value.observer?.medialibrary?(self, didAddVideos: videos) observer.value.observer?.medialibrary?(self, didAddVideos: videos)
observer.value.observer?.medialibrary?(self, didAddAudios: audio) observer.value.observer?.medialibrary?(self, didAddAudios: audio)
}
}
func medialibrary(_ medialibrary: VLCMediaLibrary, didUpdateMedia media: [VLCMLMedia]) {
let showEpisodes = media.filter {( $0.subtype() == .showEpisode )}
let albumTrack = media.filter {( $0.subtype() == .albumTrack )}
for observer in observers {
observer.value.observer?.medialibrary?(self, didAddShowEpisodes: showEpisodes) observer.value.observer?.medialibrary?(self, didAddShowEpisodes: showEpisodes)
observer.value.observer?.medialibrary?(self, didAddAlbumTracks: albumTrack) observer.value.observer?.medialibrary?(self, didAddAlbumTracks: albumTrack)
} }
...@@ -222,6 +236,12 @@ extension VLCMediaLibraryManager { ...@@ -222,6 +236,12 @@ extension VLCMediaLibraryManager {
observer.value.observer?.medialibrary?(self, didAddArtists: artists) observer.value.observer?.medialibrary?(self, didAddArtists: artists)
} }
} }
func medialibrary(_ medialibrary: VLCMediaLibrary, didDeleteArtistsWithIds artistsIds: [NSNumber]) {
for observer in observers {
observer.value.observer?.medialibrary?(self, didDeleteArtistsWithIds: artistsIds)
}
}
} }
// MARK: - VLCMediaLibraryDelegate - Albums // MARK: - VLCMediaLibraryDelegate - Albums
...@@ -232,6 +252,12 @@ extension VLCMediaLibraryManager { ...@@ -232,6 +252,12 @@ extension VLCMediaLibraryManager {
observer.value.observer?.medialibrary?(self, didAddAlbums: albums) observer.value.observer?.medialibrary?(self, didAddAlbums: albums)
} }
} }
func medialibrary(_ medialibrary: VLCMediaLibrary, didDeleteAlbumsWithIds albumsIds: [NSNumber]) {
for observer in observers {
observer.value.observer?.medialibrary?(self, didDeleteAlbumsWithIds: albumsIds)
}
}
} }
// MARK: - VLCMediaLibraryDelegate - Playlists // MARK: - VLCMediaLibraryDelegate - Playlists
...@@ -242,6 +268,12 @@ extension VLCMediaLibraryManager { ...@@ -242,6 +268,12 @@ extension VLCMediaLibraryManager {
observer.value.observer?.medialibrary?(self, didAddPlaylists: playlists) observer.value.observer?.medialibrary?(self, didAddPlaylists: playlists)
} }
} }
func medialibrary(_ medialibrary: VLCMediaLibrary, didDeletePlaylistsWithIds playlistsIds: [NSNumber]) {
for observer in observers {
observer.value.observer?.medialibrary?(self, didDeletePlaylistsWithIds: playlistsIds)
}
}
} }
// MARK: - VLCMediaLibraryDelegate - Discovery // MARK: - VLCMediaLibraryDelegate - Discovery
......
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