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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:58:21+00:00 2026-06-10T06:58:21+00:00

This code: NSString *urlPath = [[NSBundle mainBundle] pathForResource:@snd ofType:@mp3]; NSURL *url = [NSURL fileURLWithPath:urlPath];

  • 0

This code:

NSString *urlPath = [[NSBundle mainBundle] pathForResource:@"snd" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:urlPath];

NSError *err;

AVAudioPlayer* audioPlayerMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&err];

[audioPlayerMusic play];

Works just fine.

While this one:

NSString *urlPath = [[NSBundle mainBundle] pathForResource:@"snd" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:urlPath];

AVPlayer* audioPlayerMusic = [AVPlayer playerWithURL:url];

[audioPlayerMusic play];

Plays nothing!

What’s 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-06-10T06:58:23+00:00Added an answer on June 10, 2026 at 6:58 am

    When playing/streaming a remote file, AVPlayer isn’t ready to play it – you must wait for it to buffer enough data to start paying, while this is not necessary when using AVAudioPlayer. So, either use AVAudioPlayer, or make AVPlayer notify your class using key-value observing when it’s ready to begin playback:

    [player addObserver:self forKeyPath:@"status" options:0 context:NULL];
    

    And in your class (self refers to its instance in the above line):

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
        if ([keyPath isEqualToString:@"status"]) {
            if (player.status == AVPlayerStatusReadyToPlay) {
                [player play];
            } else if (player.status == AVPlayerStatusFailed) {
                /* An error was encountered */
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: NSString *path = [NSString stringWithFormat:@%@/%@, [[NSBundle mainBundle] resourcePath], @change.mp3]; NSURL
I am currently trying out this code: NSString *path = [[NSBundle mainBundle] pathForResource:@dream ofType:@m4a];
Please consider this code: NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:[ NSURL URLWithString:url ]]; //
I'm using this code: NSString *recievedData; NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@http://www.site.com/] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; // create
I have a this code : NSString *url = [NSString stringWithFormat:@tt://classObj?title=%@, obl.title]; TTTableImageItem *cell
i found this code -(NSString *) genRandStringLength: (int) len { NSMutableString *randomString = [NSMutableString
i have an error in this code NSString *str = @above string; //load above
I currently have this piece of code: NSString *strURL = [NSString stringWithFormat:@http://www.sample.com /phpFile.php?firstname=%@,txtfirstName.text]; NSString
Im getting data from a server by executing this code: - (void) sendGeneral:(NSString *)
Check this code (My Custom Keyboard): -(IBAction) updateTextBackSpace:(id)sender { if([txtview.text length]>0) { NSString *deletedLastCharString

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.