VLCPlaylistViewController.m 18.8 KB
Newer Older
Felix Paul Kühne's avatar
Felix Paul Kühne committed
1 2 3 4 5 6 7
//
//  VLCMasterViewController.m
//  AspenProject
//
//  Created by Felix Paul Kühne on 27.02.13.
//  Copyright (c) 2013 VideoLAN. All rights reserved.
//
8 9
//  Refer to the COPYING file of the official project for license.
//
Felix Paul Kühne's avatar
Felix Paul Kühne committed
10 11

#import "VLCPlaylistViewController.h"
12
#import "VLCMovieViewController.h"
13
#import "VLCPlaylistTableViewCell.h"
14
#import "VLCPlaylistGridView.h"
Romain Goyet's avatar
Romain Goyet committed
15
#import "UINavigationController+Theme.h"
16
#import "NSString+SupportedMedia.h"
17
#import "VLCBugreporter.h"
18
#import "VLCAppDelegate.h"
19
#import "UIBarButtonItem+Theme.h"
Felix Paul Kühne's avatar
Felix Paul Kühne committed
20

21 22 23
@implementation EmptyLibraryView
@end

24
@interface VLCPlaylistViewController () <AQGridViewDataSource, AQGridViewDelegate, UITableViewDataSource, UITableViewDelegate, MLMediaLibrary> {
Felix Paul Kühne's avatar
Felix Paul Kühne committed
25
    NSMutableArray *_foundMedia;
26
    NSUInteger _libraryMode;
27
    UIBarButtonItem *_menuButton;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
28 29 30 31 32
}
@end

@implementation VLCPlaylistViewController

33 34 35
- (void)loadView {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
36
        _tableView.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
37 38 39 40 41 42 43
        _tableView.delegate = self;
        _tableView.dataSource = self;
        self.view = _tableView;
    } else {
        _gridView = [[AQGridView alloc] initWithFrame:[UIScreen mainScreen].bounds];
        _gridView.delegate = self;
        _gridView.dataSource = self;
44
        _gridView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"libraryBackground"]];
45 46 47
        self.view = _gridView;
    }

48 49
    _libraryMode = kVLCLibraryModeAllFiles;

50 51 52 53 54 55
    self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    self.emptyLibraryView = [[[NSBundle mainBundle] loadNibNamed:@"VLCEmptyLibraryView" owner:self options:nil] lastObject];
}

#pragma mark -

Felix Paul Kühne's avatar
Felix Paul Kühne committed
56 57 58 59
- (void)viewDidLoad
{
    [super viewDidLoad];

60
    _menuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(leftButtonAction:)];
61 62 63 64 65 66 67 68 69 70

    /* After day 354 of the year, the usual VLC cone is replaced by another cone
     * wearing a Father Xmas hat.
     * Note: this icon doesn't represent an endorsement of The Coca-Cola Company
     * and should not be confused with the idea of religious statements or propagation there off
     */
    NSCalendar *gregorian =
    [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSDayCalendarUnit inUnit:NSYearCalendarUnit forDate:[NSDate date]];
    if (dayOfYear >= 354)
71
        _menuButton.image = [UIImage imageNamed:@"vlc-xmas"];
72

73
    self.navigationItem.leftBarButtonItem = _menuButton;
74

75 76 77 78
    [self.editButtonItem setBackgroundImage:[UIImage imageNamed:@"button"]
                                   forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [self.editButtonItem setBackgroundImage:[UIImage imageNamed:@"buttonHighlight"]
                                   forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
79

80
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
81 82 83
        _gridView.separatorStyle = AQGridViewCellSeparatorStyleEmptySpace;
        _gridView.alwaysBounceVertical = YES;
        _gridView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
84 85
    } else {
        _tableView.rowHeight = [VLCPlaylistTableViewCell heightOfCell];
86
        _tableView.separatorColor = [UIColor colorWithWhite:.122 alpha:1.];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
87
    }
Felix Paul Kühne's avatar
Felix Paul Kühne committed
88
    self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
89

90 91 92 93 94
    _emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", @"");
    _emptyLibraryView.emptyLibraryLongDescriptionLabel.lineBreakMode = UILineBreakModeWordWrap;
    _emptyLibraryView.emptyLibraryLongDescriptionLabel.numberOfLines = 0;
    _emptyLibraryView.emptyLibraryLongDescriptionLabel.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", @"");
    [_emptyLibraryView.emptyLibraryLongDescriptionLabel sizeToFit];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
95 96
}

97 98 99
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
100
    [self _displayEmptyLibraryViewIfNeeded];
101 102
}

