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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:07:00+00:00 2026-06-07T06:07:00+00:00

I need some help with my app I have recently started. I am a

  • 0

I need some help with my app I have recently started. I am a very big starter to coding so please do help me, it’ll mean a lot. I need a piece of music to play as soon as the user enters my app, i have followed other youtube tutorials but they only work for the older Xcode versions, so please help thank you so much.

  • 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-07T06:07:01+00:00Added an answer on June 7, 2026 at 6:07 am

    How about putting it in you application didFinishLaunching but be sure to instantiate it in you .h and .m.

    Something like this should do your problem:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    
        NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
        resourcePath = [resourcePath stringByAppendingString:@"/YOURMUSICNAME.wav"];
        NSLog(@"Path to play: %@", resourcePath);
        NSError* err;
    
        //Initialize our player pointing to the path to our resource
        player = [[AVAudioPlayer alloc] initWithContentsOfURL:
                     [NSURL fileURLWithPath:resourcePath] error:&err];
    
        if( err ){
            //bail!
            NSLog(@"Failed with reason: %@", [err localizedDescription]);
        }
        else{
            //set our delegate and begin playback
            player.delegate = self;
            [player play];
            player.numberOfLoops = -1;
            player.currentTime = 0;
            player.volume = 1.0;
        }
    }
    

    Then if you want to stop it:

    [player stop];
    

    or pause it :

    [player pause];
    

    and also import it in your header file:

    #import <AVFoundation/AVFoundation.h>
    

    EDIT:

    You should to ofcourse declare it in your header, then synthesize it.

    //.h and add the bold part:

    @interface ViewController : UIViewController <AVAudioPlayerDelegate> {

    AVAudioPlayer *player;
    }
    @property (nonatomic, retain) AVAudioPlayer *player;
    

    //.m

    @synthesize player;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help, please. I have a line of horizontal thumbnails loaded as ONE
I m new to iphone app development and i need some help. I have
I need some help. In my android app I have a ViewFlipper that contains
Need some help from Oracle app developers out there: I have an C#.NET 4.0
I need some help. I have an app that is based on UITabBarController. It
I am writing an Android app and need some help. I have a string
Hey guys i need some help with logic in my app. I have an
I need some help to have a widget work correctly in a web2py app.
I need some help. I have a 2 pages in my app. Page #1
I have an app I'm creating and I need some help. Under the view

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.