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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:06:38+00:00 2026-06-08T20:06:38+00:00

I have a problem with AVAudioPlayer to reach a sound from an other view.

  • 0

I have a problem with AVAudioPlayer to reach a sound from an other view. It’s work perfectly with AudioToolbox but not with AVAudioPlayer. Here is my code :

.h file :

#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreText/CoreText.h>
#import "SimpleTableCelldetail.h"

int clicked;


@interface DetailViewController : UIViewController {

AVAudioPlayer *audioPlayer;
IBOutlet UIButton *start;

}

@property (strong, nonatomic) IBOutlet NSString *audioSon;

@end

.m file

-(IBAction)play:(id)sender {

if(clicked == 0) {
    clicked = 1;
    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:audioSon, [[NSBundle mainBundle] resourcePath]]];

    NSError *error;
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    audioPlayer.numberOfLoops = 0;

    [audioPlayer play];
    [start setTitle:@"Stop" forState:UIControlStateNormal];
}
else {
    clicked = 0;
    [audioPlayer stop];
    [start setTitle:@"Ecouter" forState:UIControlStateNormal];
}
}

When i run this code, the button don’t play any sound.
The value of audioSon is “sound01.m4r”.

When i replace the line

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:audioSon, [[NSBundle mainBundle] resourcePath]]];

with

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/sound01.m4r", [[NSBundle mainBundle] resourcePath]]];

It works but xcode show me an error :

2012-08-01 01:59:44.697 CustomTable[12709:3703] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security

Any idea?

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-08T20:06:39+00:00Added an answer on June 8, 2026 at 8:06 pm

    You’re using stringWithFormat in your original line when you should be using stringByAppendingPathComponent. If you change this you’ll be accessing the correct file and your program should work.

    NSURL *url = [NSURL fileURLWithPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:audioSon];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have little problem in my iPhone application code but can not identify. please
I have problem SIMILAR to preventing form data reposting, but not quite the same
I have problem with repopulating form_upload after validation. Other input fields or selectboxes are
I have problem with UIWebView delay when the load image from url. In my
I have problem with AVAudioPlayer in iphone when ever the my ipod is lock(sleep)
I have a view where a video record, then I have a section AVAudioPlayer,
In a certain view I have a bunch of AVAudioPlayer properties, each one is
Have problem while getting data from Memcached on .NET MVC solution. I have this
Sorry if this is a stupid question, but I have come across a problem
Hi I have a very strange problem in the simulator works perfect but when

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.