Search Results

Search found 1 results on 1 pages for 'ss30'.

Page 1/1 | 1 

  • how do i call mpmovieplayer from applicationwillresignactive in ppdelegate

    - by ss30
    i'm using mpmovieplayer to play audio stream, one problem i'm having trouble with handling intruptions e.g when call is received. My player is declared in viewcontroller and i beleive i need to do something in applicationdidresignactive in my appdelegate right? how do i do that if my appdelegate isn't aware of my moviePlayer? i'm new to iphone dev so i'm learning as i go and enjoying it :) here is what i'm doing in viewcontroller -(IBAction)play1MButton:(id)sender{ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerStatus:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; NSString *url = @"http://22.22.22.22:8000/listen.pls"; [self.activityIndicator startAnimating]; moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:url]]; [moviePlayer prepareToPlay]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil]; } } -(void) moviePlayerStatus:(NSNotification*)notification { //MPMoviePlayerController *moviePlayer = notification.object; MPMoviePlaybackState playbackState = moviePlayer.playbackState; if(playbackState == MPMoviePlaybackStateStopped) { NSLog(@"MPMoviePlaybackStateStopped"); } else if(playbackState == MPMoviePlaybackStatePlaying) { NSLog(@"MPMoviePlaybackStatePlaying"); } else if(playbackState == MPMoviePlaybackStatePaused) { NSLog(@"MPMoviePlaybackStatePaused"); } else if(playbackState == MPMoviePlaybackStateInterrupted) { NSLog(@"MPMoviePlaybackStateInterrupted"); } else if(playbackState == MPMoviePlaybackStateSeekingForward) { NSLog(@"MPMoviePlaybackStateSeekingForward"); } else if(playbackState == MPMoviePlaybackStateSeekingBackward) { NSLog(@"MPMoviePlaybackStateSeekingBackward"); } } - (void) moviePlayerLoadStateChanged:(NSNotification*)notification { if ([moviePlayer loadState] != MPMovieLoadStateUnknown) { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer]; [moviePlayer play]; [self.activityIndicator stopAnimating]; [moviePlayer setFullscreen:NO animated:NO]; } } and in appdelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *setCategoryError = nil; [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError]; if (setCategoryError) { } NSError *activationError = nil; [audioSession setActive:YES error:&activationError]; if (activationError) { } I can catch the errors but how do i use the player from appdelegate?!! thanks in advance

    Read the article

1