|
@@ -20,18 +20,12 @@
|
|
|
#import "VLCNotificationRelay.h"
|
|
|
#import "VLCWatchTableController.h"
|
|
|
#import "NSManagedObjectContext+refreshAll.h"
|
|
|
+#import "MLMediaLibrary+playlist.h"
|
|
|
|
|
|
static NSString *const rowType = @"mediaRow";
|
|
|
static NSString *const VLCDBUpdateNotification = @"VLCUpdateDataBase";
|
|
|
static NSString *const VLCDBUpdateNotificationRemote = @"org.videolan.ios-app.dbupdate";
|
|
|
|
|
|
-typedef enum {
|
|
|
- VLCLibraryModeAllFiles = 0,
|
|
|
- VLCLibraryModeAllAlbums = 1,
|
|
|
- VLCLibraryModeAllSeries = 2,
|
|
|
- VLCLibraryModeInGroup = 3
|
|
|
-} VLCLibraryMode;
|
|
|
-
|
|
|
@interface VLCPlaylistInterfaceController()
|
|
|
{
|
|
|
CGRect _thumbnailSize;
|
|
@@ -62,7 +56,7 @@ typedef enum {
|
|
|
} else {
|
|
|
self.groupObject = context;
|
|
|
self.title = [self.groupObject name];
|
|
|
- self.libraryMode = VLCLibraryModeInGroup;
|
|
|
+ self.libraryMode = VLCLibraryModeNone;
|
|
|
}
|
|
|
[self addNowPlayingMenu];
|
|
|
|
|
@@ -140,77 +134,6 @@ typedef enum {
|
|
|
self.tableController.objects = [self mediaArray];
|
|
|
}
|
|
|
|
|
|
-//TODO: this code could use refactoring to be more readable
|
|
|
-- (NSMutableArray *)mediaArray {
|
|
|
-
|
|
|
- if (_libraryMode == VLCLibraryModeInGroup) {
|
|
|
- id groupObject = self.groupObject;
|
|
|
-
|
|
|
- if([groupObject isKindOfClass:[MLLabel class]]) {
|
|
|
- return [NSMutableArray arrayWithArray:[(MLLabel *)groupObject sortedFolderItems]];
|
|
|
- } else if ([groupObject isKindOfClass:[MLAlbum class]]) {
|
|
|
- return [NSMutableArray arrayWithArray:[(MLAlbum *)groupObject sortedTracks]];
|
|
|
- } else if ([groupObject isKindOfClass:[MLShow class]]){
|
|
|
- return [NSMutableArray arrayWithArray:[(MLShow *)groupObject sortedEpisodes]];
|
|
|
- } else {
|
|
|
- NSAssert(NO, @"this shouldn't have happened check the grouObjects type");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- NSMutableArray *objects = [NSMutableArray array];
|
|
|
-
|
|
|
- /* add all albums */
|
|
|
- if (_libraryMode != VLCLibraryModeAllSeries) {
|
|
|
- NSArray *rawAlbums = [MLAlbum allAlbums];
|
|
|
- for (MLAlbum *album in rawAlbums) {
|
|
|
- if (album.name.length > 0 && album.tracks.count > 1)
|
|
|
- [objects addObject:album];
|
|
|
- }
|
|
|
- }
|
|
|
- if (_libraryMode == VLCLibraryModeAllAlbums) {
|
|
|
- return objects;
|
|
|
- }
|
|
|
-
|
|
|
- /* add all shows */
|
|
|
- NSArray *rawShows = [MLShow allShows];
|
|
|
- for (MLShow *show in rawShows) {
|
|
|
- if (show.name.length > 0 && show.episodes.count > 1)
|
|
|
- [objects addObject:show];
|
|
|
- }
|
|
|
- if (_libraryMode == VLCLibraryModeAllSeries) {
|
|
|
- return objects;
|
|
|
- }
|
|
|
-
|
|
|
- /* add all folders*/
|
|
|
- NSArray *allFolders = [MLLabel allLabels];
|
|
|
- for (MLLabel *folder in allFolders)
|
|
|
- [objects addObject:folder];
|
|
|
-
|
|
|
- /* add all remaining files */
|
|
|
- NSArray *allFiles = [MLFile allFiles];
|
|
|
- for (MLFile *file in allFiles) {
|
|
|
- if (file.labels.count > 0) continue;
|
|
|
-
|
|
|
- if (!file.isShowEpisode && !file.isAlbumTrack)
|
|
|
- [objects addObject:file];
|
|
|
- else if (file.isShowEpisode) {
|
|
|
- if (file.showEpisode.show.episodes.count < 2)
|
|
|
- [objects addObject:file];
|
|
|
-
|
|
|
- /* older MediaLibraryKit versions don't send a show name in a popular
|
|
|
- * corner case. hence, we need to work-around here and force a reload
|
|
|
- * afterwards as this could lead to the 'all my shows are gone'
|
|
|
- * syndrome (see #10435, #10464, #10432 et al) */
|
|
|
- if (file.showEpisode.show.name.length == 0) {
|
|
|
- file.showEpisode.show.name = NSLocalizedString(@"UNTITLED_SHOW", nil);
|
|
|
- }
|
|
|
- } else if (file.isAlbumTrack) {
|
|
|
- if (file.albumTrack.album.tracks.count < 2)
|
|
|
- [objects addObject:file];
|
|
|
- }
|
|
|
- }
|
|
|
- return objects;
|
|
|
-}
|
|
|
|
|
|
- (void)setLibraryMode:(VLCLibraryMode)libraryMode
|
|
|
{
|
|
@@ -219,4 +142,14 @@ typedef enum {
|
|
|
_libraryMode = libraryMode;
|
|
|
}
|
|
|
|
|
|
+- (NSArray *)mediaArray
|
|
|
+{
|
|
|
+ id groupObject = self.groupObject;
|
|
|
+ if (groupObject) {
|
|
|
+ return [[MLMediaLibrary sharedMediaLibrary] playlistArrayForGroupObject:groupObject];
|
|
|
+ } else {
|
|
|
+ return [[MLMediaLibrary sharedMediaLibrary] playlistArrayForLibraryMode:self.libraryMode];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
@end
|