Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play remote mp3 using iOS

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?

like image 601
Tony Avatar asked Jun 28 '26 13:06

Tony


1 Answers

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).

like image 114
Michael Dautermann Avatar answered Jun 30 '26 03:06

Michael Dautermann