【发布时间】:2017-06-13 19:13:57
【问题描述】:
我已经在我的文档文件夹中保存了一个 1mb 的大钱兔子,我尝试用我的 AVPlayer 加载和播放它,为此我使用了这个代码
NSString* documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString* foofile = [documentsPath stringByAppendingPathComponent:string]; // string is file name
NSURL *url = [NSURL URLWithString:foofile];
NSLog(@" exsits %@ :",foofile);
AVPlayer*player1 = [AVPlayer playerWithURL:url];
AVPlayerViewController *Controller = [[AVPlayerViewController alloc] init];
Controller.player = player1;
[player1 play];
[self presentViewController:Controller animated:YES completion:nil];
但我得到的不是播放器
编辑 文件 URL 看起来像这样
/Users/usrname/Library/Developer/CoreSimulator/Devices/4453818A-0617-479B-B98C-3FC544A24D00/data/Containers/Data/Application/D7449628-0A67-4294-9471-98F5596FE596/Documents/tt1823672.mp4
【问题讨论】:
-
您正在从
string而不是foofile创建您的网址 -
NSURL *url = [NSURL URLWithString:foofile]; -
@dan,对不起,我更正了,但还是一样
标签: ios objective-c avplayer nsfilemanager