views:

86

answers:

2

Hi, I want to play a MP3 which is on a distant server. What can i do to play the MP3 in a Iphone Application ?

A: 

You could try AVPlayer. For example,

avPlayer = MonoTouch.AVFoundation.AVPlayer.FromUrl(new NSUrl("http://www.robtowns.com/music/blind_willie.mp3"));
avPlayer.Play();

Check out the MonoTouch or Apple documentation for more details.

dommer
Cool it works only on the simulator. But I can't launch the application on my iphone :-(. Do you have an idea ? I use the last version of Monotouch
Kalonji
What's happening on the iPhone? Error?
dommer
On my iphone, i click on the application which crash. On my simulator i have no error
Kalonji
Debug it on the iPhone using MonoDevelop and see if you get the error reported. Are you running iOS 4 on your phone?
dommer
I have debuged my application on iOS 3 but I don't have more informations. Now i have upgraded my iphone on iOS 4 and my application work. I think we have a problem with the class AVPlayer on iOS 3.
Kalonji
A: 

The AVPlayer will work, if you want low-level access to the media pipeline, you can use the AVAudioFile APIs that let you stream the data yourself and then feed it to the audio decoders.

See my sample at:

http://github.com/migueldeicaza/monotouch-samples/tree/master/StreamingAudio/

This is a low-level API, just keep that in mind. The sample does its own file fetching from the remote site.

miguel.de.icaza
At the beginning i used your samples. But after severals playing of mp3 the application block. I have tried with AVPlayer and now no problems.
Kalonji