Well..I have a simple animation that slides 2 image views left and right.. when it’s completed, I would like to play a video but with my existing code(below), animation never happens and video starts playing. How can I fix this problem? Thanks..
NSString *movpath = [[NSBundle mainBundle] pathForResource:@"testvideo" ofType:@"m4v"];
mpviewController = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:movpath]];
[mainView addSubview:mpviewController.view];
[UIView animateWithDuration:0.5 animations:^{
leftView.frame = CGRectOffset(leftView.frame, 160, 0);
rightView.frame = CGRectOffset(rightView.frame, -160, 0);
}completion:(void (^)(BOOL)) ^{
MPMoviePlayerController *mp = [mpviewController moviePlayer];
[mp prepareToPlay];
[mp setFullscreen:YES animated:YES];
mp.controlStyle = MPMovieControlStyleNone;
[[mpviewController moviePlayer] play];
}
];
Your completion block for the animation looks wrong. Try this: