2012-06-20 51 views
2

有人可以指出爲什麼這不起作用嗎?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]; 

沒有任何回調觸發。只是有一個空白的地方畫布。

+0

查看[視頻播放];而不是[video prepareToPlay]; –

+0

謝謝,但同樣的交易經歷了所有的代碼行,但沒有任何東西觸發任何東西 – BarryF

+0

從viewDidLoad移動到viewDidAppear解決了這個對我來說 – BarryF

回答

1

保留MPMoviePlayerController引用的實例變量或屬性爲我工作。

相關問題