Ios 如何在UIWebView中循环mp4文件

Ios 如何在UIWebView中循环mp4文件,ios,objective-c,loops,uiwebview,mp4,Ios,Objective C,Loops,Uiwebview,Mp4,我想在UIWebView中循环一个mp4文件 e、 g。 如果您转到此链接()打开UIWebView,您将无法在循环中播放它。但我想再看一遍mp4的视频 请给我一些克服困难的建议 干杯,您只需将MPMoviePlayerController与setRepeatMode:MPMovieRepeatModeOne一起使用即可 这应该允许任何视频的无缝循环,而且实现起来很简单 NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] path

我想在UIWebView中循环一个mp4文件

e、 g。 如果您转到此链接()打开UIWebView,您将无法在循环中播放它。但我想再看一遍mp4的视频

请给我一些克服困难的建议


干杯,

您只需将
MPMoviePlayerController
setRepeatMode:MPMovieRepeatModeOne
一起使用即可

这应该允许任何视频的无缝循环,而且实现起来很简单

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Your Cool Video File" ofType:@"mp4"]];
MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc]initWithContentURL:url];

[self presentMoviePlayerViewControllerAnimated:playerController];
[playerController.moviePlayer prepareToPlay];

playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
playerController.moviePlayer.controlStyle = MPMovieControlStyleNone;
playerController.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
playerController.moviePlayer.repeatMode = MPMovieRepeatModeOne;

[playerController.moviePlayer play];
重要的是要记住订阅结束播放通知,如下所示:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
  • 在moviePlayBackDidFinished方法中手动开始播放

哇,你太棒了。我会尝试你的代码。如果工作正常,我会稍后给你!无论如何,非常感谢您的评论!