我试图让一个mp4电影在UICollectionViewCell中播放。我没有运气让它显示。所以,我的第一个问题是:这可能吗?如果是这样,我做错了什么?这是一个非ARC项目,我没有使用任何XIBs或情节串连图板...UICollectionViewCell中的MPMoviePlayerController
NSURL * theURL = nil;
NSBundle * bundle = [NSBundle mainBundle];
if (bundle)
{
NSString * thePath = [bundle pathForResource:@"intro" ofType:@"mp4"];
if (thePath)
{
theURL = [NSURL fileURLWithPath:thePath];
}
}
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: theURL];
[player prepareToPlay];
[player.view setFrame: self.contentView.bounds]; // player's frame must match parent's
[self.contentView addSubview: player.view];
[player play];
[player release];
将播放器放在@property中,并检查它。播放后不要释放它。 – iDev 2013-02-28 22:56:57