VLCPlaylistViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. //
  2. // VLCMasterViewController.m
  3. // AspenProject
  4. //
  5. // Created by Felix Paul Kühne on 27.02.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. // Refer to the COPYING file of the official project for license.
  9. //
  10. #import "VLCPlaylistViewController.h"
  11. #import "VLCMovieViewController.h"
  12. #import "VLCPlaylistTableViewCell.h"
  13. #import "VLCPlaylistGridView.h"
  14. #import "UINavigationController+Theme.h"
  15. #import "NSString+SupportedMedia.h"
  16. #import "VLCBugreporter.h"
  17. #import "VLCAppDelegate.h"
  18. #import "UIBarButtonItem+Theme.h"
  19. #import "AQGridView.h"
  20. #ifndef UIStatusBarStyleLightContent
  21. #define UIStatusBarStyleLightContent 1
  22. #endif
  23. @implementation EmptyLibraryView
  24. @end
  25. @interface VLCPlaylistViewController () <AQGridViewDataSource, AQGridViewDelegate, UITableViewDataSource, UITableViewDelegate, MLMediaLibrary> {
  26. NSMutableArray *_foundMedia;
  27. VLCLibraryMode _libraryMode;
  28. UIBarButtonItem *_menuButton;
  29. }
  30. @end
  31. @implementation VLCPlaylistViewController
  32. - (void)loadView {
  33. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  34. _tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
  35. _tableView.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  36. _tableView.delegate = self;
  37. _tableView.dataSource = self;
  38. self.view = _tableView;
  39. } else {
  40. _gridView = [[AQGridView alloc] initWithFrame:[UIScreen mainScreen].bounds];
  41. _gridView.delegate = self;
  42. _gridView.dataSource = self;
  43. _gridView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"libraryBackground"]];
  44. self.view = _gridView;
  45. }
  46. _libraryMode = VLCLibraryModeAllFiles;
  47. self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
  48. self.emptyLibraryView = [[[NSBundle mainBundle] loadNibNamed:@"VLCEmptyLibraryView" owner:self options:nil] lastObject];
  49. }
  50. #pragma mark -
  51. - (void)viewDidLoad
  52. {
  53. [super viewDidLoad];
  54. _menuButton = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(leftButtonAction:)];
  55. /* After day 354 of the year, the usual VLC cone is replaced by another cone
  56. * wearing a Father Xmas hat.
  57. * Note: this icon doesn't represent an endorsement of The Coca-Cola Company
  58. * and should not be confused with the idea of religious statements or propagation there off
  59. */
  60. NSCalendar *gregorian =
  61. [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  62. NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSDayCalendarUnit inUnit:NSYearCalendarUnit forDate:[NSDate date]];
  63. if (dayOfYear >= 354)
  64. _menuButton.image = [UIImage imageNamed:@"vlc-xmas"];
  65. self.navigationItem.leftBarButtonItem = _menuButton;
  66. if (SYSTEM_RUNS_IN_THE_FUTURE)
  67. self.editButtonItem.tintColor = [UIColor whiteColor];
  68. else {
  69. [self.editButtonItem setBackgroundImage:[UIImage imageNamed:@"button"]
  70. forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  71. [self.editButtonItem setBackgroundImage:[UIImage imageNamed:@"buttonHighlight"]
  72. forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  73. }
  74. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  75. _gridView.separatorStyle = AQGridViewCellSeparatorStyleEmptySpace;
  76. _gridView.alwaysBounceVertical = YES;
  77. _gridView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
  78. } else {
  79. _tableView.rowHeight = [VLCPlaylistTableViewCell heightOfCell];
  80. _tableView.separatorColor = [UIColor colorWithWhite:.122 alpha:1.];
  81. }
  82. self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
  83. _emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", @"");
  84. _emptyLibraryView.emptyLibraryLongDescriptionLabel.lineBreakMode = UILineBreakModeWordWrap;
  85. _emptyLibraryView.emptyLibraryLongDescriptionLabel.numberOfLines = 0;
  86. _emptyLibraryView.emptyLibraryLongDescriptionLabel.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", @"");
  87. [_emptyLibraryView.emptyLibraryLongDescriptionLabel sizeToFit];
  88. }
  89. - (void)viewWillAppear:(BOOL)animated
  90. {
  91. [super viewWillAppear:animated];
  92. [self _displayEmptyLibraryViewIfNeeded];
  93. }
  94. - (void)viewDidAppear:(BOOL)animated
  95. {
  96. [super viewDidAppear:animated];
  97. if ([[MLMediaLibrary sharedMediaLibrary] libraryNeedsUpgrade]) {
  98. self.navigationItem.rightBarButtonItem = nil;
  99. self.navigationItem.leftBarButtonItem = nil;
  100. self.emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"UPGRADING_LIBRARY", @"");
  101. self.emptyLibraryView.emptyLibraryLongDescriptionLabel.hidden = YES;
  102. [self.emptyLibraryView.activityIndicator startAnimating];
  103. self.emptyLibraryView.frame = self.view.frame;
  104. self.title = @"";
  105. [self.view addSubview:self.emptyLibraryView];
  106. [[MLMediaLibrary sharedMediaLibrary] setDelegate: self];
  107. [[MLMediaLibrary sharedMediaLibrary] performSelectorInBackground:@selector(upgradeLibrary) withObject:nil];
  108. return;
  109. }
  110. if (_foundMedia.count < 1)
  111. [self updateViewContents];
  112. [[MLMediaLibrary sharedMediaLibrary] performSelector:@selector(libraryDidAppear) withObject:nil afterDelay:1.];
  113. if (SYSTEM_RUNS_IN_THE_FUTURE)
  114. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  115. }
  116. - (void)viewDidDisappear:(BOOL)animated
  117. {
  118. [super viewDidDisappear:animated];
  119. [[MLMediaLibrary sharedMediaLibrary] libraryDidDisappear];
  120. }
  121. - (BOOL)canBecomeFirstResponder
  122. {
  123. return YES;
  124. }
  125. - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
  126. {
  127. if (motion == UIEventSubtypeMotionShake)
  128. [[VLCBugreporter sharedInstance] handleBugreportRequest];
  129. }
  130. - (void)removeMediaObject:(MLFile *)mediaObject
  131. {
  132. NSFileManager *fileManager = [NSFileManager defaultManager];
  133. NSString *folderLocation = [[[NSURL URLWithString:mediaObject.url] path] stringByDeletingLastPathComponent];
  134. NSArray *allfiles = [fileManager contentsOfDirectoryAtPath:folderLocation error:nil];
  135. NSString *fileName = [[[[NSURL URLWithString:mediaObject.url] path] lastPathComponent] stringByDeletingPathExtension];
  136. NSIndexSet *indexSet = [allfiles indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
  137. return ([obj rangeOfString:fileName].location != NSNotFound);
  138. }];
  139. unsigned int count = indexSet.count;
  140. NSString *additionalFilePath;
  141. NSUInteger currentIndex = [indexSet firstIndex];
  142. for (unsigned int x = 0; x < count; x++) {
  143. additionalFilePath = allfiles[currentIndex];
  144. if ([additionalFilePath isSupportedSubtitleFormat])
  145. [fileManager removeItemAtPath:[folderLocation stringByAppendingPathComponent:additionalFilePath] error:nil];
  146. currentIndex = [indexSet indexGreaterThanIndex:currentIndex];
  147. }
  148. [fileManager removeItemAtPath:[[NSURL URLWithString:mediaObject.url] path] error:nil];
  149. [[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase];
  150. [self updateViewContents];
  151. }
  152. - (void)_displayEmptyLibraryViewIfNeeded
  153. {
  154. if (self.emptyLibraryView.superview)
  155. [self.emptyLibraryView removeFromSuperview];
  156. if (_foundMedia.count <= 0) {
  157. self.emptyLibraryView.frame = self.view.frame;
  158. [self.view addSubview:self.emptyLibraryView];
  159. }
  160. if (_libraryMode == VLCLibraryModeAllFiles && _foundMedia.count > 0)
  161. self.navigationItem.rightBarButtonItem = self.editButtonItem;
  162. else
  163. self.navigationItem.rightBarButtonItem = nil;
  164. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
  165. _tableView.separatorStyle = (_foundMedia.count > 0)? UITableViewCellSeparatorStyleSingleLine:
  166. UITableViewCellSeparatorStyleNone;
  167. }
  168. }
  169. - (void)libraryUpgradeComplete
  170. {
  171. self.emptyLibraryView.emptyLibraryLongDescriptionLabel.hidden = NO;
  172. self.emptyLibraryView.emptyLibraryLabel.text = NSLocalizedString(@"EMPTY_LIBRARY", @"");
  173. [self.emptyLibraryView.activityIndicator stopAnimating];
  174. self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
  175. self.navigationItem.leftBarButtonItem = _menuButton;
  176. [self.emptyLibraryView removeFromSuperview];
  177. [self updateViewContents];
  178. }
  179. - (void)libraryWasUpdated
  180. {
  181. NSLog(@"libraryWasUpdated");
  182. [self updateViewContents];
  183. }
  184. - (void)updateViewContents
  185. {
  186. if (_libraryMode == VLCLibraryModeAllAlbums) {
  187. NSArray *rawAlbums = [MLAlbum allAlbums];
  188. _foundMedia = [[NSMutableArray alloc] init];
  189. NSUInteger count = rawAlbums.count;
  190. MLAlbum *album;
  191. for (NSUInteger x = 0; x < count; x++) {
  192. album = rawAlbums[x];
  193. if (album.name.length > 0 && album.tracks.count > 0)
  194. [_foundMedia addObject:album];
  195. }
  196. rawAlbums = nil;
  197. } else if (_libraryMode == VLCLibraryModeAllSeries) {
  198. NSArray *rawShows = [MLShow allShows];
  199. _foundMedia = [[NSMutableArray alloc] init];
  200. NSUInteger count = rawShows.count;
  201. MLShow *show;
  202. for (NSUInteger x = 0; x < count; x++) {
  203. show = rawShows[x];
  204. if (show.name.length > 0 && show.episodes.count > 0)
  205. [_foundMedia addObject:show];
  206. }
  207. rawShows = nil;
  208. } else
  209. _foundMedia = [NSMutableArray arrayWithArray:[MLFile allFiles]];
  210. [self reloadViews];
  211. }
  212. - (void)reloadViews
  213. {
  214. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  215. [self.tableView reloadData];
  216. else {
  217. [self.gridView reloadData];
  218. [self.gridView performSelector:@selector(reloadData) withObject:nil afterDelay:2.];
  219. }
  220. [self _displayEmptyLibraryViewIfNeeded];
  221. }
  222. #pragma mark - Table View
  223. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  224. {
  225. return 1;
  226. }
  227. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  228. {
  229. return _foundMedia.count;
  230. }
  231. // Customize the appearance of table view cells.
  232. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  233. {
  234. static NSString *CellIdentifier = @"PlaylistCell";
  235. VLCPlaylistTableViewCell *cell = (VLCPlaylistTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  236. if (cell == nil)
  237. cell = [VLCPlaylistTableViewCell cellWithReuseIdentifier:CellIdentifier];
  238. NSInteger row = indexPath.row;
  239. cell.mediaObject = _foundMedia[row];
  240. return cell;
  241. }
  242. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  243. {
  244. cell.backgroundColor = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor colorWithWhite:.122 alpha:1.];
  245. }
  246. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  247. {
  248. return YES;
  249. }
  250. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  251. {
  252. if (editingStyle == UITableViewCellEditingStyleDelete)
  253. [self removeMediaObject: _foundMedia[indexPath.row]];
  254. }
  255. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  256. {
  257. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  258. NSManagedObject *currentObject = _foundMedia[indexPath.row];
  259. if ([currentObject isKindOfClass:[MLAlbum class]]) {
  260. _foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
  261. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  262. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
  263. self.title = [(MLAlbum*)currentObject name];
  264. [self reloadViews];
  265. } else if ([currentObject isKindOfClass:[MLShow class]]) {
  266. _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
  267. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  268. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
  269. self.title = [(MLShow*)currentObject name];
  270. [self reloadViews];
  271. } else {
  272. if (!self.movieViewController)
  273. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  274. if ([currentObject isKindOfClass:[MLFile class]])
  275. self.movieViewController.mediaItem = (MLFile *)currentObject;
  276. else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
  277. self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
  278. else if ([currentObject isKindOfClass:[MLShowEpisode class]])
  279. self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
  280. [self.navigationController pushViewController:self.movieViewController animated:YES];
  281. }
  282. }
  283. #pragma mark - AQGridView
  284. - (NSUInteger)numberOfItemsInGridView:(AQGridView *)gridView
  285. {
  286. return _foundMedia.count;
  287. }
  288. - (AQGridViewCell *)gridView:(AQGridView *)gridView cellForItemAtIndex:(NSUInteger)index
  289. {
  290. static NSString *AQCellIdentifier = @"AQPlaylistCell";
  291. VLCPlaylistGridView *cell = (VLCPlaylistGridView *)[gridView dequeueReusableCellWithIdentifier:AQCellIdentifier];
  292. if (cell == nil) {
  293. cell = [[[NSBundle mainBundle] loadNibNamed:@"VLCPlaylistGridView" owner:self options:nil] lastObject];
  294. cell.selectionStyle = AQGridViewCellSelectionStyleNone;
  295. cell.gridView = gridView;
  296. }
  297. cell.mediaObject = _foundMedia[index];
  298. return cell;
  299. }
  300. - (CGSize)portraitGridCellSizeForGridView:(AQGridView *)gridView
  301. {
  302. return [VLCPlaylistGridView preferredSize];
  303. }
  304. - (void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index
  305. {
  306. [self.gridView deselectItemAtIndex:index animated:YES];
  307. NSManagedObject *currentObject = _foundMedia[index];
  308. if ([currentObject isKindOfClass:[MLAlbum class]]) {
  309. _foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
  310. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  311. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
  312. self.title = [(MLAlbum*)currentObject name];
  313. [self reloadViews];
  314. } else if ([currentObject isKindOfClass:[MLShow class]]) {
  315. _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
  316. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  317. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
  318. self.title = [(MLShow*)currentObject name];
  319. [self reloadViews];
  320. } else {
  321. if (!self.movieViewController)
  322. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  323. if ([currentObject isKindOfClass:[MLFile class]])
  324. self.movieViewController.mediaItem = (MLFile *)currentObject;
  325. else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
  326. self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
  327. else if ([currentObject isKindOfClass:[MLShowEpisode class]])
  328. self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
  329. [self.navigationController pushViewController:self.movieViewController animated:YES];
  330. }
  331. }
  332. - (void)gridView:(AQGridView *)aGridView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndex:(NSUInteger)index
  333. {
  334. if (editingStyle == UITableViewCellEditingStyleDelete)
  335. [self removeMediaObject: _foundMedia[index]];
  336. }
  337. #pragma mark - UI implementation
  338. - (void)setEditing:(BOOL)editing animated:(BOOL)animated
  339. {
  340. if (_libraryMode != VLCLibraryModeAllFiles)
  341. return;
  342. [super setEditing:editing animated:animated];
  343. UIBarButtonItem *editButton = self.editButtonItem;
  344. NSString *editImage = editing? @"doneButton": @"button";
  345. NSString *editImageHighlight = editing? @"doneButtonHighlight": @"buttonHighlight";
  346. if (SYSTEM_RUNS_IN_THE_FUTURE)
  347. editButton.tintColor = [UIColor whiteColor];
  348. else {
  349. [editButton setBackgroundImage:[UIImage imageNamed:editImage] forState:UIControlStateNormal
  350. barMetrics:UIBarMetricsDefault];
  351. [editButton setBackgroundImage:[UIImage imageNamed:editImageHighlight]
  352. forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  353. [editButton setTitleTextAttributes: editing ? @{UITextAttributeTextShadowColor : [UIColor whiteColor], UITextAttributeTextColor : [UIColor blackColor]} : @{UITextAttributeTextShadowColor : [UIColor colorWithWhite:0. alpha:.37], UITextAttributeTextColor : [UIColor whiteColor]} forState:UIControlStateNormal];
  354. }
  355. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  356. [self.gridView setEditing:editing];
  357. else
  358. [self.tableView setEditing:editing animated:YES];
  359. }
  360. - (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
  361. {
  362. if (_libraryMode != VLCLibraryModeAllFiles)
  363. return UITableViewCellEditingStyleNone;
  364. return UITableViewCellEditingStyleDelete;
  365. }
  366. - (IBAction)leftButtonAction:(id)sender
  367. {
  368. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  369. }
  370. - (IBAction)backToAllItems:(id)sender
  371. {
  372. self.navigationItem.leftBarButtonItem = _menuButton;
  373. [self setLibraryMode:_libraryMode];
  374. }
  375. /* deprecated in iOS 6 */
  376. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  377. {
  378. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  379. return YES;
  380. return (_foundMedia.count > 0) || toInterfaceOrientation == UIInterfaceOrientationPortrait;
  381. }
  382. // RootController is responsible for supporting interface orientation(iOS6.0+), i.e. navigation controller
  383. // so this will not work as intended without "voodoo magic"(UINavigationController category, subclassing, etc)
  384. /* introduced in iOS 6 */
  385. - (NSUInteger)supportedInterfaceOrientations {
  386. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  387. return UIInterfaceOrientationMaskAll;
  388. return (_foundMedia.count > 0)? UIInterfaceOrientationMaskAllButUpsideDown:
  389. UIInterfaceOrientationMaskPortrait;
  390. }
  391. /* introduced in iOS 6 */
  392. - (BOOL)shouldAutorotate {
  393. return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (_foundMedia.count > 0);
  394. }
  395. #pragma mark - coin coin
  396. - (void)openMovieFromURL:(NSURL *)url
  397. {
  398. if (!self.movieViewController)
  399. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  400. if (self.navigationController.topViewController != self.movieViewController)
  401. [self.navigationController pushViewController:self.movieViewController animated:YES];
  402. self.movieViewController.url = url;
  403. }
  404. - (void)setLibraryMode:(VLCLibraryMode)mode
  405. {
  406. _libraryMode = mode;
  407. if (_libraryMode == VLCLibraryModeAllAlbums)
  408. self.title = NSLocalizedString(@"LIBRARY_MUSIC", @"");
  409. else if( _libraryMode == VLCLibraryModeAllSeries)
  410. self.title = NSLocalizedString(@"LIBRARY_SERIES", @"");
  411. else
  412. self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
  413. [self updateViewContents];
  414. }
  415. @end