0
Xcode 프로젝트에서 원격 MP3 파일을 재생하려고하는데 아래의 구현은 MPMoviePlayerController를 사용하여 작동하지 않고 예외가 발생합니다.iOS 5에서 HTTP를 통해 원격 MP3 파일 재생
키 값 관찰자가 여전히 인 동안 AVPlayerItem이 할당 해제되었습니다.
내 .H 파일
#import <MediaPlayer/MediaPlayer.h>
@property (nonatomic, strong) MPMoviePlayerController *moviePlayer;
당신은 당신의 플레이어에 대한 합성 속성을 지정한
@synthesize moviePlayer = _moviePlayer;
- (void)playEnglish
{
NSURL *url = [NSURL URLWithString:_audioUrlEnglish];
_moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:YES];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
좋은 답변입니다. 고맙습니다. – Nick