0
- (void)viewDidLoad {
[super viewDidLoad];
[audioPlayer stop];
NSString *Path = [[NSBundle mainBundle] pathForResource:@"Keep the Shoes Moving" ofType: @"m4a"];
NSURL *URL = [[NSURL alloc] initFileURLWithPath: Path];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:URL error:&error];
audioPlayer.numberOfLoops = -1;
[audioPlayer play];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; }

これで何が起こるかというと、この viewController に戻るたびに、別のトラックが再生されます。それで、2 つのトラックを重ねて再生しています。どうすればこれを止めることができますか??

4

1 に答える 1

2

インスタンスAVAudioPlayerをプロパティに保存し、stop再生を停止したいときにそのメソッドを呼び出します。

于 2013-02-17T20:12:12.743 に答える