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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:00:20+00:00 2026-06-08T05:00:20+00:00

I have an iOS app that plays a background soundtrack with one AVPlayer and

  • 0

I have an iOS app that plays a background soundtrack with one AVPlayer and plays other sound clips “on top” with a second AVPlayer. (The sound clips are streamed from the Internet, hence the requirement for AVPlayer.) The problem is that when the second AVPlayer starts playing, it causes the background AVPlayer to stop for a fraction of a second, similar to what’s described in this comment:

Play multiple Audio Files with AVPlayer

I am preparing the audio clips with this method:

- (void)prepareAudio:(NSURL *)assetURL {

asset = [AVURLAsset URLAssetWithURL:assetURL options:nil];
playerItem = [AVPlayerItem playerItemWithAsset:asset];
[player replaceCurrentItemWithPlayerItem:playerItem];


[playerItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil];
[playerItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];


[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(playerItemDidReachEnd:)
                                             name:AVPlayerItemDidPlayToEndTimeNotification
                                           object:[player currentItem]];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(playerItemFailedToReachEnd:)
                                             name:AVPlayerItemFailedToPlayToEndTimeNotification
                                           object:[player currentItem]];
 }

…and then invoking [player play]; when I want to hear each sound.

Is there something I need to do when I set up the audio session or each instance of the AVPlayer, so that the sounds blend without the glitch?

  • 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-08T05:00:25+00:00Added an answer on June 8, 2026 at 5:00 am

    This is probably as a result of the software encoder kicking in. You’ll see a pretty big spike in memory as the software encoder attempts to play the second sound clip. Take a look at the apple docs section “iOS Hardware and Software Audio Codecs”
    http://developer.apple.com/library/ios/#DOCUMENTATION/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html

    “When using hardware-assisted decoding, the device can play only a single instance of one of the supported formats at a time.”

    Also… “To play multiple sounds with best performance, or to efficiently play sounds while the iPod is playing in the background, use linear PCM (uncompressed) or IMA4 (compressed) audio.”

    If you have no choice in the media codecs you can provide, take a look at the AudioUnit framework to get a more seamless mixing. In particular the “Audio Mixer (MixerHost)” at http://developer.apple.com/library/ios/#samplecode/MixerHost/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010210

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

Sidebar

Related Questions

I have an app that plays audio using AVPlayer. I have enabled background audio
I have an App that does the pretty standard operation: It plays audio (streamed
I have an app that loads while a 2 second movie plays. Currently the
I have an app running on iOS 5.1 built with Xcode 4.31 that plays
I have an iOS app that uses a number of enums for valid values,
I have an old iOS app that I never distributed and am now trying
I have a Rails app that has 2 clients -- an iOS app reads/writes
I'm doing an iOS app that crawl my youtube subscription's videos. I have a
I have an iOS app with a UITableView that has flexible width, which allow
In my iOS app I have several UIElement s that can process user input:

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.