VLCAppDelegate.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // VLCAppDelegate.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. #import "VLCAppDelegate.h"
  9. #import "VLCPlaylistViewController.h"
  10. #import "VLCMovieViewController.h"
  11. @implementation VLCAppDelegate
  12. - (void)dealloc
  13. {
  14. [_playlistViewController release];
  15. [_window release];
  16. [_navigationController release];
  17. [_splitViewController release];
  18. [super dealloc];
  19. }
  20. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  21. {
  22. self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
  23. _playlistViewController = [[VLCPlaylistViewController alloc] initWithNibName:@"VLCPlaylistViewController" bundle:nil];
  24. self.navigationController = [[[UINavigationController alloc] initWithRootViewController:_playlistViewController] autorelease];
  25. self.window.rootViewController = self.navigationController;
  26. self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
  27. [self.window makeKeyAndVisible];
  28. return YES;
  29. }
  30. - (void)applicationWillResignActive:(UIApplication *)application
  31. {
  32. [[MLMediaLibrary sharedMediaLibrary] applicationWillExit];
  33. }
  34. - (void)applicationDidEnterBackground:(UIApplication *)application
  35. {
  36. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  37. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  38. }
  39. - (void)applicationWillEnterForeground:(UIApplication *)application
  40. {
  41. // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
  42. }
  43. - (void)applicationDidBecomeActive:(UIApplication *)application
  44. {
  45. [self updateMediaList];
  46. }
  47. - (void)applicationWillTerminate:(UIApplication *)application
  48. {
  49. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  50. }
  51. - (void)updateMediaList
  52. {
  53. #define LOCAL_PLAYBACK_HACK 1
  54. #if LOCAL_PLAYBACK_HACK && TARGET_IPHONE_SIMULATOR
  55. NSString *directoryPath = @"/Users/fkuehne/Desktop/VideoLAN docs/Clips/sel/";
  56. #else
  57. NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  58. NSString *directoryPath = [searchPaths objectAtIndex:0];
  59. #endif
  60. NSArray *foundFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil];
  61. NSMutableArray *filePaths = [NSMutableArray arrayWithCapacity:[foundFiles count]];
  62. for (NSString *fileName in foundFiles) {
  63. if ([fileName rangeOfString:@"\\.(3gp|3gp|3gp2|3gpp|amv|asf|avi|divx|dv|flv|f4v|gvi|gxf|m1v|m2p|m2t|m2ts|m2v|m4v|mkv|moov|mov|mp2v|mp4|mpeg|mpeg1|mpeg2|mpeg4|mpg|mpv|mt2s|mts|mxf|oga|ogm|ogv|ogx|spx|ps|qt|rm|rmvb|ts|tts|vob|webm|wm|wmv)$" options:NSRegularExpressionSearch|NSCaseInsensitiveSearch].length != 0) {
  64. [filePaths addObject:[directoryPath stringByAppendingPathComponent:fileName]];
  65. }
  66. }
  67. [[MLMediaLibrary sharedMediaLibrary] addFilePaths:filePaths];
  68. [_playlistViewController updateViewContents];
  69. }
  70. @end