Ver código fonte

Add 'Play All' button for network shares

Only exposed on iOS so far

(cherry picked from commit 8bd8ee300b4cc1aeecbe72c870082490ef96905f)
Felix Paul Kühne 9 anos atrás
pai
commit
0aee14a8e7

+ 1 - 0
Sources/LocalNetworkConnectivity/VLCNetworkListViewController.h

@@ -18,6 +18,7 @@ extern NSString *VLCNetworkListCellIdentifier;
 
 @property (nonatomic, strong) UITableView *tableView;
 
+- (IBAction)playAllAction:(id)sender;
 - (void)tableView:(UITableView *)tableView willDisplayCell:(VLCNetworkListCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
 
 @end

+ 10 - 1
Sources/LocalNetworkConnectivity/VLCNetworkListViewController.m

@@ -77,7 +77,11 @@ NSString *VLCNetworkListCellIdentifier = @"VLCNetworkListCellIdentifier";
     _tapTwiceGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self  action:@selector(tapTwiceGestureAction:)];
     [_tapTwiceGestureRecognizer setNumberOfTapsRequired:2];
 
-    self.navigationItem.rightBarButtonItem = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(menuButtonAction:)];
+    UIBarButtonItem *playAllButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(playAllAction:)];
+    playAllButton.accessibilityLabel = NSLocalizedString(@"PLAY_ALL_BUTTON", nil);
+    playAllButton.isAccessibilityElement = YES;
+    self.navigationItem.rightBarButtonItems = @[[UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(menuButtonAction:)],
+                                                playAllButton];
 
     _searchData = [[NSMutableArray alloc] init];
     [_searchData removeAllObjects];
@@ -108,6 +112,11 @@ NSString *VLCNetworkListCellIdentifier = @"VLCNetworkListCellIdentifier";
         [self setEditing:NO animated:YES];
 }
 
+- (IBAction)playAllAction:(id)sender
+{
+    // to be implemented by subclass
+}
+
 #pragma mark - Table view data source
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

+ 20 - 0
Sources/LocalNetworkConnectivity/VLCNetworkServerBrowserViewController.m

@@ -123,6 +123,26 @@
     }
 }
 
+- (void)playAllAction:(id)sender
+{
+    VLCMediaList *fullMediaList = self.serverBrowser.mediaList;
+    NSUInteger count = fullMediaList.count;
+    NSMutableArray *fileList = [[NSMutableArray alloc] init];
+    for (NSUInteger x = count - 1; x > 0; x--) {
+        VLCMedia *media = [fullMediaList mediaAtIndex:x];
+        VLCMediaType mediaType = media.mediaType;
+        if (mediaType == VLCMediaTypeFile || mediaType == VLCMediaTypeStream || mediaType == VLCMediaTypeUnknown) {
+            [fileList addObject:media];
+        }
+    }
+
+    if (fileList.count > 0) {
+        VLCMediaList *fileMediaList = [[VLCMediaList alloc] initWithArray:fileList];
+        [self.browsingController configureSubtitlesInMediaList:fileMediaList];
+        [self.browsingController streamMediaList:fileMediaList startingAtIndex:0];
+    }
+}
+
 #pragma mark - table view data source, for more see super
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section