Привет, я создал приложение для iPad, у него есть видеофайлы в папке ресурсов, и он воспроизводится, когда пользователь нажимает кнопку воспроизведения.Он работает в первый раз, когда пользователь нажимает кнопку воспроизведения, но когда пользователь воспроизводит последующие моменты времени видеофайла. Возникает проблема, заключающаяся в том, что видео воспроизводится не только при воспроизведении звука. Эти проблемы возникают не случайно, а еще несколько раз.
В момент возникновения проблемы возникает еще одна вещь (видео не воспроизводится), когда я нажимаю значки со стрелками, расположенные в правом нижнем углу проигрывателя, фильм переходит в полноэкранный режим и показывает видео. В это времявидео воспроизводится.
Может ли кто-нибудь мне помочь?
Вот мой пример кода
MPMoviePlayerController *moviePlayer;
} @property (readwrite, retain) MPMoviePlayerController * moviePlayer;@synthesize moviePlayer;
- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayer];
[super viewDidLoad];
}
-(IBAction)PlayBtnPressed:(id)sender
{
NSURL *movieURL;
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"title" ofType:@"mp4"];
movieURL = [NSURL fileURLWithPath:moviePath];
// Initialize a movie player object with the specified URL
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
if (mp)
{
// save the movie player object
self.moviePlayer = mp;
[mp release];
UIInterfaceOrientation orientation = [[UIDevice currentDevice]orientation];
[self shouldAutorotateToInterfaceOrientation:orientation];
// Play the movie!
[self.view addSubview:self.moviePlayer.view];
[self.moviePlayer play];
}
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
NSLog(@"movieFinishedCallback aNotification");
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player stop];
[player.view removeFromSuperview];
}
Заранее спасибо ........