This is copied straight from my Stackoverflow question here: http://stackoverflow.com/questions/9495456/local-file-plays-with-avaudioplayer-but-not-with-avplayer
Might be easier to view there with code formatting ;-) 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 -- View this message in context: http://monotouch.2284126.n4.nabble.com/Playing-local-mp3-works-with-AVAudioPlayer-but-not-AVPlayer-tp4430999p4430999.html Sent from the MonoTouch mailing list archive at Nabble.com. _______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
