Playing a Sound While App Runs
===

hi there I'm creating and iOS application and trying to make it play a sound when running I've type up my code in the app delegate .h , .m and it plays the sound fine but the thing is it goes to a black screen when my ViewController.xib has a blue background heres heres the code i have 

AppDelegate.h



    #import <UIKit/UIKit.h>
    #import <AVFoundation/AVFoundation.h>
    @class ViewController;
    
    @interface AppDelegate : NSObject <UIApplicationDelegate, AVAudioPlayerDelegate> {
        UIWindow *window;
        ViewController *viewController;
    	AVAudioPlayer *_backgroundMusicPlayer;
    	BOOL _backgroundMusicPlaying;
    	BOOL _backgroundMusicInterrupted;
    	UInt32 _otherMusicIsPlaying;
    }
    
    
    @property (nonatomic, retain) IBOutlet UIWindow *window;
    
    @property (nonatomic, retain) IBOutlet ViewController *viewController;
    
    - (void)tryPlayMusic;


AppDelegate.m


    #import "AppDelegate.h"
    
    #import "ViewController.h"
    
    @implementation AppDelegate
    
    @synthesize window = _window;
    @synthesize viewController = _viewController;
    
    - (void)applicationDidFinishLaunching:(UIApplication *)application {    
        
    	// Set up the audio session
    	// See handy chart on pg. 55 of the Audio Session Programming Guide for what the categories mean
    	// Not absolutely required in this example, but good to get into the habit of doing
    	// See pg. 11 of Audio Session Programming Guide for "Why a Default Session Usually Isn't What You Want"
    	NSError *setCategoryError = nil;
    	[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&setCategoryError];
    	
    	// Create audio player with background music
    	NSString *ticktockPath = [[NSBundle mainBundle] pathForResource:@"ticktock" ofType:@"wav"];
    	NSURL *ticktockURL = [NSURL fileURLWithPath:ticktockPath];
    	NSError *error;
    	_backgroundMusicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:ticktockURL error:&error];
    	[_backgroundMusicPlayer setDelegate:self];  // We need this so we can restart after interruptions
    	[_backgroundMusicPlayer setNumberOfLoops:-1];	// Negative number means loop forever
    	
        // Override point for customization after app launch    
        [window addSubview:viewController.view];
        [window makeKeyAndVisible];
    }
    
    - (void) audioPlayerBeginInterruption: (AVAudioPlayer *) player {
    	_backgroundMusicInterrupted = YES;
    	_backgroundMusicPlaying = NO;
    }
    
    - (void) audioPlayerEndInterruption: (AVAudioPlayer *) player {
    	if (_backgroundMusicInterrupted) {
    		[self tryPlayMusic];
    		_backgroundMusicInterrupted = NO;
    	}
    }
    
    - (void)applicationDidBecomeActive:(NSNotification *)notification {
    	[self tryPlayMusic];
    }
    
    - (void)tryPlayMusic {
    	
    	
    	// Play the music if no other music is playing and we aren't playing already
    	if (_otherMusicIsPlaying != 1 && !_backgroundMusicPlaying) {
    		[_backgroundMusicPlayer prepareToPlay];
    		[_backgroundMusicPlayer play];
    		_backgroundMusicPlaying = YES;
    	}	
    }
    
    - (void)dealloc {
        [viewController release];
        [window release];
        [super dealloc];
    }
    
    
    @end


ok so thats all the code 

![enter image description here][1]



and heres what i get when app loads and the sound works fine

![enter image description here][2]

and this is what i want to get (ViewController.xib)

![enter image description here][3]


Thank in advanced


  [1]: http://i.stack.imgur.com/ZrcbW.png
  [2]: http://i.stack.imgur.com/GR4Ec.png
  [3]: http://i.stack.imgur.com/eoQnq.png