VLCPlaylistViewController.m 20 KB

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