MPMoviePlayerController无法正常工作,也没有通知

时间:2012-06-20 18:15:49

标签: iphone ios5 video mpmovieplayercontroller

有人可以指出为什么这不起作用吗?

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];

没有回调触发。只需要一个画布所在的空白区域。

1 个答案:

答案 0 :(得分:1)

保持实例变量或属性中的MPMoviePlayerController引用对我有效。