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

  • Home
  • SEARCH
  • 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 4066124
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:05:46+00:00 2026-05-20T16:05:46+00:00

I have a button on a UIImagePicker overly , and I want it to

  • 0

I have a button on a UIImagePicker overly , and I want it to make some sound when clicked.
To do so, I have in my project resources a sound in m4a and mp3 formats (for test purpose).

I try to play the sound by many ways, trying alternatively with m4a and mp3 formats, but nothing goes out of the iPhone (not the simulator).

The Frameworks are include in the project.

Here is my sample code :

#import <AudioToolBox/AudioToolbox.h>
#import <AVFoundation/AVAudioPlayer.h>

- (IBAction) click:(id)sender {
// Try
/*
    SystemSoundID train;
    AudioServicesCreateSystemSoundID(CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("TheSound"), CFSTR("mp3"), NULL), &train);
    AudioServicesPlaySystemSound(train);
*/

// Try
/*
    NSError *error;
    AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource: @"TheSound" withExtension: @"mp3"] error:&error];
    [audioPlayer play];
    [audioPlayer release];
*/

// Try (works)
    //AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);

// Try
/*
    SystemSoundID soundID;
    NSURL *filePath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"TheSound" ofType:@"mp3"] isDirectory:NO];
    AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
    AudioServicesPlaySystemSound(soundID);
*/  

    NSLog(@"Clicked");
}

Could you tell me what is going wrong ?

  • 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-20T16:05:46+00:00Added an answer on May 20, 2026 at 4:05 pm

    You can’t use an MP3 with Audio Services. It must be a WAV file of a certain subtype. As for AVAudioPlayer, it supports MP3 files but when AVAudioPlayer is deallocated it stops playback, and since you do so immediately after sending -play (by sending -release to balance the +alloc), you never hear anything.

    So either convert the file to WAV, or hang onto your AVAudioPlayer long enough for it to play. 🙂

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

Sidebar

Related Questions

I have button on form2. i want when user click this button make something
how to make button cause validation for some controls and other not.. i have
I have a button on an ASP.NET wep application form and when clicked goes
I have a Button that is looking at 2 comboboxes to make sure they
I want my application to have button bar at the bottom, that is similar
I have Button inside application.resources DataTemplate : <DataTemplate x:Key=contactItem DataType={x:Type Model:Contact}> <Button x:Name=openButton Style={StaticResource
i have button, on a click of which i want to download the file
I have button with name itemname, and now I want to put underline just
simple question maybe but can't find solution. I have button for refresh/update some contents
I have some main activity and clicking on a button it launches a custom

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.