Commit 0b2d0b87 authored by Soomin Lee's avatar Soomin Lee

VLCMediaLibraryManager: Remove unnecessary code

parent 45da7268
......@@ -47,7 +47,6 @@ extension NSNotification {
}
class VLCMediaLibraryManager: NSObject {
private static let databaseName: String = "medialibrary.db"
private var databasePath: String!
private var thumbnailPath: String!
......@@ -90,17 +89,13 @@ class VLCMediaLibraryManager: NSObject {
}
medialib.reload()
medialib.discover(onEntryPoint: "file://" + documentPath)
break
case .alreadyInitialized:
assertionFailure("VLCMediaLibraryManager: Medialibrary already initialized.")
break
case .failed:
preconditionFailure("VLCMediaLibraryManager: Failed to setup medialibrary.")
break
case .dbReset:
// should still start and discover but warn the user that the db has been wipped
assertionFailure("VLCMediaLibraryManager: The database was resetted, please re-configure.")
break
}
}
......@@ -159,14 +154,6 @@ extension VLCMediaLibraryManager {
// MARK: MediaDataSource - Audio methods
extension VLCMediaLibraryManager {
private func getAllAudio() {
// foundAudio = medialibrary.media(ofType: .audio)
// artistsFromAudio()
// albumsFromAudio()
// audioPlaylistsFromAudio()
// genresFromAudio()
}
func getArtists() -> [VLCMLArtist] {
return medialib.artists(with: .artist, desc: false, all: true)
}
......@@ -174,56 +161,11 @@ extension VLCMediaLibraryManager {
func getAlbums() -> [VLCMLAlbum] {
return medialib.albums(with: .album, desc: false)
}
private func getAudioPlaylists() {
// let labels = MLLabel.allLabels() as! [MLLabel]
// audioPlaylist = labels.filter {
// let audioFiles = $0.files.filter {
// if let file = $0 as? MLFile {
// return file.isSupportedAudioFile()
// }
// return false
// }
// return !audioFiles.isEmpty
// }
}
private func genresFromAudio() {
// let albumtracks = MLAlbumTrack.allTracks() as! [MLAlbumTrack]
// let tracksWithArtist = albumtracks.filter { $0.genre != nil && $0.genre != "" }
// genres = tracksWithArtist.map { $0.genre }
}
}
// MARK: MediaDataSource - Video methods
extension VLCMediaLibraryManager {
private func getAllVideos() {
// moviesFromVideos()
// episodesFromVideos()
// videoPlaylistsFromVideos()
}
private func getMovies() {
// movies = foundVideos.filter { $0.subtype() == .movie }
}
private func getShowEpisodes() {
// episodes = foundVideos.filter { $0.subtype() == .showEpisode }
}
private func getVideoPlaylists() {
// let labels = MLLabel.allLabels() as! [MLLabel]
// audioPlaylist = labels.filter {
// let audioFiles = $0.files.filter {
// if let file = $0 as? MLFile {
// return file.isShowEpisode() || file.isMovie() || file.isClip()
// }
// return false
// }
// return !audioFiles.isEmpty
// }
}
}
// MARK: VLCMediaLibraryDelegate
......@@ -243,14 +185,12 @@ 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, didAdd albums: [VLCMLAlbum]) {
print("VLCMediaLibraryDelegate: Did add albums: \(albums), with count: \(albums.count)")
for observer in observers {
observer.value.observer?.medialibrary?(self, didAddAlbum: albums)
}
......@@ -268,116 +208,3 @@ extension VLCMediaLibraryManager: VLCMediaLibraryDelegate {
func medialibrary(_ medialibrary: VLCMediaLibrary, didUpdateParsingStatsWithPercent percent: UInt32) {
}
}
// MARK: Future MediaDataSource extension
// Todo: implement the remove
// - (void)removeMediaObjectFromFolder:(NSManagedObject *)managedObject
// {
// NSAssert(([managedObject isKindOfClass:[MLFile class]] && ((MLFile *)managedObject).labels.count > 0), @"All media in a folder should be of type MLFile and it should be in a folder");
//
// if (![managedObject isKindOfClass:[MLFile class]]) return;
//
// MLFile *mediaFile = (MLFile *)managedObject;
// [self rearrangeFolderTrackNumbersForRemovedItem:mediaFile];
// mediaFile.labels = nil;
// mediaFile.folderTrackNumber = nil;
// }
//
// - (void)removeMediaObject:(NSManagedObject *)managedObject
// {
// if ([managedObject isKindOfClass:[MLAlbum class]]) {
// MLAlbum *album = (MLAlbum *)managedObject;
// NSSet *iterAlbumTrack = [NSSet setWithSet:album.tracks];
//
// for (MLAlbumTrack *track in iterAlbumTrack) {
// NSSet *iterFiles = [NSSet setWithSet:track.files];
//
// for (MLFile *file in iterFiles)
// [self _deleteMediaObject:file];
// }
// [[MLMediaLibrary sharedMediaLibrary] removeObject: album];
// // delete all episodes from a show
// } else if ([managedObject isKindOfClass:[MLShow class]]) {
// MLShow *show = (MLShow *)managedObject;
// NSSet *iterShowEpisodes = [NSSet setWithSet:show.episodes];
//
// for (MLShowEpisode *episode in iterShowEpisodes) {
// NSSet *iterFiles = [NSSet setWithSet:episode.files];
//
// for (MLFile *file in iterFiles)
// [self _deleteMediaObject:file];
// }
// [[MLMediaLibrary sharedMediaLibrary] removeObject: show];
// // delete all files from an episode
// } else if ([managedObject isKindOfClass:[MLShowEpisode class]]) {
// MLShowEpisode *episode = (MLShowEpisode *)managedObject;
// NSSet *iterFiles = [NSSet setWithSet:episode.files];
//
// for (MLFile *file in iterFiles)
// [self _deleteMediaObject:file];
// // delete all files from a track
// [[MLMediaLibrary sharedMediaLibrary] removeObject: episode];
// } else if ([managedObject isKindOfClass:[MLAlbumTrack class]]) {
// MLAlbumTrack *track = (MLAlbumTrack *)managedObject;
// NSSet *iterFiles = [NSSet setWithSet:track.files];
//
// for (MLFile *file in iterFiles)
// [self _deleteMediaObject:file];
// } else if ([managedObject isKindOfClass:[MLLabel class]]) {
// MLLabel *folder = (MLLabel *)managedObject;
// NSSet *iterFiles = [NSSet setWithSet:folder.files];
// [folder removeFiles:folder.files];
// for (MLFile *file in iterFiles)
// [self _deleteMediaObject:file];
// [[MLMediaLibrary sharedMediaLibrary] removeObject:folder];
// }
// else
// [self _deleteMediaObject:(MLFile *)managedObject];
// }
//
// - (void)_deleteMediaObject:(MLFile *)mediaObject
// {
// [self rearrangeFolderTrackNumbersForRemovedItem:mediaObject];
//
// /* stop playback if needed */
// VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
// VLCMedia *media = [vpc currentlyPlayingMedia];
// MLFile *currentlyPlayingFile = [MLFile fileForURL:media.url].firstObject;
// if (currentlyPlayingFile && currentlyPlayingFile == mediaObject) {
// [vpc stopPlayback];
// }
//
// NSFileManager *fileManager = [NSFileManager defaultManager];
// NSString *folderLocation = [[mediaObject.url path] stringByDeletingLastPathComponent];
// NSArray *allfiles = [fileManager contentsOfDirectoryAtPath:folderLocation error:nil];
// NSString *fileName = [mediaObject.path.lastPathComponent stringByDeletingPathExtension];
// if (!fileName)
// return;
// NSIndexSet *indexSet = [allfiles indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
// return ([obj rangeOfString:fileName].location != NSNotFound);
// }];
// NSUInteger count = indexSet.count;
// NSString *additionalFilePath;
// NSUInteger currentIndex = [indexSet firstIndex];
// for (unsigned int x = 0; x < count; x++) {
// additionalFilePath = allfiles[currentIndex];
// if ([additionalFilePath isSupportedSubtitleFormat])
// [fileManager removeItemAtPath:[folderLocation stringByAppendingPathComponent:additionalFilePath] error:nil];
// currentIndex = [indexSet indexGreaterThanIndex:currentIndex];
// }
// [fileManager removeItemAtURL:mediaObject.url error:nil];
// }
//
// - (void)rearrangeFolderTrackNumbersForRemovedItem:(MLFile *) mediaObject
// {
// MLLabel *label = [mediaObject.labels anyObject];
// NSSet *allFiles = label.files;
// for (MLFile *file in allFiles) {
// if (file.folderTrackNumber > mediaObject.folderTrackNumber) {
// int value = [file.folderTrackNumber intValue];
// file.folderTrackNumber = [NSNumber numberWithInt:value - 1];
// }
// }
// }
// @end
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