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

  • Home
  • SEARCH
  • 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 7912155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:31:30+00:00 2026-06-03T13:31:30+00:00

How to resume audio after the phone call ends. Here is my code but

  • 0

How to resume audio after the phone call ends.

Here is my code but it is not working don’t know why

@interface MainViewController : UIViewController <InfoDelegate, AVAudioPlayerDelegate> 

In m file

-(void)audioPlayerBeginInterruption:(AVAudioPlayer *)audioPlayer;
{

}
-(void)audioPlayerEndInterruption:(AVAudioPlayer *)audioPlayer;

{
   [self.audioPlayer play];
   }   

Any ideas what is it i m doing wrong or missing from code.

Please help.

  • 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-03T13:31:31+00:00Added an answer on June 3, 2026 at 1:31 pm

    Depending on how your audio was stopped (did you call [self.audioPlayer stop]?) you may have to call [self.audioPlayer prepareToPlay] before calling play again.

    I believe what you ought to do is the following:

    -(void)audioPlayerBeginInterruption:(AVAudioPlayer *)audioPlayer;
    {
        [self.audioPlayer pause];
    }
    
    -(void)audioPlayerEndInterruption:(AVAudioPlayer *)audioPlayer;
    {
        [self.audioPlayer play];
    }   
    

    In my experience, if you call stop you then must call prepareToPlay before you can call play again.

    EDIT:

    Alternatively, you may need to handle interruptions via the AudioSession directly.

    Your app should initialize the AudioSession, something like this:

    AudioSessionInitialize(NULL, NULL, AudioInterruptionListener, NULL);
    

    Then, implement AudioInterruptionListener outside your @implementation/@end block, something like this:

    #define kAudioEndInterruption   @"AudioEndInterruptionNotification"
    #define kAudioBeginInterruption @"AudioBeginInterruptionNotification"
    
    void AudioInterruptionListener (
                                 void     *inClientData,
                                 UInt32   inInterruptionState
                                 )
    {
        NSString *notificationName = nil;
        switch (inInterruptionState) {
            case kAudioSessionEndInterruption:
                notificationName = kAudioEndInterruption;
                break;
    
            case kAudioSessionBeginInterruption:
                notificationName = kAudioBeginInterruption;
                break;
    
            default:
                break;
        }
    
        if (notificationName) {
            NSNotification *notice = [NSNotification notificationWithName:notificationName object:nil];
            [[NSNotificationCenter defaultCenter] postNotification:notice];
        }
    }
    

    Back in your Objective-C, you’ll need to listen for the notifications that this code may post, something like this:

    // Listen for audio interruption begin/end
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(beginAudioInterruption:) 
                                                 name:kAudioBeginInterruption object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(endAudioInterruption:) 
                                                 name:kAudioEndInterruption object:nil];
    

    And:

    -(void)beginAudioInterruption:(id)context
    {
        [self.audioPlayer pause];
    }
    
    -(void)endAudioInterruption:(id)context
    {
        [self.audioPlayer play];
    }
    

    Give that a whirl. 🙂

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

Sidebar

Related Questions

i'm working on an audio based app. audio is playing in the background but
How do we resume a download after the user quits the app, not just
Q : How to resume code operation after a handled exception ? i now
I have streamed audio from url,but when the call or sms comes i need
Can this be done? And if not, how far down towards Core Audio do
I'm trying to pause a recording on an incoming call and resume it later.
Here's what currently happens in my app: Locking: iPhone Lock Button Pressed -> Audio
Is it possible to resume interrupted uploads using HTTP Post? I am working on
How do I avoid resume after taking picture in android? I didn't override any
I'm trying to handle audio streaming interruption, when the user receives a call the

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.