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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:50:21+00:00 2026-05-30T16:50:21+00:00

(Note: The code here is Monotouch/C#, however Objective-C Answers are welcome!) Im using AVPlayer

  • 0

(Note: The code here is Monotouch/C#, however Objective-C Answers are welcome!)

Im using AVPlayer as my app plays iPod library files as well as local mp3/m4a files. The playback of iPod library files is fine, however I cannot seem to get the AVPlayer to play local mp3 files.

For example, this code works:

NSUrl url;
AVAudioPlayer player2;

url = NSUrl.FromFilename(Path.Combine(Constants.TrackCacheLocation , songPath));

/* The url variable has the value file://localhost/private/var/mobile/Applications/B1ED2576-4398-43F3-8573-2FA3A0342265/Documents/Cache/Remote/dcaad4ff-452e-4d91-8788-c018e6b286f2.mp3 */

player2 = AVAudioPlayer.FromUrl(url);
player2.Play();

The above works fine, note that it’s using AVAudioPlayer.

This doesn’t (using AVPlayer):

NSUrl url;
AVPlayer player2;

url = NSUrl.FromFilename(Path.Combine(Constants.TrackCacheLocation , songPath));

/* The url variable has the value file://localhost/private/var/mobile/Applications/B1ED2576-4398-43F3-8573-2FA3A0342265/Documents/Cache/Remote/dcaad4ff-452e-4d91-8788-c018e6b286f2.mp3 */

player2 = AVPlayer.FromUrl(url);
player2.Play();

Creating an NSUrl from a local or remote web server also works (with AVPlayer), eg: http://10.0.0.1/testing/test.mp3 delays about a second or two while loading, then starts to play fine. I have a feeling im not creating my NSUrl correctly (even though it works fine for AVAudioPlayer). Any one any have ideas what could be going wrong?

Also, if I check the CurrentItem.Status of the AVPlayer it remains Unknown, it never changes to ReadyToPlay

  • 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-30T16:50:23+00:00Added an answer on May 30, 2026 at 4:50 pm

    Many API that uses NSUrl or NSUrlRequest parameters are async by design and will have issues (or even crash) if defined as a local variable (e.g. that will be collected when your method returns when still needed by the native code).

    You code above does not supply enough information about where they are created. If you’re using local variables then try to promote them as fields and ensure they will exists (e.g. don’t re-assign them) until you don’t need the AVPlayer anymore.

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

Sidebar

Related Questions

Using the code here: http://www.w3schools.com/php/php_xml_parser_expat.asp How would you get the attributes using the switch
(NOTE: Source code here https://github.com/cthielen/dss-evote ) I've got a simple voting application. A survey
Note : The code in this question is part of deSleeper if you want
Note my code below. I am trying to figure out why my data is
Environment is VS2008, .Net 3.5 The following C# code (note the specified encoding of
I have such a basic problem in Delphi,I can't solve it. My Code: Note:DataR
System.Diagnostics.Contracts.ContractException is not accessible in my test project. Note this code is purely myself
Note The question below was asked in 2008 about some code from 2003. As
Note: I am just consuming webservice I have no control over webservice code. So
this code is correct?? String note = text.txt; FileWriter file = new FileWriter(note); Scanner

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.