Cocos2D를 사용하는 응용 프로그램 내에서 MPMoviePlayerController를 사용하여 영화를 재생하고 있습니다. 그러나 영화가 실행되면 영화의 오디오의 마지막 2/3 만 재생됩니다. 영화가 첫 번째 3 분 동안 침묵하지 않았다는 것이 아닙니다. 동영상 재생이 시작되면 동영상 재생 속도의 1/3을 오디오 재생으로 시작합니다. 즉, 오디오와 비디오가 동기화되지 않습니다.MPMoviePlayerController 비디오 및 오디오가 동기화되지 않았습니다.
iOS 4.2를 사용하고 있으며 최신 xCode로 업그레이드했습니다. 아래는 내가 사용하고있는 코드입니다. 누군가 이것이 왜 일어나고 있는지 말해 줄 수 있습니까?
- (id) init
{
self = [super init];
if (self != nil)
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"SomeMovie" ofType:@"m4v"]];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(PlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = YES;
[moviePlayer.view setTransform:CGAffineTransformMakeRotation((float)M_PI_2)];
[moviePlayer.view setFrame:[[UIScreen mainScreen] bounds]];
[[[CCDirector sharedDirector] openGLView] addSubview:moviePlayer.view];
}
return self;
}
- (void) PlayBackDidFinish:(NSNotification *)notification
{
MPMoviePlayerController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer.view removeFromSuperview];
[moviePlayer release];
}
예. iTunes에서 재생했고 예상대로 작동했습니다. –