123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- //
- // VLCAppDelegate.m
- // AspenProject
- //
- // Created by Felix Paul Kühne on 27.02.13.
- // Copyright (c) 2013 VideoLAN. All rights reserved.
- //
- #import "VLCAppDelegate.h"
- #import "VLCPlaylistViewController.h"
- #import "VLCMovieViewController.h"
- @implementation VLCAppDelegate
- - (void)dealloc
- {
- [_playlistViewController release];
- [_window release];
- [_navigationController release];
- [_splitViewController release];
- [super dealloc];
- }
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
- // Override point for customization after application launch.
- _playlistViewController = [[VLCPlaylistViewController alloc] initWithNibName:@"VLCPlaylistViewController" bundle:nil];
- if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
- self.navigationController = [[[UINavigationController alloc] initWithRootViewController:_playlistViewController] autorelease];
- self.window.rootViewController = self.navigationController;
- } else {
- _playlistViewController = [[VLCPlaylistViewController alloc] initWithNibName:@"VLCPlaylistViewController" bundle:nil];
- UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:_playlistViewController] autorelease];
- VLCMovieViewController *movieViewController = [[[VLCMovieViewController alloc] initWithNibName:@"VLCMovieViewController" bundle:nil] autorelease];
- UINavigationController *movieNavigationController = [[[UINavigationController alloc] initWithRootViewController:movieViewController] autorelease];
- _playlistViewController.movieViewController = movieViewController;
- self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
- self.splitViewController.delegate = movieViewController;
- self.splitViewController.viewControllers = @[masterNavigationController, movieNavigationController];
- self.window.rootViewController = self.splitViewController;
- }
- UINavigationBar *navbar = self.navigationController.navigationBar;
- navbar.barStyle = UIBarStyleBlack;
- navbar.translucent = YES;
- navbar.tintColor = [UIColor colorWithWhite:.15 alpha:1.];
- [self.window makeKeyAndVisible];
- return YES;
- }
- - (void)applicationWillResignActive:(UIApplication *)application
- {
- [[MLMediaLibrary sharedMediaLibrary] applicationWillExit];
- }
- - (void)applicationDidEnterBackground:(UIApplication *)application
- {
- // 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.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
- }
- - (void)applicationWillEnterForeground:(UIApplication *)application
- {
- // 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.
- }
- - (void)applicationDidBecomeActive:(UIApplication *)application
- {
- [self updateMediaList];
- }
- - (void)applicationWillTerminate:(UIApplication *)application
- {
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
- }
- - (void)updateMediaList
- {
- #define LOCAL_PLAYBACK_HACK 1
- #if LOCAL_PLAYBACK_HACK && TARGET_IPHONE_SIMULATOR
- NSString *directoryPath = @"/Users/fkuehne/Desktop/VideoLAN docs/Clips/sel/";
- #else
- NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *directoryPath = [searchPaths objectAtIndex:0];
- #endif
- NSArray *foundFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:nil];
- NSMutableArray *filePaths = [NSMutableArray arrayWithCapacity:[foundFiles count]];
- for (NSString * fileName in foundFiles) {
- 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) {
- [filePaths addObject:[directoryPath stringByAppendingPathComponent:fileName]];
- }
- }
- [[MLMediaLibrary sharedMediaLibrary] addFilePaths:filePaths];
- [_playlistViewController updateViewContents];
- }
- @end
|