0

Iphone で AVAudioPlayer を使用するとエラーが発生します。毎回ではなく、いつかこのエラーが発生しました。エラーは:

AVPlayerItem は、AVPlayer の複数のインスタンスに関連付けることはできません

ファイルの再生に使用しているコード:

NSString *soundPath =[[NSBundle mainBundle] pathForResource:@"abc" ofType:@"m4a"];
NSURL *soundURL = [NSURL fileURLWithPath:soundPath];
NSError *error;

AVAudioPlayer *theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:&error];
[theAudio setDelegate:self];
[theAudio setNumberOfLoops:0];
if(theAudio == nil)
{
    NSLog([error description]);
}
else
{
    [theAudio play];
}

この問題を解決する方法を教えてください。

4

0 に答える 0