VLCAppDelegate.m 3.1 KB

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