私は、ユーザーが画像をクリックするたびに再生したい映画へのリンクを含むXMLフィードを含むアプリケーションを構築しています。
そのために、私はMPMoviePlayerViewControllerを使用しています。シミュレーターでアプリをテストすると、これまでのところ期待どおりの結果が得られましたが、iPhoneでアプリをテストすると、プレーヤーは正しく再生されますが、音は出ません。
私はインターネットを調べましたが、いくつかの記事によると、アプリのパフォーマンスはシミュレーターが提供するパフォーマンスとは大きく異なるとのことです。そのため、Instrumentsで「リーク」テストを行いました。これにより、映画の再生を開始するたびに、一部のバイトがドロップまたはリークすることがわかりました。それは突然の音の低下と関係があるのでしょうか?もしそうなら、私はそれをどのように解決しますか?
iPhoneでアプリをテストするのは初めてなので、アプリのパフォーマンスがいかに悪いかを見てかなりショックを受けました。これがmovieplayer-partのコードです。
#pragma mark Video Controls
-(void)playVideo:(id)sender{
moviePlaying=TRUE;
MPMoviePlayerViewController *playerViewController;
playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:[data objectForKey:@"[att]url"]]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:[playerViewController moviePlayer]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidExitFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:[playerViewController moviePlayer]];
MPMoviePlayerController *player = [[[MPMoviePlayerController alloc] init] autorelease];
player = [playerViewController moviePlayer];
[self.view addSubview:playerViewController.view];
player.controlStyle = MPMovieControlStyleDefault;
player.shouldAutoplay = YES;
[player setFullscreen:YES animated:YES];
}
- (void)moviePlayBackDidExitFullscreen:(NSNotification*)notification{
MPMoviePlayerViewController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
[moviePlayer.view removeFromSuperview];
[moviePlayer release];
}
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerViewController *moviePlayer = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];
moviePlaying=FALSE;
[moviePlayer.view removeFromSuperview];
[moviePlayer release];
}
#pragma mark VideoControls End
問題を解決していただければ幸いです。
前もって感謝します、
/ Brinck10