Search code examples
iphoneobjective-cxcodemp3

How to play an mp3 file from server?


I want to play an mp3 file that is stored in a server Ex:-mp3 link

I have tried the other relevant answers but i didn't get the output. Can anyone please tell me how to play an mp3 that is stored on the web.


Solution

  • Apple's documentation for AVPlayer states the following: AVPlayerplayer works equally well with local and remote media files

    Apple's documentation for AVAudioPlayer states the following: Use this class for audio playback unless you are playing audio captured from a network stream

      -(IBAction)playTapped {
            AVPlayer *player = [[AVPlayer playerWithURL:[NSURL  URLWithString:@"http://www.mp3.com/mp3file.mp3"]] retain];
            [player play];
    
         }