AVAudioPLayer pause method

Discussion in 'iOS Programming' started by RashiMahajan, Apr 17, 2009.

  1. RashiMahajan macrumors newbie

    Apr 17, 2009
    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

    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];

    [audioPlayer pause];

    Its not working fore Pause......
    Wht m skipping..
  2. hemalimojidra macrumors newbie

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

    in .m file

    @synthesize audioPlayer;

    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

    Hemali mojidra

Share This Page