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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:10:13+00:00 2026-06-13T02:10:13+00:00

I have an app that when it launches it plays an intro clip. The

  • 0

I have an app that when it launches it plays an intro clip. The following code is in the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions within the appDelegate.m which works just splendid.

NSLog(@"PLAY SOUND CLIP WHILE LOADING APP");
NSURL *clip = [[NSBundle mainBundle] URLForResource: @"intro" withExtension:@"caf"];
self.startupPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:clip error:NULL];
[self.startupPlayer play];

If the user changes view before the intro sound finishes it still continues to play. I have placed this code outside of - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions thinking it would help but no.

-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
// Stop Sound
[self.startupPlayer stop];
}

I thought maybe if I put an if statement right after the load request that might do the trick but it has not worked. See example:

NSLog(@"PLAY SOUND CLIP WHILE LOADING APP");
NSURL *clip = [[NSBundle mainBundle] URLForResource: @"intro" withExtension:@"caf"];
self.startupPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:clip error:NULL];
[self.startupPlayer play];

if ([viewDidDisappear == YES]) {
[self.startupPlayer stop];
}

Any suggestions that would stop the intro sound if the user changes view before that clip is done playing would be great. Oh and I’ve used the “viewWillDisappear” in other parts of the app with success, but in this case I choose “viewDidDisappear” because the later didn’t work either. So I’m stumped. Thanks in advance.

EDIT: So I moved the viewWillDisappear into my MainViewController and called the delegate but I’m still not having any luck. Again, help would be appreciated.

  • 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-13T02:10:14+00:00Added an answer on June 13, 2026 at 2:10 am

    I solved this issue by taking the @property declaration for *startupPlayer and placing it in the AppDelegate.h file instead of how it was below;

    In the AppDelegate.m

    @interface AppDelegate () 
    
    @property (nonatomic, strong) AVAudioPlayer *startupPlayer;
    @end
    

    Then I still @synthesized it in the .m file as shown below and kept the didFinishLaunchingWithOptions the same:

    @implementation AppDelegate 
    @synthesize startupPlayer = _startupPlayer;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    
    //------ PLAY SOUND CLIP WHILE LOADING APP -----
    
    NSLog(@"PLAY SOUND CLIP WHILE LOADING APP");
    NSURL *clip = [[NSBundle mainBundle] URLForResource: @"intro" withExtension:@"caf"];
    self.startupPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:clip error:NULL];
    [self.startupPlayer play]; }
    

    Then in my MainViewController.m

    #import "AppDelegate.h"
    
    -(void)viewWillDisappear:(BOOL)animated
    {
    [super viewWillDisappear:animated];
    //stop intro sound
    AppDelegate *introClip = (AppDelegate *)[[UIApplication sharedApplication]delegate];
    [[introClip startupPlayer]stop];}
    

    Now even if the intro music is still playing through one cycle, the user can switch to another view and stop that music.

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

Sidebar

Related Questions

We have a VB6 app that launches our .NET code upon startup. Cold start
I have a button that launches the google maps app on my device via
I have a fairly simple app that launches the camera from a menu. The
I have a Windows Forms app that itself launches different threads to do different
We have a launcher app that does some setup (starting a server), launches a
I have a C# Windows Forms app that launches a webpage based on some
Suppose that, I have an android app that launches browser with some url supplied
I have a portion of my app that simply launches a webview linked to
I have an app that launches a browser with a VIEW intent pointing at
I have an app that launches to a tab bar controller. When the app

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.