103 104
- (void)viewDidAppear:(BOOL)animated
{
105 106
    [super viewDidAppear:animated];

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    if ([[MLMediaLibrary sharedMediaLibrary] libraryNeedsUpgrade]) {
        self.navigationItem.rightBarButtonItem = nil;
        self.navigationItem.leftBarButtonItem = nil;
        self.emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"UPGRADING_LIBRARY", @"");
        self.emptyLibraryView.emptyLibraryLongDescriptionLabel.hidden = YES;
        [self.emptyLibraryView.activityIndicator startAnimating];
        self.emptyLibraryView.frame = self.view.frame;
        self.title = @"";
        [self.view addSubview:self.emptyLibraryView];

        [[MLMediaLibrary sharedMediaLibrary] setDelegate: self];
        [[MLMediaLibrary sharedMediaLibrary] performSelectorInBackground:@selector(upgradeLibrary) withObject:nil];
        return;
    }

122 123
    if (_foundMedia.count < 1)
        [self performSelector:@selector(reloadContents) withObject:nil afterDelay:.0];
124 125 126 127 128 129 130 131 132
    [[MLMediaLibrary sharedMediaLibrary] performSelector:@selector(libraryDidAppear) withObject:nil afterDelay:1.];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [[MLMediaLibrary sharedMediaLibrary] libraryDidDisappear];
}

133 134 135 136 137 138 139 140 141 142 143
- (BOOL)canBecomeFirstResponder
{
    return YES;
}

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
    if (motion == UIEventSubtypeMotionShake)
        [[VLCBugreporter sharedInstance] handleBugreportRequest];
}

144 145
- (void)removeMediaObject:(MLFile *)mediaObject
{
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSString *folderLocation = [[[NSURL URLWithString:mediaObject.url] path] stringByDeletingLastPathComponent];
    NSArray *allfiles = [fileManager contentsOfDirectoryAtPath:folderLocation error:nil];
    NSString *fileName = [[[[NSURL URLWithString:mediaObject.url] path] lastPathComponent] stringByDeletingPathExtension];
    NSIndexSet *indexSet = [allfiles indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
       return ([obj rangeOfString:fileName].location != NSNotFound);
    }];
    unsigned int 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 removeItemAtPath:[[NSURL URLWithString:mediaObject.url] path] error:nil];
163
    [[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase];
164
    [self reloadContents];
165 166 167 168 169 170 171 172
}

- (void)_displayEmptyLibraryViewIfNeeded
{
    if (_foundMedia.count > 0) {
        if (self.emptyLibraryView.superview)
            [self.emptyLibraryView removeFromSuperview];
    } else {
173
        self.emptyLibraryView.frame = self.view.frame;
174 175
        [self.view addSubview:self.emptyLibraryView];
    }
176 177 178 179
    if (_libraryMode == kVLCLibraryModeAllFiles && _foundMedia.count > 0)
        self.navigationItem.rightBarButtonItem = self.editButtonItem;
    else
        self.navigationItem.rightBarButtonItem = nil;
180 181 182 183 184

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        _tableView.separatorStyle = (_foundMedia.count > 0)? UITableViewCellSeparatorStyleSingleLine:
                                                             UITableViewCellSeparatorStyleNone;
    }
185 186
}

187 188 189 190 191 192 193 194 195 196 197 198
- (void)libraryUpgradeComplete
{
    self.emptyLibraryView.emptyLibraryLongDescriptionLabel.hidden = NO;
    self.emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", @"");
    [self.emptyLibraryView.activityIndicator stopAnimating];
    self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
    self.navigationItem.leftBarButtonItem = _menuButton;
    [self.emptyLibraryView removeFromSuperview];

    [self reloadContents];
}

199
- (void)reloadContents
Felix Paul Kühne's avatar
Felix Paul Kühne committed
200
{
201 202 203 204 205 206 207 208 209 210 211 212
    if (_libraryMode == kVLCLibraryModeAllAlbums) {
        NSArray *rawAlbums = [MLAlbum allAlbums];
        _foundMedia = [[NSMutableArray alloc] init];
        NSUInteger count = rawAlbums.count;
        MLAlbum *album;

        for (NSUInteger x = 0; x < count; x++) {
            album = rawAlbums[x];
            if (album.name.length > 0 && album.tracks.count > 0)
                [_foundMedia addObject:album];
        }
        rawAlbums = nil;
213 214 215 216 217 218 219 220 221 222 223 224
    } else if (_libraryMode == kVLCLibraryModeAllSeries) {
        NSArray *rawShows = [MLShow allShows];
        _foundMedia = [[NSMutableArray alloc] init];
        NSUInteger count = rawShows.count;
        MLShow *show;

        for (NSUInteger x = 0; x < count; x++) {
            show = rawShows[x];
            if (show.name.length > 0 && show.episodes.count > 0)
                [_foundMedia addObject:show];
        }
        rawShows = nil;
225 226 227 228 229
    } else
        _foundMedia = [NSMutableArray arrayWithArray:[MLFile allFiles]];

    [self updateViewContents];
}
230

