开发者

Problem regarding overlapping song?

I am using a AVAudio player to play a song,

I take a song from ipod library,

i play a first song but 开发者_如何学Cwhen select other song from ipod library that both song play simultaneously,

How to stop a first song?

I tried to stop a song

- (IBAction)player_stop {

   [theAudio stop];

   theAudio = Nil;

}

on button play method i write this code

- (IBAction)btn_play {

    [self player_stop];

    [theAudio play];

}

How i Do that?


You should tell the player, not the audio, to stop.

[self.player stop];

To start a new audio you can do as follows:

[self.player stop];
self.player = nil;
NSError *error;
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
[self.player play];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