将显示带有加载活动指示的黑屏当我全屏点击视频并触摸向前或向后按钮时。
我已将以下代码用于电影播放器
NSURL *fURL = [NSURL URLWithString:[self.winnersCircleDictionary objectForKey:@"videoname"]];
self.players=nil;
self.players=[[MPMoviePlayerController alloc]initWithContentURL:fURL];
[self.players setContentURL:fURL];
self.players.scalingMode = MPMovieScalingModeAspectFit;
self.players.repeatMode=MPMovieRepeatModeOne;
[[self.players view] setFrame:_webviewWinnerCircle.frame];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.players];
object:nil];
self.players.shouldAutoplay=NO;
self.players.currentPlaybackTime=0.0;
[scrollViewWinnerCircle addSubview:self.players.view];
前进和后退按钮在iOS 6中正常工作,此问题仅适用于iOS 7。 谢谢。
答案 0 :(得分:0)
我刚试过你的代码并得到了问题,并且这样解决了。
在将self.player.view作为子视图添加到MoviePlayer
之后,准备了[self.players prepareToPlay];
scrollViewWinnerCircle
来播放所选视频。
代码如下。
self.players = [[MPMoviePlayerController alloc]initWithContentURL:fURL];
[self.players setContentURL:fURL];
self.players.scalingMode = MPMovieScalingModeAspectFit;
self.players.repeatMode = MPMovieRepeatModeOne;
[[self.players view] setFrame:_containerView.frame];
self.players.shouldAutoplay = NO;
self.players.currentPlaybackTime = 0.0;
[_containerView addSubview:self.players.view];
[self.players prepareToPlay]; // Prepares a movie player for playback.
[self.players pause]; // Pause playback of the loaded movie
答案 1 :(得分:0)
这是源的问题,也没有指定源类型。 如下所示,它使用我在这里使用的网址为我工作。
NSURL *fURL = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
self.players = nil;
self.players = [[MPMoviePlayerController alloc]initWithContentURL:fURL];
[self.players setContentURL:fURL];
// Specifying media source type
self.players.movieSourceType = MPMovieSourceTypeStreaming;
最初加载需要一些时间。
答案 2 :(得分:0)
您必须使用此代码而不是MPMovieplayerController并在您的类中导入这些库: AVKit AVFoundation
NSURL * videoURL = [NSURL URLWithString:@“https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4”];
AVPlayer * player = [AVPlayer playerWithURL:videoURL];
AVPlayerViewController * playerViewController = [AVPlayerViewController new];
playerViewController.player = player;
[玩家玩];
[self presentViewController:playerViewController animated:YES completion:nil];
使用上述代码后,您就可以转发和转发视频。