MP3 재생 및 중지 문제?
-
20-09-2019 - |
문제
이 코드는 내가보기를 종료하고 다시 들어 오려고 할 때까지 잘 작동합니다. 이렇게하면 정지 버튼이 더 이상 작동하지 않습니다. 전망을 떠난 후에도 여전히 작동하도록하려면 어떻게해야합니까?
-(IBAction)musiconButtonClicked:(id)sender{
NSString *path = [[NSBundle mainBundle] pathForResource:@"NextRevIt" ofType:@"mp3"];
self.audioPlayer = [[AVAudioPlayer alloc ] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
[audioPlayer play];
}
-(IBAction)musicoffButtonClicked:(id)sender{
[audioPlayer stop];
}
해결책
완료되면 오디오 플레이어를 출시해야합니다.
당신은 또한 사용해야합니다 [audioPlayer prepareToPlay];
~ 전에 play
코드에서.
제휴하지 않습니다 StackOverflow