project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m
changeset 5699 1a9a6a7662aa
parent 5662 99083392cd4f
child 5968 4e8bb227be9a
equal deleted inserted replaced
5698:332b4cc98569 5699:1a9a6a7662aa
    63 +(void) loadBackgroundMusic {
    63 +(void) loadBackgroundMusic {
    64     NSString *musicString = [[NSBundle mainBundle] pathForResource:@"hwclassic" ofType:@"mp3"];
    64     NSString *musicString = [[NSBundle mainBundle] pathForResource:@"hwclassic" ofType:@"mp3"];
    65     AVAudioPlayer *background = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:musicString] error:nil];
    65     AVAudioPlayer *background = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:musicString] error:nil];
    66 
    66 
    67     background.delegate = nil;
    67     background.delegate = nil;
    68     background.volume = 0.5f;
    68     background.volume = 0.4f;
    69     background.numberOfLoops = -1;
    69     background.numberOfLoops = -1;
    70     [background prepareToPlay];
    70     [background prepareToPlay];
    71     [HedgewarsAppDelegate sharedAppDelegate].backgroundMusic = background;
    71     [HedgewarsAppDelegate sharedAppDelegate].backgroundMusic = background;
    72     [background release];
    72     [background release];
    73 }
    73 }
   124 
   124 
   125 -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
   125 -(void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
   126     // don't stop music when it is playing
   126     // don't stop music when it is playing
   127     if (self.isInGame) {
   127     if (self.isInGame) {
   128         [self.backgroundMusic stop];
   128         [self.backgroundMusic stop];
   129         releaseAndNil(self.backgroundMusic);
   129         self.backgroundMusic = nil;
   130         MSG_MEMCLEAN();
   130         MSG_MEMCLEAN();
   131     }
   131     }
   132     print_free_memory();
   132     print_free_memory();
   133     // don't clean mainMenuViewController here!!!
   133     // don't clean mainMenuViewController here!!!
   134 }
   134 }