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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:35:18+00:00 2026-05-27T23:35:18+00:00

I have searched for this answer and have not found it. I have music

  • 0

I have searched for this answer and have not found it.

I have music that plays in the background when my iPhone app is launched. But I want a button so that users can mute the music. There are sound effects within the app also so sliding the mute button on the side of the device won’t cut it.

This is the current code I have for the AVAudioPlayer.

    - (void)viewDidLoad{
#if TARGET_IPHONE_SIMULATOR
    //here code for use when execute in simulator
#else
    //in real iphone
    NSString *path = [[NSBundle mainBundle] pathForResource:@"FUNKYMUSIC" ofType:@"mp3"];  
    AVAudioPlayer *TheAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];  
    TheAudio.delegate = self;  
    [TheAudio play];      
    TheAudio.numberOfLoops = -1;
#endif
}

Can anyone help me out the code needed for a simple button to simply stop the music and start it again.

Thanks in advanced.

  • 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-27T23:35:19+00:00Added an answer on May 27, 2026 at 11:35 pm

    Put this code in the viewcontroller.h file:

    -(IBAction) btnStop:(id)sender;
    

    Put this code in the viewcontroller.m file:

    -(IBAction) btnStop:(id)sender { 
        [TheAudio stop];
        //Whatever else you want to do when the audio is stopped
    }
    

    In the Interface builder, connect a button to this action, so when it is clicked this action will be called.
    That should make the music stop.

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

Sidebar

Related Questions

I have searched this question, and found an answer in MySQL but this is
I have searched a lot about UTF8 decoding, but not found the answer yet.
I have searched SO (and Google) but not found any fully matching answer to
Just wondering I have searched but I have not found an answer. My question
I have searched the numerous questions that look like this one, but haven't found
I have searched for topics specifically to this question but have not found anything
I've searched for the solution for this everywhere and have not found an answer,
I have searched for this, and i found that for api less than 12,
I have searched through the numerous S/O postings and have not found an answer
I've searched around for answers to this question, but not found anything quite on

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.