VLCAppDelegate.m 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. [super dealloc];
  18. }
  19. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  20. {
  21. self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
  22. _playlistViewController = [[VLCPlaylistViewController alloc] initWithNibName:@"VLCPlaylistViewController" bundle:nil];
  23. self.navigationController = [[[UINavigationController alloc] initWithRootViewController:_playlistViewController] autorelease];
  24. self.window.rootViewController = self.navigationController;
  25. self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
  26. [self.window makeKeyAndVisible];
  27. return YES;
  28. }
  29. - (void)applicationWillResignActive:(UIApplication *)application
  30. {
  31. [[MLMediaLibrary sharedMediaLibrary] applicationWillExit];
  32. }
  33. - (void)applicationDidEnterBackground:(UIApplication *)application
  34. {
  35. // 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.
  36. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  37. }
  38. - (void)applicationWillEnterForeground:(UIApplication *)application
  39. {
  40. // 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.
  41. }
  42. - (void)applicationDidBecomeActive:(UIApplication *)application
  43. {
  44. [self updateMediaList];
  45. }
  46. - (void)applicationWillTerminate:(UIApplication *)application
  47. {
  48. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  49. }
  50. - (void)updateMediaList
  51. {
  52. #define LOCAL_PLAYBACK_HACK 1
  53. #if LOCAL_PLAYBACK_HACK && TARGET_IPHONE_SIMULATOR
  54. NSString *directoryPath = @"/Users/fkuehne/Desktop/VideoLAN docs/Clips/sel/";
  55. #else
  56. NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  57. NSString *directoryPath = [searchPaths objectAtIndex:0];
  58. #endif
  59. NSArray *foundFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil];
  60. NSMutableArray *filePaths = [NSMutableArray arrayWithCapacity:[foundFiles count]];
  61. for (NSString *fileName in foundFiles) {
  62. 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) {
  63. [filePaths addObject:[directoryPath stringByAppendingPathComponent:fileName]];
  64. }
  65. }
  66. [[MLMediaLibrary sharedMediaLibrary] addFilePaths:filePaths];
  67. [_playlistViewController updateViewContents];
  68. }
  69. @end