提交 1f727ea7 编写于 作者: G Gdier

ios: demo app support play local videos in NSDocumentDirectory.

上级 132ec911
......@@ -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 = "<group>"; };
55E809F41B1480BC003E98A5 /* IJKDemoHistory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJKDemoHistory.h; sourceTree = "<group>"; };
55E809F51B1480BC003E98A5 /* IJKDemoHistory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJKDemoHistory.m; sourceTree = "<group>"; };
55E809F71B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJKDemoLocalFolderViewController.h; sourceTree = "<group>"; };
55E809F81B15A1DB003E98A5 /* IJKDemoLocalFolderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJKDemoLocalFolderViewController.m; sourceTree = "<group>"; };
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 = "<group>";
......@@ -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 = "<group>";
......@@ -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 */,
......
......@@ -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];
}];
}
}
......
//
// IJKDemoLocalFolderViewController.h
// IJKMediaDemo
//
// Created by Gdier on 5/27/15.
// Copyright (c) 2015 bilibili. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface IJKDemoLocalFolderViewController : UITableViewController
- (instancetype)initWithFolderPath:(NSString *)folderPath;
@end
//
// 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
......@@ -12,6 +12,7 @@
#import "IJKCommon.h"
#import "IJKDemoHistory.h"
#import "IJKMoviePlayerViewController.h"
#import "IJKDemoLocalFolderViewController.h"
@interface IJKDemoMainViewController () <UITableViewDataSource, UITableViewDelegate>
......@@ -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];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册