BarryF
BarryF

Reputation: 77

MPMoviePlayerController not working, no Notifications either

Can someone please point out why this would NOT work?

NSURL  *url = [NSURL fileURLWithPath:ImageName];

MPMoviePlayerController *video = [[MPMoviePlayerController alloc]  initWithContentURL:url];
            NSLog(@"%@", ImageName);
            NSLog(@" %@", url);
            [canvas addSubview:video.view];
            video.view.frame = canvas.bounds; 

//  [video setControlStyle:MPMovieControlStyleEmbedded];
    [[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(myMovieCallback:)  name:MPMoviePlayerPlaybackDidFinishNotification          object:video];
    [[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(myMovieCallback:)  name:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey     object:video];
    [[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(myMovieCallback:)  name:MPMoviePlayerPlaybackStateDidChangeNotification     object:video];
    [[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(myMovieCallback:)  name:MPMoviePlayerLoadStateDidChangeNotification         object:video];
    [[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(myMovieCallback:)  name:MPMoviePlayerNowPlayingMovieDidChangeNotification   object:video];
    [video prepareToPlay];

None of the callbacks trigger. Just have a blank space where canvas is.

Upvotes: 2

Views: 696

Answers (1)

julg
julg

Reputation: 129

Keeping the MPMoviePlayerController reference in an instance variable or property worked for me.

Upvotes: 1

Related Questions