Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RashiMahajan

macrumors newbie
Original poster
Apr 17, 2009
22
0
HI,
M using AVAudioPalyer to play my mp3 file..
t is working fine. but when call pause method to pause the pm,3 file , its dont respond/stops, it continue to play.. evn it dont response to stop...
wht shld i do or wht m skipping..???
Here posting the code to for the clarity purpose

if(...)
{
NSString *newAudioFile = [[NSBundle mainBundle] pathForResource:mad:"xyz" ofType:mad:"mp3"];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:newAudioFile] error:NULL];
[audioPlayer setDelegate:self];
[audioPlayer prepareToPlay];
[audioPlayer play];


if(..){
[audioPlayer pause];
}

Its not working fore Pause......
Wht m skipping..
 
HI,
M using AVAudioPalyer to play my mp3 file..
t is working fine. but when call pause method to pause the pm,3 file , its dont respond/stops, it continue to play.. evn it dont response to stop...
wht shld i do or wht m skipping..???
Here posting the code to for the clarity purpose

if(...)
{
NSString *newAudioFile = [[NSBundle mainBundle] pathForResource:mad:"xyz" ofType:mad:"mp3"];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:newAudioFile] error:NULL];
[audioPlayer setDelegate:self];
[audioPlayer prepareToPlay];
[audioPlayer play];


if(..){
[audioPlayer pause];
}

Its not working fore Pause......
Wht m skipping..

Make audioPlayer object as a class object than do this..
Like...
in .h file
@interface AudioPlayerView : UIView <AVAudioPlayerDelegate>{
AVAudioPlayer *audioPlayer;
}
@property (nonatomic, retain) AVAudioPlayer *audioPlayer;
@end

in .m file

@synthesize audioPlayer;

-(init){
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error: nil];
self.audioPlayer = newPlayer;
[newPlayer release];
[self.audioPlayer setDelegate: self];

}

-(void) play{
[self.audioPlayer play];
}

-(void) pause{
[self.audioPlayer pause];
}


-(void) stop{
[self.audioPlayer stop];
}


I am success using this coding... Try it

Thanks
Hemali mojidra
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.