MPMoviePlayerPlaybackDidFinishNotification not working on UITabBar tap

Discussion in 'iPad Development' started by julianb, Dec 29, 2010.

  1. julianb

    julianb iPF Noob

    Joined:
    Dec 29, 2010
    Messages:
    1
    Thanks Received:
    0
    Trophy Points:
    0
    Ratings:
    +0 / 0
    Hi

    Noobie I'm afraid (but with some programming experience). I have a UITabBar where one of the the views (view 4) plays a video.

    I create a listener:

    -(void)viewDidLoad {
    NSString *path = [[NSBundle mainBundle] pathForResource:mad:"Sample" ofType:mad:"mp4"];
    movieURL = [NSURL fileURLWithPathath];

    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

    moviePlayer.controlStyle = MPMovieControlStyleDefault;

    [[NSNotificationCenter defaultCenter]
    addObserver:self
    selector:mad:selector(moviePlayBackDidFinish
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:moviePlayer];

    [moviePlayer.view setFrame:CGRectMake(0, 0, 1024 , 739)];
    moviePlayer.view.backgroundColor = [UIColor grayColor];
    [self.view addSubview:moviePlayer.view];
    [moviePlayer prepareToPlay];
    [moviePlayer play];
    }

    Here's the function:


    - (void) moviePlayBackDidFinishNSNotification*)notification
    {
    [[NSNotificationCenter defaultCenter]
    removeObserver:self
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:moviePlayer];

    moviePlayer.initialPlaybackTime = -1;
    [moviePlayer stop];
    [movieURL release];
    [moviePlayer autorelease];
    }

    If I press another view UITabBar item the video continues playing in the background (as in I can hear the audio still). I f I return to the video view the app crashes.

    How do I get the other UITabBar items to stop remove the MPMoviePlayerController instance if it's active?

    TIA
    JB
     

Share This Page

Search tags for this page
hide player mpmovieplayerplaybackdidfinishnotification
,

mpmovieplayerplaybackdidfinishnotification

,
mpmovieplayerplaybackdidfinishnotification example
,
mpmovieplayerplaybackdidfinishnotification ipad
,
mpmovieplayerplaybackdidfinishnotification not called