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];
沒有任何回調觸發。只是有一個空白的地方畫布。
查看[視頻播放];而不是[video prepareToPlay]; –
謝謝,但同樣的交易經歷了所有的代碼行,但沒有任何東西觸發任何東西 – BarryF
從viewDidLoad移動到viewDidAppear解決了這個對我來說 – BarryF