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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:00:53+00:00 2026-06-05T03:00:53+00:00

I have set music file on button click in the memory game application. Music

  • 0

I have set music file on button click in the memory game application.

Music is properly played, for some time but after the number of the buttons click looses the sound effect from the applcation.

-(void)setButtons_AsPerTheMatrixSelection
{
    for ( i = 0 ; i < cv ; ++i )
    {
        for ( j = 0 ; j < ch ; ++j )
        {
            btnMatrix = [[[UIButton alloc] initWithFrame:CGRectMake(10+pw*j, 51+ph*i, width, height)] autorelease];
            btnMatrix.tag = i*ch+j;
            btnMatrix.userInteractionEnabled = TRUE;
            bulImageStatus = FALSE;
            [btnMatrix addTarget:self action:@selector(changeImage:) forControlEvents:UIControlEventTouchUpInside];
            [btnMatrix setImage:imgDefaultBG forState:UIControlStateNormal];
            [viewWithButtons addSubview:btnMatrix];

            [arrButton addObject:btnMatrix];
        }
    }
}    

-(void)changeImage:(id)sender
{
    NSString *musicPath = [[NSBundle mainBundle] pathForResource:@"ding" ofType:@"mp3"];
    if (musicPath) 
        TapSoud = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:musicPath] error:nil];

    [TapSoud setDelegate:self];
    [TapSoud prepareToPlay];
    [TapSoud play];
}

This is working perfectly for number of presses but after certain click i am not able to play this button click tone.

what can be the issue & how can be solved this issue.

Is there any other way to play audio file?

Please suggest the appropriate solution.

Thanks.

  • 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-05T03:00:55+00:00Added an answer on June 5, 2026 at 3:00 am

    AVAudioPlayer is alloced over and over but never released.

    try this.

    -(void)changeImage:(id)sender
    {
        NSString *musicPath = [[NSBundle mainBundle] pathForResource:@"ding" ofType:@"mp3"];
        if (musicPath) {
            if(TapSoud){ // TapSound ? 
                 [TapSoud release];
                  TapSoud = nil;
            }
            TapSoud = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL 
    fileURLWithPath:musicPath] error:nil];
    }
    
    [TapSoud setDelegate:self];
    [TapSoud prepareToPlay];
    [TapSoud play];
    

    }

    • 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 some background music, when a certain button is
I have read some here: http://www.asp.net/mvc/tutorials/mvc-music-store-part-4 and set some stuck namespace MvcMusicStore.Models { public
I have set up multiple targets in a single xml file. I expect all
I have set permission to allow anonymous user to create page. but when the
I have a list of extension to mimetype in a INI file. However some
I need help trying set-up Foreign Keys after having difficulty following Music library MySQL
I have set up my AVAudioSession to play music in the background AVAudioSession *audioSession
I currently have background music playing in my application. in: -(void)viewDidLoad I start the
I have set thumb image of a seek bar but my thumb looks little
I have an application, targeting mango devices, which plays music via a BackgroundAudioAgent. As

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.