2013-04-12 45 views
4

我的應用程序中有一個小視頻部分。帶本地視頻文件的AVPlayer

所以我覺得這個樣本,從而起到從URL MP4視頻:http://www.sdkboy.com/?p=66

你可以在這裏下載示例:http://www.sdkboy.com/tutorials/AVFoundation_Test3.zip

但是,當我更換NSURL代碼

NSURL *url = [NSURL URLWithString:@"http://www.samkeeneinteractivedesign.com/videos/littleVid3.mp4"]; 

有了這一個,播放本地視頻時,播放器不起作用。

NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"malina36" ofType:@"mp4"]]; 

該文件存在,我

if ([[NSFileManager defaultManager] fileExistsAtPath:url.absoluteString]) { 
     NSLog(@"yes"); 
    } else { 
     NSLog(@"no"); 
    } 

檢查它,你能幫我嗎?

+0

可能重複(http://stackoverflow.com/questions/2112927/urlwithstring-returns-nil-for-resource -path-iphone) –

回答

16

嘗試使用fileURLWithPath:方法,而不是URLWithString:

的[URLWithString返回nil的資源路徑 - iphone]