は私が私の見解の背景としてビデオを再生したいと私はそのような何か作っ:無限のビデオ再生IOS
NSString *pathForFile = [[NSBundle mainBundle] pathForResource:@"clear" ofType:@"mp4"];
player = [[MPMoviePlayerController alloc] init];
player.shouldAutoplay = YES;
player.repeatMode = MPMovieRepeatModeNone;
player.fullscreen = YES;
player.movieSourceType = MPMovieSourceTypeFile;
player.scalingMode = MPMovieScalingModeAspectFill;
player.contentURL =[NSURL fileURLWithPath:pathForFile];
player.controlStyle = MPMovieControlStyleNone;
[player.view setFrame:self.view.bounds];
[player.view setUserInteractionEnabled:NO];
[player.view setAlpha:0.0f];
[self.view addSubview:player.view];
[self.view sendSubviewToBack:player.view];
[player prepareToPlay];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
- (void)moviePlayerDidFinish:(NSNotification *)note {
if (note.object == player) {
NSInteger reason = [[note.userInfo objectForKey:@"MPMoviePlayerPlaybackDidFinishReasonUserInfoKey"] integerValue];
if (reason == MPMovieFinishReasonPlaybackEnded) {
[player play];
}
}
私のメソッドが呼び出されるたびに、ビデオが終了プレーヤーは再びビデオを再生しません。私は間違って何をしていますか?
ありがとうございます。
[player seekToTime:kCMTimeZero];この行をif(reason == MPMovieFinishReasonPlaybackEnded){}の条件で使用すると、いくつかのループの後に –