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,對不起,我糾正了它,但它仍然是一樣的 –