开发者

Problem regarding overlapping song?

开发者 https://www.devze.com 2023-03-31 12:46 出处:网络
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,

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

精彩评论

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

关注公众号