231 232
- (void)updateViewContents
{
233
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
234
        [self.tableView reloadData];
235
    else {
236
        [self.gridView reloadData];
237
        [self.gridView setNeedsLayout];
238
    }
239 240

    [self _displayEmptyLibraryViewIfNeeded];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
241 242
}

243 244
#pragma mark - Table View

Felix Paul Kühne's avatar
Felix Paul Kühne committed
245 246 247 248 249 250 251 252 253 254 255 256 257
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _foundMedia.count;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
258
    static NSString *CellIdentifier = @"PlaylistCell";
Felix Paul Kühne's avatar
Felix Paul Kühne committed
259

260
    VLCPlaylistTableViewCell *cell = (VLCPlaylistTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
261
    if (cell == nil)
262
        cell = [VLCPlaylistTableViewCell cellWithReuseIdentifier:CellIdentifier];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
263

264 265
    NSInteger row = indexPath.row;
    cell.mediaObject = _foundMedia[row];
266

Felix Paul Kühne's avatar
Felix Paul Kühne committed
267 268 269
    return cell;
}

270 271 272 273 274
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.backgroundColor = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor colorWithWhite:.122 alpha:1.];
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
275 276 277 278 279 280 281
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
282 283
    if (editingStyle == UITableViewCellEditingStyleDelete)
        [self removeMediaObject: _foundMedia[indexPath.row]];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
284 285
}

