親切にこのことについて私の完全なコードを見つけ、それは.hのクラスは、この
@property(strong,nonatomic) MPMoviePlayerViewController * moviePlayer;
.Mクラスに追加し、このコードを追加します追加私
で働いて
-(void) playMovie:(NSString *)filePath
{
NSURL *theOutputURL = [NSURL fileURLWithPath:filePath];
if(_moviePlayer)
[_moviePlayer.moviePlayer setContentURL:theOutputURL];
else
_moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:theOutputURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:_moviePlayer.moviePlayer];
if (![_moviePlayer.moviePlayer isPreparedToPlay])
[_moviePlayer.moviePlayer prepareToPlay];
_moviePlayer.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[_moviePlayer.moviePlayer setFullscreen:YES];
_moviePlayer.moviePlayer.controlStyle=MPMovieControlStyleEmbedded;
[_moviePlayer.moviePlayer setContentURL:theOutputURL];
_moviePlayer.view.frame = CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height);
[_moviePlayer shouldAutorotateToInterfaceOrientation: AVCaptureVideoOrientationLandscapeRight];
[self.view addSubview:_moviePlayer.view];
}
- (void) moviePlayerPlaybackStateDidChange: (NSNotification *) notification {
if (_moviePlayer.moviePlayer.playbackState == MPMoviePlaybackStateStopped) {
[_moviePlayer.moviePlayer setContentURL:[_moviePlayer.moviePlayer contentURL]];
[_moviePlayer.moviePlayer play];
}
}
-(void)myMovieFinishedCallback:(NSNotification*)aNotification
{
// to add your code after playback is finished
}
「映画のURLを渡します」
MPMoviePlayerPlaybackDidFinishNotificationが通知を受けていますか?ブレークポイントまたはNSLogメッセージを設定して、確実に確認することができます。 –
あなたはこのロバートの解決策を見つけましたか? – ToddH
私は覚えておくのはずっと前だと思っていますが、最終的には別のプレイヤーを使用するように変更したと思いますか? –