【发布时间】:2013-06-17 08:12:04
【问题描述】:
我尝试向 Viewcontroller 添加视频但总是失败:有人可以帮忙吗?
-(id) init
{
// always call "super" init // Apple recommends to re-assign "self" with the "super's" return value
if(self=[super init])
{
//play // [[[CCDirector sharedDirector] view] addSubview:viewController.view];
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[viewController.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
moviePlayerController.controlStyle = MPMovieControlStyleNone;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieDone:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController]; [moviePlayerController play];
//play
}
return self;
}
【问题讨论】:
-
您可以添加更多信息吗?它在哪里崩溃?崩溃日志说什么?你检查过 filePath 是否为 nil 吗?
-
@Xena Steward - 检查我的答案
标签: ios mpmediaplayercontroller