Tuesday, 17 September 2013

Cant pause audio during applicationDidEnterBackground

Cant pause audio during applicationDidEnterBackground

I cant change the values or alter any variables or objects declared. Can
anyone see whats wrong?
In my app delegate method..
- (void)applicationDidEnterBackground:(UIApplication *)application
{
MainPage *mp = [[MainPage alloc]init];
mp.newTime = [[NSDate date] timeIntervalSinceDate:mp.date];
[mp.timer invalidate];
mp.switchT = 1;
mp.playBarButton.enabled = YES;
mp.pauseBarButton.enabled = NO;
mp.stopBarButton.enabled = YES;
[mp.avPlayer pause];
}
None of these actions above are executed..In my mainpage.h file I have the
followed declared like this
@property (nonatomic, retain) AVAudioPlayer *avPlayer;
@property (strong, retain) NSTimer *timer;
@property (strong, retain) NSDate *date;
@property (nonatomic) NSTimeInterval newTime;
@property (nonatomic) NSInteger switchT;
@property (strong, nonatomic) IBOutlet UIBarButtonItem *playBarButton;
@property (strong, nonatomic) IBOutlet UIBarButtonItem *pauseBarButton;
@property (strong, nonatomic) IBOutlet UIBarButtonItem *stopBarButton;
Of coarse in my implementation file these are synthesized and all works
well with my code within mainpage.m just not in my appDelegate file can
anyone see the problem? Note this is a fully functioning app everything
works well just can't execute the following code in my
applicationDidEnterBackground method and im assuming its the way my
properties are made? Also no errors with my code written in the app
delegate.

No comments:

Post a Comment