iOS 3.1.3 까지는 동영상 재생을 원할때 MPMoviePlayerController를 사용했었습니다.
iOS 3.2 이상 버전에서는 MPMoviePlayerViewController가 추가되었습니다.
- (void) moviePlayBack:(NSNotification *)noti {
NSURL *movieURL = (NSURL *)[[noti userInfo] objectForKey:@"url"];
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 3.2) {
MPMoviePlayerViewController *playerView = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
playerView.view.backgroundColor = [UIColor blackColor];
playerView.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerView.moviePlayer];
[self presentMoviePlayerViewControllerAnimated:playerView];
[playerView release];
} else if ([[[UIDevice currentDevice] systemVersion] doubleValue] < 3.2) {
MPMoviePlayerController* moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
[moviePlayer play];
}
}
- (void) playbackDidFinish:(NSNotification *)noti {
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 3.2) {
MPMoviePlayerController *player = [noti object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];
[player stop];
[self dismissMoviePlayerViewControllerAnimated];
} else if ([[[UIDevice currentDevice] systemVersion] doubleValue] < 3.2) {
MPMoviePlayerController *player = [noti object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];
[player stop];
[player release];
}
'프로그래밍 > iOS' 카테고리의 다른 글
uiwebview 사용 시 확대 축소 (0) | 2012.05.09 |
---|---|
MPMoviePlayerViewController 컨텐츠 이어서 재생하기 (0) | 2012.05.08 |
맥어드레스 가져오기 (0) | 2012.05.02 |
Custom AlertView (0) | 2012.04.29 |
How does UITableViewCell reorder, expand/shrink work ? (0) | 2012.04.28 |