diff --git a/ios/IJKMediaDemo/IJKMediaDemo.xcodeproj/project.pbxproj b/ios/IJKMediaDemo/IJKMediaDemo.xcodeproj/project.pbxproj index 6c17fd36f5e129dbfd827079a6a41ebd3c1da622..e3d75969e96746f02c37017daeae00c32d6359fc 100644 --- a/ios/IJKMediaDemo/IJKMediaDemo.xcodeproj/project.pbxproj +++ b/ios/IJKMediaDemo/IJKMediaDemo.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 55E809F11B146C80003E98A5 /* Barcode.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E809F01B146C80003E98A5 /* Barcode.m */; }; 55E809F31B146DE8003E98A5 /* IJKQRCodeScanViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55E809F21B146DE8003E98A5 /* IJKQRCodeScanViewController.xib */; }; 55E809F61B1480BC003E98A5 /* IJKDemoHistory.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E809F51B1480BC003E98A5 /* IJKDemoHistory.m */; }; + 55E809F91B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E809F81B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.m */; }; E60E8C2A19EF70BB005B5B6E /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E60E8C2919EF70BB005B5B6E /* CoreMedia.framework */; }; E60FFBE418BF695700825D7F /* libIJKMediaPlayer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E6D74F2E18A5F94B00165BFD /* libIJKMediaPlayer.a */; }; E612EAE517F7E0F800BEE660 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E612EAE417F7E0F800BEE660 /* MediaPlayer.framework */; }; @@ -85,6 +86,8 @@ 55E809F21B146DE8003E98A5 /* IJKQRCodeScanViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IJKQRCodeScanViewController.xib; sourceTree = ""; }; 55E809F41B1480BC003E98A5 /* IJKDemoHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJKDemoHistory.h; sourceTree = ""; }; 55E809F51B1480BC003E98A5 /* IJKDemoHistory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJKDemoHistory.m; sourceTree = ""; }; + 55E809F71B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJKDemoLocalFolderViewController.h; sourceTree = ""; }; + 55E809F81B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJKDemoLocalFolderViewController.m; sourceTree = ""; }; E60E8C2719EF70A7005B5B6E /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; }; E60E8C2919EF70BB005B5B6E /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; E612EAE417F7E0F800BEE660 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; @@ -155,6 +158,8 @@ E63FC27817F032FD003551EB /* IJKCommon.h */, 55E809EF1B146C80003E98A5 /* Barcode.h */, 55E809F01B146C80003E98A5 /* Barcode.m */, + 55E809F41B1480BC003E98A5 /* IJKDemoHistory.h */, + 55E809F51B1480BC003E98A5 /* IJKDemoHistory.m */, ); name = Misc; sourceTree = ""; @@ -259,8 +264,8 @@ 55E809EC1B146C1E003E98A5 /* IJKQRCodeScanViewController.h */, 55E809ED1B146C1E003E98A5 /* IJKQRCodeScanViewController.m */, 55E809F21B146DE8003E98A5 /* IJKQRCodeScanViewController.xib */, - 55E809F41B1480BC003E98A5 /* IJKDemoHistory.h */, - 55E809F51B1480BC003E98A5 /* IJKDemoHistory.m */, + 55E809F71B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.h */, + 55E809F81B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.m */, ); name = "View Controllers"; sourceTree = ""; @@ -372,6 +377,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 55E809F91B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.m in Sources */, 55E809F61B1480BC003E98A5 /* IJKDemoHistory.m in Sources */, E6903F0C17EAF70200CFD954 /* main.m in Sources */, 55E809E21B143C47003E98A5 /* IJKDemoMainViewController.m in Sources */, diff --git a/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoInputURLViewController.m b/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoInputURLViewController.m index e952ba59d85f0cd021ef7df367125978ac3501c9..e6b1482608a67f4641fabcbd57e4a8945ad3b61d 100644 --- a/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoInputURLViewController.m +++ b/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoInputURLViewController.m @@ -37,7 +37,7 @@ if ([scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"]) { [IJKVideoViewController presentFromViewController:self withTitle:[NSString stringWithFormat:@"URL: %@", url] URL:url completion:^{ - [self.navigationController popViewControllerAnimated:NO]; +// [self.navigationController popViewControllerAnimated:NO]; }]; } } diff --git a/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoLocalFolderViewController.h b/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoLocalFolderViewController.h new file mode 100644 index 0000000000000000000000000000000000000000..4a70a244427910203b06a4e4ddde68a47a2cdef1 --- /dev/null +++ b/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoLocalFolderViewController.h @@ -0,0 +1,15 @@ +// +// IJKDemoLocalFolderViewController.h +// IJKMediaDemo +// +// Created by Gdier on 5/27/15. +// Copyright (c) 2015 bilibili. All rights reserved. +// + +#import + +@interface IJKDemoLocalFolderViewController : UITableViewController + +- (instancetype)initWithFolderPath:(NSString *)folderPath; + +@end diff --git a/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoLocalFolderViewController.m b/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoLocalFolderViewController.m new file mode 100644 index 0000000000000000000000000000000000000000..309f2cf645d2d01a61d805c1cd098b981f4c5a1f --- /dev/null +++ b/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoLocalFolderViewController.m @@ -0,0 +1,169 @@ +// +// IJKDemoLocalFolderViewController.m +// IJKMediaDemo +// +// Created by Gdier on 5/27/15. +// Copyright (c) 2015 bilibili. All rights reserved. +// + +#import "IJKDemoLocalFolderViewController.h" +#import "IJKMoviePlayerViewController.h" + +@interface IJKDemoLocalFolderViewController () + +@end + +@implementation IJKDemoLocalFolderViewController { + NSString *_folderPath; + NSMutableArray *_subpaths; + NSMutableArray *_files; +} + +- (instancetype)initWithFolderPath:(NSString *)folderPath { + self = [super init]; + if (self) { + self.title = [folderPath lastPathComponent]; + + _folderPath = folderPath; + _subpaths = [NSMutableArray array]; + _files = [NSMutableArray array]; + } + return self; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + NSError *error = nil; + BOOL isDirectory = NO; + NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:_folderPath error:&error]; + + for (NSString *fileName in files) { + NSString *fullFileName = [_folderPath stringByAppendingPathComponent:fileName]; + + [[NSFileManager defaultManager] fileExistsAtPath:fullFileName isDirectory:&isDirectory]; + if (isDirectory) { + [_subpaths addObject:fileName]; + } else { + [_files addObject:fileName]; + } + } +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 2; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + switch (section) { + case 0: + return _subpaths.count; + + case 1: + return _files.count; + + default: + break; + } + + return 0; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"abc"]; + if (nil == cell) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"abc"]; + cell.textLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; + } + + switch (indexPath.section) { + case 0: { + cell.textLabel.text = [NSString stringWithFormat:@"[%@]", _subpaths[indexPath.row]]; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + } break; + case 1: { + cell.textLabel.text = _files[indexPath.row]; + cell.accessoryType = UITableViewCellAccessoryNone; + } break; + default: + break; + } + + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + + switch (indexPath.section) { + case 0: { + NSString *fileName = [_folderPath stringByAppendingPathComponent:_subpaths[indexPath.row]]; + + IJKDemoLocalFolderViewController *viewController = [[IJKDemoLocalFolderViewController alloc] initWithFolderPath:fileName]; + + [self.navigationController pushViewController:viewController animated:YES]; + } break; + case 1: { + NSString *fileName = [_folderPath stringByAppendingPathComponent:_files[indexPath.row]]; + + [IJKVideoViewController presentFromViewController:self withTitle:[NSString stringWithFormat:@"File: %@", fileName] URL:[NSURL fileURLWithPath:fileName] completion:^{ + }]; + + } break; + default: + break; + } +} + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoMainViewController.m b/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoMainViewController.m index 1f734a5c9ffdbddbfdec88b4e2dba60939a8ad41..93ed3ec308b008fa3302c6f4e0ce44afaaa1685a 100644 --- a/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoMainViewController.m +++ b/ios/IJKMediaDemo/IJKMediaDemo/IJKDemoMainViewController.m @@ -12,6 +12,7 @@ #import "IJKCommon.h" #import "IJKDemoHistory.h" #import "IJKMoviePlayerViewController.h" +#import "IJKDemoLocalFolderViewController.h" @interface IJKDemoMainViewController () @@ -33,6 +34,14 @@ @"Input URL", @"Scan QRCode", ]; + + NSURL *documentsUrl = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject]; + + NSError *error = nil; + + [documentsUrl setResourceValue:[NSNumber numberWithBool:YES] + forKey:NSURLIsExcludedFromBackupKey + error:&error]; } - (void)viewWillAppear:(BOOL)animated { @@ -81,6 +90,7 @@ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"abc"]; if (nil == cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"abc"]; + cell.textLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; } switch (indexPath.section) { @@ -105,9 +115,13 @@ switch (indexPath.section) { case 0: { switch (indexPath.row) { - case 0: - [[[UIAlertView alloc] initWithTitle:nil message:@"TODO" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:nil] show]; - break; + case 0: { + NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]; + + IJKDemoLocalFolderViewController *viewController = [[IJKDemoLocalFolderViewController alloc] initWithFolderPath:documentsPath]; + + [self.navigationController pushViewController:viewController animated:YES]; + } break; case 1: [self.navigationController pushViewController:[[IJKDemoInputURLViewController alloc] init] animated:YES];