VLCPlaylistViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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. NSLog(@"old count %i", _foundMedia.count);
  186. if (_libraryMode == kVLCLibraryModeAllAlbums) {
  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 == kVLCLibraryModeAllSeries) {
  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. NSLog(@"old count %i", _foundMedia.count);
  211. [self reloadViews];
  212. }
  213. - (void)reloadViews
  214. {
  215. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  216. [self.tableView reloadData];
  217. else {
  218. [self.gridView reloadData];
  219. [self.gridView performSelector:@selector(reloadData) withObject:nil afterDelay:2.];
  220. }
  221. [self _displayEmptyLibraryViewIfNeeded];
  222. }
  223. #pragma mark - Table View
  224. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  225. {
  226. return 1;
  227. }
  228. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  229. {
  230. return _foundMedia.count;
  231. }
  232. // Customize the appearance of table view cells.
  233. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  234. {
  235. static NSString *CellIdentifier = @"PlaylistCell";
  236. VLCPlaylistTableViewCell *cell = (VLCPlaylistTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  237. if (cell == nil)
  238. cell = [VLCPlaylistTableViewCell cellWithReuseIdentifier:CellIdentifier];
  239. NSInteger row = indexPath.row;
  240. cell.mediaObject = _foundMedia[row];
  241. return cell;
  242. }
  243. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  244. {
  245. cell.backgroundColor = (indexPath.row % 2 == 0)? [UIColor blackColor]: [UIColor colorWithWhite:.122 alpha:1.];
  246. }
  247. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  248. {
  249. return YES;
  250. }
  251. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  252. {
  253. if (editingStyle == UITableViewCellEditingStyleDelete)
  254. [self removeMediaObject: _foundMedia[indexPath.row]];
  255. }
  256. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  257. {
  258. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  259. NSManagedObject *currentObject = _foundMedia[indexPath.row];
  260. if ([currentObject isKindOfClass:[MLAlbum class]]) {
  261. _foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
  262. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  263. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
  264. self.title = [(MLAlbum*)currentObject name];
  265. [self reloadViews];
  266. } else if ([currentObject isKindOfClass:[MLShow class]]) {
  267. _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
  268. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  269. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
  270. self.title = [(MLShow*)currentObject name];
  271. [self reloadViews];
  272. } else {
  273. if (!self.movieViewController)
  274. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  275. if ([currentObject isKindOfClass:[MLFile class]])
  276. self.movieViewController.mediaItem = (MLFile *)currentObject;
  277. else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
  278. self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
  279. else if ([currentObject isKindOfClass:[MLShowEpisode class]])
  280. self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
  281. [self.navigationController pushViewController:self.movieViewController animated:YES];
  282. }
  283. }
  284. #pragma mark - AQGridView
  285. - (NSUInteger)numberOfItemsInGridView:(AQGridView *)gridView
  286. {
  287. return _foundMedia.count;
  288. }
  289. - (AQGridViewCell *)gridView:(AQGridView *)gridView cellForItemAtIndex:(NSUInteger)index
  290. {
  291. static NSString *AQCellIdentifier = @"AQPlaylistCell";
  292. VLCPlaylistGridView *cell = (VLCPlaylistGridView *)[gridView dequeueReusableCellWithIdentifier:AQCellIdentifier];
  293. if (cell == nil) {
  294. cell = [[[NSBundle mainBundle] loadNibNamed:@"VLCPlaylistGridView" owner:self options:nil] lastObject];
  295. cell.selectionStyle = AQGridViewCellSelectionStyleNone;
  296. cell.gridView = gridView;
  297. }
  298. cell.mediaObject = _foundMedia[index];
  299. return cell;
  300. }
  301. - (CGSize)portraitGridCellSizeForGridView:(AQGridView *)gridView
  302. {
  303. return [VLCPlaylistGridView preferredSize];
  304. }
  305. - (void)gridView:(AQGridView *)gridView didSelectItemAtIndex:(NSUInteger)index
  306. {
  307. [self.gridView deselectItemAtIndex:index animated:YES];
  308. NSManagedObject *currentObject = _foundMedia[index];
  309. if ([currentObject isKindOfClass:[MLAlbum class]]) {
  310. _foundMedia = [NSMutableArray arrayWithArray:[[(MLAlbum *)currentObject tracks] allObjects]];
  311. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  312. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_MUSIC", @"")];
  313. self.title = [(MLAlbum*)currentObject name];
  314. [self reloadViews];
  315. } else if ([currentObject isKindOfClass:[MLShow class]]) {
  316. _foundMedia = [NSMutableArray arrayWithArray:[[(MLShow *)currentObject episodes] allObjects]];
  317. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(backToAllItems:)];
  318. [self.navigationItem.leftBarButtonItem setTitle:NSLocalizedString(@"LIBRARY_SERIES", @"")];
  319. self.title = [(MLShow*)currentObject name];
  320. [self reloadViews];
  321. } else {
  322. if (!self.movieViewController)
  323. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  324. if ([currentObject isKindOfClass:[MLFile class]])
  325. self.movieViewController.mediaItem = (MLFile *)currentObject;
  326. else if ([currentObject isKindOfClass:[MLAlbumTrack class]])
  327. self.movieViewController.mediaItem = [(MLAlbumTrack*)currentObject files].anyObject;
  328. else if ([currentObject isKindOfClass:[MLShowEpisode class]])
  329. self.movieViewController.mediaItem = [(MLShowEpisode*)currentObject files].anyObject;
  330. [self.navigationController pushViewController:self.movieViewController animated:YES];
  331. }
  332. }
  333. - (void)gridView:(AQGridView *)aGridView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndex:(NSUInteger)index
  334. {
  335. if (editingStyle == UITableViewCellEditingStyleDelete)
  336. [self removeMediaObject: _foundMedia[index]];
  337. }
  338. #pragma mark - UI implementation
  339. - (void)setEditing:(BOOL)editing animated:(BOOL)animated
  340. {
  341. if (_libraryMode != kVLCLibraryModeAllFiles)
  342. return;
  343. [super setEditing:editing animated:animated];
  344. UIBarButtonItem *editButton = self.editButtonItem;
  345. NSString *editImage = editing? @"doneButton": @"button";
  346. NSString *editImageHighlight = editing? @"doneButtonHighlight": @"buttonHighlight";
  347. if (SYSTEM_RUNS_IN_THE_FUTURE)
  348. editButton.tintColor = [UIColor whiteColor];
  349. else {
  350. [editButton setBackgroundImage:[UIImage imageNamed:editImage] forState:UIControlStateNormal
  351. barMetrics:UIBarMetricsDefault];
  352. [editButton setBackgroundImage:[UIImage imageNamed:editImageHighlight]
  353. forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  354. [editButton setTitleTextAttributes: editing ? @{UITextAttributeTextShadowColor : [UIColor whiteColor], UITextAttributeTextColor : [UIColor blackColor]} : @{UITextAttributeTextShadowColor : [UIColor colorWithWhite:0. alpha:.37], UITextAttributeTextColor : [UIColor whiteColor]} forState:UIControlStateNormal];
  355. }
  356. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  357. [self.gridView setEditing:editing];
  358. else
  359. [self.tableView setEditing:editing animated:YES];
  360. }
  361. - (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
  362. {
  363. if (_libraryMode != kVLCLibraryModeAllFiles)
  364. return UITableViewCellEditingStyleNone;
  365. return UITableViewCellEditingStyleDelete;
  366. }
  367. - (IBAction)leftButtonAction:(id)sender
  368. {
  369. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  370. }
  371. - (IBAction)backToAllItems:(id)sender
  372. {
  373. self.navigationItem.leftBarButtonItem = _menuButton;
  374. [self setLibraryMode:_libraryMode];
  375. }
  376. /* deprecated in iOS 6 */
  377. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  378. {
  379. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  380. return YES;
  381. return (_foundMedia.count > 0) || toInterfaceOrientation == UIInterfaceOrientationPortrait;
  382. }
  383. // RootController is responsible for supporting interface orientation(iOS6.0+), i.e. navigation controller
  384. // so this will not work as intended without "voodoo magic"(UINavigationController category, subclassing, etc)
  385. /* introduced in iOS 6 */
  386. - (NSUInteger)supportedInterfaceOrientations {
  387. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  388. return UIInterfaceOrientationMaskAll;
  389. return (_foundMedia.count > 0)? UIInterfaceOrientationMaskAllButUpsideDown:
  390. UIInterfaceOrientationMaskPortrait;
  391. }
  392. /* introduced in iOS 6 */
  393. - (BOOL)shouldAutorotate {
  394. return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (_foundMedia.count > 0);
  395. }
  396. #pragma mark - coin coin
  397. - (void)openMovieFromURL:(NSURL *)url
  398. {
  399. if (!self.movieViewController)
  400. self.movieViewController = [[VLCMovieViewController alloc] initWithNibName:nil bundle:nil];
  401. if (self.navigationController.topViewController != self.movieViewController)
  402. [self.navigationController pushViewController:self.movieViewController animated:YES];
  403. self.movieViewController.url = url;
  404. }
  405. - (void)setLibraryMode:(NSUInteger)mode
  406. {
  407. _libraryMode = mode;
  408. if (_libraryMode == kVLCLibraryModeAllAlbums)
  409. self.title = NSLocalizedString(@"LIBRARY_MUSIC", @"");
  410. else if( _libraryMode == kVLCLibraryModeAllSeries)
  411. self.title = NSLocalizedString(@"LIBRARY_SERIES", @"");
  412. else
  413. self.title = NSLocalizedString(@"LIBRARY_ALL_FILES", @"");
  414. [self updateViewContents];
  415. }
  416. @end