3

I have a remote mp3 (small file, just a few seconds) which I have the URL. I need to play it on an App that uses iOS 4.

The URL is not exactly a .mp3 file, but it is a dynamic .php url that requests the .mp3 file. If I put that php route in the browser it downloads the mp3 file.

I am trying to use this project (https://github.com/mattgallagher/AudioStreamer) but it isn't working. The audio starts but it only plays a part of it.

How can I do it?

Tony
  • 10,088
  • 20
  • 85
  • 139

1 Answers1

5

If it's truly just a small (and static, non-streaming) mp3 file, why not consider doing something like:

NSError * error = nil;
AVAudioPlayer * avPlayerObject =
    [[AVAudioPlayer alloc] initWithContentsOfURL: yourRemoteURL error:&error];
if(avPlayerObject)
{
    [avPlayerObject play];
}

Check out Apple's AVAudioPlayer class (documentation linked for you).

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Thanks for the answer but didn't worked. The URL is not exactly a .mp3 file, but it is a dynamic .php url that requests the .mp3 file. If I put that php route in the browser it downloads the mp3 file. – Tony Dec 26 '11 at 20:28
  • Would have been nice to have had that detail in the original question. Does the php give back any useful URL (pointing to the mp3 file)? If it doesn't give back a URL, can you download the data and then use `AVAudioPlayer` to play the data from a locally saved file? – Michael Dautermann Dec 26 '11 at 20:31
  • Yes, sorry I did not realized that before. I will try this tomorrow. I updated the question. – Tony Dec 26 '11 at 21:01