title: iOS background music problems
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8467533/ios-sdk-playing-music-on-the-background-and-switching-views">iOS SDK : playing music on the background and switching views</a>  </p>
  </blockquote>
  
  
  
  <p>Hi guys im currently using this code to play background music in my app when its launched .But when i switch views to my SecondView and return back to my Firstview the music starts over and overlaps the music that is currently playing and it keeps overlapping music when i return back to my Firstview, how can i have the music start over when i switch back to my Firstview from my SecondView.</p>
  
  <p>FirstViewController.m</p>
  
  <pre><code>- (void)viewDidLoad {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"drums" ofType:@"mp3"];
    theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPathath] error:NULL];
    theAudio.delegate = self;
    theAudio.numberOfLoops = -1;
    [theAudio play]; 
  </code></pre>