我很努力去理解爲什麼這不起作用:/每當我運行項目時,應用程序崩潰拋出一個'NSInvalidArgumentException',原因:'* - [NSURL initFileURLWithPath:]:零字符串參數」視頻播放失敗 - [NSURL initFileURLWithPath:]:無字符串參數
我跟着一個教程(我很新的這一點),併爲他工作和代碼是完全一樣的..誰能解釋怎麼回事上?
.h文件中
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import <QuartzCore/QuartzCore.h>
@interface FirstViewController : UIViewController {
MPMoviePlayerViewController *playerController;
}
-(IBAction)playVideo;
@end
.m文件
#import "FirstViewController.h"
@interface FirstViewController()
@end
@implementation FirstViewController
{
MPMoviePlayerController *mpc;
}
- (IBAction)playButton:(id)sender {
NSString *stringPath = [[NSBundle mainBundle]pathForResource:@"intro" ofType:@"MP4"];
NSURL *url = [NSURL fileURLWithPath:stringPath];
if(url != nil){
mpc = [[MPMoviePlayerController alloc]initWithContentURL:url];
[mpc setMovieSourceType:MPMovieSourceTypeFile];
[[self view]addSubview:mpc.view];
[mpc setFullscreen:YES];
[mpc play];
}
else{
NSLog(@"URL not found");
}
}
@end
在任何人問及Reece Darragh擁有我們正在使用的開發者賬戶之前,感謝您的幫助 –