Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7825901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:11:54+00:00 2026-06-02T09:11:54+00:00

-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag { [self NextHeading]; // this plays an mp3 file [self NextHeadingMeaning];

  • 0
-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{

    [self NextHeading]; // this plays an mp3 file

    [self NextHeadingMeaning]; // this plays an Mp3 file

}

Only [self NextHeadingMeaning] method is called and NextHeading method is missed each time

-(IBAction) NextHeading{ 
    ; 

    NSString *Filename = [[NSString alloc]initWithFormat:@"CH%@S%@",Heading,Meaning];
    Filepath = [[NSBundle mainBundle]pathForResource:Filename ofType:@"mp3"]; 

    audio = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:Filepath] error:NULL]; 

    audio.delegate = self; 
    ; 
    [Filename autorelease]; 
}

-(IBAction) NextHeadingMeaning { 
    ; 

     NSString *Filename = [[NSString alloc] initWithFormat:@"CH%@S%@",bold**Chapter**bold, Meaning]; 
     Filepath = [[NSBundle mainBundle]pathForResource:Filename ofType:@"mp3"]; 

     audio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:Filepath] error:NULL]; 

     audio.delegate = self; 
     ; 
     [Filename autorelease]; 
}

Why is this happening and how can I resolve it ?

Please advice, thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:11:56+00:00Added an answer on June 2, 2026 at 9:11 am

    You just used a single iVar (audio) as an player, and when you send NextHeading & NextHeadingMeaning message, the audio init with your sound_1.mp3 file firstly (it’ll take some seconds if the mp3 file is big), then at the next moment (your first mp3 file might not inited, or has inited, but stopped followed by next message), you redo the init action with another mp3 file (sound_2.mp3), and finally, when the second mp3 file init done, audio plays sound_2.mp3. That’s why you think the NextHeading is skipped.

    So, to solve this problem, you can use a NSMutableArray iVar (e.g. audioPlayers), and create a local audio for both NextHeading & NextHeadingMeaning, and push it to audioPlayers.

    And I think it is better to preload sound files if you can. 🙂


    EDIT:

    There’s a playAtTime: method instead of play, you can delay the second audio player’s playing time by this method, just like this:

    [audioPlayer playAtTime:(audioPlayer.deviceCurrentTime + delay)];
    

    delay is in seconds (NSTimeInterval).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I include in my own header file the method: - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag;
- (void)viewDidLoad //In this scenario it only gets called once, but in other bits
void FileManager::CloseFile(File * const file) { for (int i = 0; i < MAX_OPEN_FILES;
- (void)viewDidUnload { self.GPSArray = nil; self.accelerometerArray = nil; self.headingArray = nil; self.managedObjectContext =
void GasPump::dispense() { bool cont = true; char stop; do{ cout << Press any
void openUpNow(FILE *x, FILE *y) { x = fopen(xwhatever, r); y = fopen(ywhatever, r);
- (void)loadLocations { NSString *url = @<URL to a text file>; NSStringEncoding enc =
In my app I use AVAudioPlayer to play some mp3. My code is: -
- (void)viewDidLoad { [super viewDidLoad]; UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithTitle:@Refresh style:UIBarButtonItemStylePlain target:self action:@selector(refreshButtonClicked:)];
void PrintNow(const std::vector<int> &v) { std::cout << v[0] << std::endl; } std::vector<int>().push_back(20); // this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.