فهرست منبع

library: when trying to play an item from an album, build a media list and play that one instead, so we can listen to the other tracks without going to back to the library

Felix Paul Kühne 11 سال پیش
والد
کامیت
44cd3745b5
3فایلهای تغییر یافته به همراه30 افزوده شده و 1 حذف شده
  1. 1 0
      Sources/VLCAppDelegate.h
  2. 14 0
      Sources/VLCAppDelegate.m
  3. 15 1
      Sources/VLCPlaylistViewController.m

+ 1 - 0
Sources/VLCAppDelegate.h

@@ -31,6 +31,7 @@
 
 - (void)openMediaFromManagedObject:(NSManagedObject *)file;
 - (void)openMovieFromURL:(NSURL *)url;
+- (void)openMediaList:(VLCMediaList*)list atIndex:(NSUInteger)index;
 
 @property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
 @property (nonatomic, readonly) VLCDropboxTableViewController *dropboxTableViewController;

+ 14 - 0
Sources/VLCAppDelegate.m

@@ -334,4 +334,18 @@
     [self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
 }
 
+- (void)openMediaList:(VLCMediaList*)list atIndex:(NSUInteger)index
+{
+    if (!_movieViewController)
+        _movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
+
+    _movieViewController.mediaList = list;
+    _movieViewController.itemInMediaListToBePlayedFirst = index;
+
+    UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_movieViewController];
+    navCon.modalPresentationStyle = UIModalPresentationFullScreen;
+    [self.window.rootViewController presentViewController:navCon animated:YES completion:nil];
+}
+
+
 @end

+ 15 - 1
Sources/VLCPlaylistViewController.m

@@ -430,7 +430,21 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
 
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
     NSManagedObject *selectedObject = _foundMedia[indexPath.row];
-    [self openMediaObject:selectedObject];
+
+    if ([selectedObject isKindOfClass:[MLAlbumTrack class]]) {
+        VLCMediaList *list;
+        NSArray *tracks = [[(MLAlbumTrack*)selectedObject album] sortedTracks];
+        NSUInteger count = tracks.count;
+        list = [[VLCMediaList alloc] init];
+
+        MLFile *file;
+        for (NSUInteger x = 0; x < count; x++) {
+            file = [(MLAlbumTrack*)tracks[x] files].anyObject;
+            [list addMedia:[VLCMedia mediaWithURL: [NSURL URLWithString:file.url]]];
+        }
+        [(VLCAppDelegate*)[UIApplication sharedApplication].delegate openMediaList:list atIndex:[tracks indexOfObject:selectedObject]];
+    } else
+        [self openMediaObject:selectedObject];
 }
 
 #pragma mark - table view gestures