0

嗨朋友,我希望视频文件在我的应用程序中重复播放,我使用以下代码播放视频文件

NSString *tempurl = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Movie.m4v"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:tempurl]];
player.view.frame = CGRectMake(0, 0, 867, 1008);
player.scalingMode = MPMovieScalingModeFill;
[self.view addSubview:player.view];
[player play];

我可以有一个可以在视频文件播放结束时发出警报的 Delegate 方法吗 提前谢谢你

4

1 回答 1

3

您可以使用属性“repeatMode”并将其设置为 MPMovieRepeatModeOne

//Determines how the movie player repeats the playback of the movie.


@property(nonatomic) MPMovieRepeatMode repeatMode

//Discussion The default value of this property is MPMovieRepeatModeNone. 

   // For a list of available repeat modes, see “MPMovieRepeatMode.”

// Availability Available in iOS 3.2 and later.Declared In MPMoviePlayerController.h

NSString *tempurl = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Movie.m4v"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:tempurl]];

player.view.frame = CGRectMake(0, 0, 867, 1008);

player.scalingMode = MPMovieScalingModeFill;

player.repeatMode = MPMovieRepeatModeOne;

[self.view addSubview:player.view];

[player play];
于 2011-03-14T10:46:27.480 回答