title: How to play a music file using URL link in iPhone?
body: <p>I want to play a music file using URL Link in the iPhone. But when I use the below code I am getting error I am not getting where I am going wrong. Can anyone Correct me?</p>
  
  <pre><code>-(void)viewDidLoad 
  
  {
  
  [super viewDidLoad];
  NSString* resourcePath = @"http://192.167.1.104:8888/SHREYA.mp3"; //your url
  
  NSData *_objectData = [NSData dataWithContentsOfURL:[NSURL URLWithString:resourcePath]];
  NSError *error;
  
  
  audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:_objectData error:&amp;error];
  audioPlayer.numberOfLoops = -1;
  
  if (audioPlayer == nil)
      NSLog([error description]);             
  
  else 
      [audioPlayer play];
  }
  </code></pre>