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 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

I'm brand spanking new to WPF and am trying to play around with projects
I've been trying a new way to set up a website using jQuery to
I'm trying to load a flash file using 'AC_FL_RunContent' like below. But the file
I'm trying to graphically display a graph of N lines and I'm trying to
I'm trying to write a very simple/minimal custom video player in Flash CS3 I
I'm trying to write a simple script around Lame to customize the program for
Hey there, I have an issues/bug when trying to have a v3 and v2
I have created a FLV video player using the AS3 flash.media.Video object (not the
To learn a bit more about FreeBSD and *nix systems in general, I'm starting
Hey guys I'm fairly green when it comes to wpf, so I need a

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.