0
我救了1MB的大降压兔子到我的文档文件夹中,我试图加载和我AVPlayer播放它,为了这个,我用这个代码播放保存的视频在文件字典中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'创建你的url – dan
'NSURL * url = [NSURL URLWithString:foofile];' – dan
@dan,对不起,我纠正了它,但它仍然是一样的 –