2

有人可以指出为什么这行不通吗?

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

没有任何回调触发。只要在画布所在的地方留一个空白。

4

1 回答 1

1

MPMoviePlayerController引用保存在实例变量或属性中对我有用。

于 2013-09-24T07:13:55.430 回答