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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:26:29+00:00 2026-05-31T13:26:29+00:00

Simple enough… I have a background song playing on my game, and I would

  • 0

Simple enough… I have a background song playing on my game, and I would like to crossfade a track, instead of a hard stop.

//Prep Background Music
        if (![[SimpleAudioEngine sharedEngine]isBackgroundMusicPlaying]) {
             [[SimpleAudioEngine sharedEngine] preloadBackgroundMusic:@"song.mp3"];
        }
        [[SimpleAudioEngine sharedEngine] setBackgroundMusicVolume:1.0]; 

        //Play Background Music
         if (![[SimpleAudioEngine sharedEngine]isBackgroundMusicPlaying]) {
             [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"song.mp3" loop:YES];
         }
  • 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-05-31T13:26:30+00:00Added an answer on May 31, 2026 at 1:26 pm

    You can’t do that using SimpleAudioEngine. Here is how I did it:

    1. Create a class that extends CDAudioManager

    2. In the method that you call to start playing a new background music, first check if the ivar backgroundMusic (inherited from CDAudioManager) is not nil and is playing. If it is, then fade it out using CDLongAudioSourceFader.

    3. Load the new background music into backgroundMusic (it’s an instance of CDLongAudioSource — look it up). Fade it in using CDLongAudioSourceFader.

    Here’s a snippet of the method in step 2 (sorry can’t show you the rest as it is part of my own proprietary library)

    - (void)audioBackgroundPlay:(NSString *)bgmfile crossfade:(float)fade {
        CDLongAudioSource *audioSource = [self audioBackgroundLoad:bgmfile];
        if (audioSource != backgroundMusic) {
            if (backgroundMusic) {
                [self audioBackgroundControl:AUDIOCTRL_STOP fade:fade];
                backgroundMusic.audioSourcePlayer.meteringEnabled = NO;
                [backgroundMusic release];
            }
            backgroundMusic = [audioSource retain];
            if (meteringEnabled_) {
                backgroundMusic.audioSourcePlayer.meteringEnabled = YES;
            }
        }
        if (![backgroundMusic isPlaying]) {
            [self audioBackgroundControl:AUDIOCTRL_PLAY fade:fade];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this seems like a simple enough question but I can't seem to find a
This sounds like a simple enough question, but can't find the answer for the
Seems like it should be simple enough but it's driving me up the wall.
Seems like this should be simple enough but for whatever reason I am unable
This seems like it should be simple enough, but I can't seem to get
Simple enough question: Is it possible to leverage css transitions when it would would
This should be simple enough, but somehow my brain stopped working. I have two
This should be simple enough. I have an iPhone app with a TableView. How
I have what seems a simple enough regex problem that I can't seem to
It's simple enough to code up a class to store/validate something like 192.168.0.0/16 ,

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.