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 8885889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:25:22+00:00 2026-06-14T21:25:22+00:00

I have a basic beep sound that I loaded with AVAudioPlayer in my app.

  • 0

I have a basic beep sound that I loaded with AVAudioPlayer in my app.

It can play the beep fine if my finger isn’t panning my MKMapView.

My beep is set to play every 2 seconds.

When I start panning the map view, and don’t take my finger off the screen, the beep stops playing.

I recall NSUrlConnection also doesn’t fire while scrolling a table view, I thought this might be the same problem but I couldn’t figure out how I can add my audio player to the proper run loop.

I setup my player like this:

-(void)setupBeep
{
    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/beep.mp3", [[NSBundle mainBundle] resourcePath]]];

    NSError *error;
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    audioPlayer.numberOfLoops = 0;

    if(error)
    {
        NSLog(@"Error opening sound file: %@", [error localizedDescription]);
    }
}

and I am playing my sound like this:

// plays a beeping sound
-(void)beep
{
    [audioPlayer play];
}

Anyone came across this problem before?

  • 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-14T21:25:24+00:00Added an answer on June 14, 2026 at 9:25 pm

    How have you scheduled your -beep method to be called?

    I suspect you’ve added an NSTimer to the main run loop in the default input mode. The reason you’re not hearing anything is that while MKMapView is tracking your finger, the run loop is in not in NSDefaultRunLoopMode—it’s in UITrackingRunLoopMode.

    Try scheduling in NSRunLoopCommonModes, which includes both default and tracking modes:

    NSTimer *timer = [NSTimer timerWithTimeInterval:interval target:self selector:@selector(beep) userInfo:nil repeats:YES];
    [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
    

    Also, be aware that NSTimer retains its target. A repeating timer will reschedule itself automatically, so you’ll need to call its -invalidate method to remove it from the loop and allow the target to be released.

    EDIT: Check out Apple’s Threading Programming Guide: Run Loops for a much more detailed explanation.

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

Sidebar

Related Questions

I have basic Spring MVC 3 setup for i18n where I can show labels
I have a basic web service that returns the following object as JSON: public
I have basic issue that i don't understand, we use HEAT to consume directory
I have basic stored procedure that performs a full text search against 3 columns
I'm using node, express and connect for a simple app and have basic HTTP
I have Basic Authorization mechanism on the server for WSDL/SOAP. How I can send
I have basic code that looks like this: while(inputfileStream.good()) { for(int i = 0;i<levels;i++)
I have basic function that prints network errors based on enum NetworkError. that looks
I have basic JavaScript code that needs to tell how many names out of
I have basic *.xib file, which have NSView. How can I use another nib

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.