J'essaie d'obtenir un film mp4 à jouer dans un UICollectionViewCell. Je n'ai pas de chance pour l'afficher. Donc, ma première question est: est-ce possible? Si oui, qu'est-ce que je fais de mal? C'est un projet non-ARC et je ne suis pas utiliser de XIBs ou storyboards ...MPMoviePlayerController dans UICollectionViewCell
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];
Placez le lecteur dans un @property et vérifiez-le. Ne le relâchez pas après la lecture. – iDev