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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:22:50+00:00 2026-05-17T23:22:50+00:00

I am trying to play dynamically few mp3 sounds using AVAudioPlayer. The following code

  • 0

I am trying to play dynamically few mp3 sounds using AVAudioPlayer.

The following code works fine and indeed plays the sound,
nevertheless I get this error when Analyzing

“Pass-by-value argument in message expression is undefined”

Why so and how should one fix it?

+(void)playSound:(int)soundName
{
    NSString *theSound;
    switch (soundName) {
        case 1:
            theSound = @"beep1.mp3";
            break;
        case 2:
            theSound = @"beep2.mp3";
            break;
        case 3:
            theSound = @"beep3.mp3";
            break;
        default:
            break;
    }
    //
    NSURL *s1 = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], theSound]];
    NSError *error;
    AVAudioPlayer *sound1;
    sound1 = [[[AVAudioPlayer alloc] initWithContentsOfURL:s1 error:&error] autorelease];
    sound1.numberOfLoops = 0;
    //[sound1 prepareToPlay];
    [sound1 play];

}
  • 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-17T23:22:50+00:00Added an answer on May 17, 2026 at 11:22 pm

    Do you really want to try and play a sound file with no path if soundName is not 1,2 or 3?

    For your default clause, either report an error, or just silently return. Don’t create a player with an invalid path and ask to it to play it, it will only get upset.

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

Sidebar

Related Questions

Trying to play a sound via javascript and want to change it dynamically using
Im trying to play a sound in my app using the AVAudioPlayer stored in
I'm trying to play an mp3 audio file on iPhone executing the following code:
I'm trying to play a sound file from an iPhone program. Here's the code:
I am trying to play audio buffered sound (.wav) using AudioTrack. Please see the
I'm trying to play only part of a sound using FMOD, say frames 50000-100000
I'm trying to play a sound on a button click i'm using: -(IBAction)sound {
I am trying to play and audio file using DirectX dll. Audio.FromFile(Message 1.mp3).Play(); But
I am trying to play a sound file using : gst-launch playbin uri=some URL
I am trying to play music in my application. The music works fine but

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.