286
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Felix Paul Kühne's avatar
Felix Paul Kühne committed
287
{
288 289
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

290 291 292
    NSManagedObject *currentObject = _foundMedia[indexPath.row];
    if ([currentObject isKindOfClass:[MLAlbum class]]) {
        _foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
293 294 295
        self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
        [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
        self.title = [(MLAlbum*)currentObject name];
296 297 298
        [self updateViewContents];
    } else if ([currentObject isKindOfClass:[MLShow class]]) {
        _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
299 300 301
        self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
        [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
        self.title = [(MLShow*)currentObject name];
302 303 304 305
        [self updateViewContents];
    } else {
        if (!self.movieViewController)
            self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
306

307 308
        if ([currentObject isKindOfClass:[MLFile class]])
            self.movieViewController.mediaItem = (MLFile *)currentObject;
309
        else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
310
            self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
311 312
        else if ([currentObject isKindOfClass:[MLShowEpisode class]])
            self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
313 314 315

        [self.navigationController pushViewController:self.movieViewController animated:YES];
    }
Felix Paul Kühne's avatar
Felix Paul Kühne committed
316 317
}

318 319
#pragma mark - AQGridView
- (NSUInteger)numberOfItemsInGridView:(AQGridView *)gridView
Felix Paul Kühne's avatar
Felix Paul Kühne committed
320
{
321
    return _foundMedia.count;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
322 323
}

324
- (AQGridViewCell *)gridView:(AQGridView *)gridView cellForItemAtIndex:(NSUInteger)index
Felix Paul Kühne's avatar
Felix Paul Kühne committed
325
{
326
    static NSString *AQCellIdentifier = @"AQPlaylistCell";
327

328
    VLCPlaylistGridView *cell = (VLCPlaylistGridView *)[gridView dequeueReusableCellWithIdentifier:AQCellIdentifier];
329
    if (cell == nil) {
330
        cell = [[[NSBundle mainBundle] loadNibNamed:@"VLCPlaylistGridView" owner:self options:nil] lastObject];
331
        cell.selectionStyle = AQGridViewCellSelectionStyleNone;
332
        cell.gridView = gridView;
333 334
    }

335
    cell.mediaObject = _foundMedia[index];
336 337 338 339 340 341

    return cell;
}

- (CGSize)portraitGridCellSizeForGridView:(AQGridView *)gridView
{
342
    return [VLCPlaylistGridView preferredSize];
343 344 345 346
}

- (void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index
{
347 348
    [self.gridView deselectItemAtIndex:index animated:YES];

349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
    NSManagedObject *currentObject = _foundMedia[index];
    if ([currentObject isKindOfClass:[MLAlbum class]]) {
        _foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
        self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
        [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
        self.title = [(MLAlbum*)currentObject name];
        [self updateViewContents];
    } else if ([currentObject isKindOfClass:[MLShow class]]) {
        _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
        self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
        [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
        self.title = [(MLShow*)currentObject name];
        [self updateViewContents];
    } else {
        if (!self.movieViewController)
            self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];

        if ([currentObject isKindOfClass:[MLFile class]])
            self.movieViewController.mediaItem = (MLFile *)currentObject;
        else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
            self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
        else if ([currentObject isKindOfClass:[MLShowEpisode class]])
            self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
Felix Paul Kühne's avatar
Felix Paul Kühne committed
372

373 374
        [self.navigationController pushViewController:self.movieViewController animated:YES];
    }
Felix Paul Kühne's avatar
Felix Paul Kühne committed
375 376
}

377 378 379 380 381 382
- (void)gridView:(AQGridView *)aGridView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndex:(NSUInteger)index
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
        [self removeMediaObject: _foundMedia[index]];
}

383
#pragma mark - UI implementation
384 385
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
386 387 388
    if (_libraryMode != kVLCLibraryModeAllFiles)
        return;

389
    [super setEditing:editing animated:animated];
390

Felix Paul Kühne's avatar
Felix Paul Kühne committed
391
    UIBarButtonItem *editButton = self.editButtonItem;
392 393
    NSString *editImage = editing? @"doneButton": @"button";
    NSString *editImageHighlight = editing? @"doneButtonHighlight": @"buttonHighlight";
Felix Paul Kühne's avatar
Felix Paul Kühne committed
394
    [editButton setBackgroundImage:[UIImage imageNamed:editImage] forState:UIControlStateNormal
395
                                 barMetrics:UIBarMetricsDefault];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
396
    [editButton setBackgroundImage:[UIImage imageNamed:editImageHighlight]
397
                                   forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
Felix Paul Kühne's avatar
Felix Paul Kühne committed
398 399
    [editButton setTitleTextAttributes: editing ? @{UITextAttributeTextShadowColor : [UIColor whiteColor], UITextAttributeTextColor : [UIColor blackColor]} : @{UITextAttributeTextShadowColor : [UIColor colorWithWhite:0. alpha:.37], UITextAttributeTextColor : [UIColor whiteColor]} forState:UIControlStateNormal];

400
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
401
        [self.gridView setEditing:editing];
402
    else
403
        [self.tableView setEditing:editing animated:YES];
404 405
}

406
- (IBAction)leftButtonAction:(id)sender
407
{
408
    [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
409 410
}

411 412 413 414 415 416
- (IBAction)backToAllItems:(id)sender
{
    self.navigationItem.leftBarButtonItem = _menuButton;
    [self setLibraryMode:_libraryMode];
}

417
/* deprecated in iOS 6 */
418 419
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
420 421 422 423
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return YES;

    return (_foundMedia.count > 0) || toInterfaceOrientation == UIInterfaceOrientationPortrait;
424 425
}

426 427
// RootController is responsible for supporting interface orientation(iOS6.0+), i.e. navigation controller
// so this will not work as intended without "voodoo magic"(UINavigationController category, subclassing, etc)
428 429
/* introduced in iOS 6 */
- (NSUInteger)supportedInterfaceOrientations {
430 431 432 433 434
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskAll;

    return (_foundMedia.count > 0)? UIInterfaceOrientationMaskAllButUpsideDown:
                                    UIInterfaceOrientationMaskPortrait;
435 436 437 438
}

/* introduced in iOS 6 */
- (BOOL)shouldAutorotate {
439
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (_foundMedia.count > 0);
440 441
}

442
#pragma mark - coin coin
443

444 445 446
- (void)openMovieFromURL:(NSURL *)url
{
    if (!self.movieViewController)
447
        self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
448

449 450 451
    if (self.navigationController.topViewController != self.movieViewController)
        [self.navigationController pushViewController:self.movieViewController animated:YES];

452
    self.movieViewController.url = url;
453 454
}

455 456 457
- (void)setLibraryMode:(NSUInteger)mode
{
    _libraryMode = mode;
458

459 460 461 462 463 464 465
    if (_libraryMode == kVLCLibraryModeAllAlbums)
        self.title = NSLocalizedString(@"LIBRARY_MUSIC", @"");
    else if( _libraryMode == kVLCLibraryModeAllSeries)
        self.title = NSLocalizedString(@"LIBRARY_SERIES", @"");
    else
        self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");

466 467 468
    [self reloadContents];
}

Felix Paul Kühne's avatar
Felix Paul Kühne committed
469
@end