rob*_*ino 10 video movie mpmovieplayercontroller nsnotification ios6
我可能没有把我的头衔措辞得很好,也许更正确的说我的NSNotification并没有在完成比赛后放弃我的电影观点.我发现其他人有这个问题,但没有解决方案,似乎它可能是iOS 6的问题,这就是我正在运行的.
视频完成播放后,您需要按"完成"才能解除,但我希望它能自动关闭,因为我将使用MPMovieControlStyleNone一旦我将其整理出来.这是我的代码,未使用的部分被删除:`
#import "MovieViewController.h"
@interface MovieViewController ()
@end
@implementation MovieViewController
@synthesize moviePlayer = _moviePlayer;
- (IBAction)playMovie:(id)sender
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"TestMovie" ofType:@"mov"]];
_moviePlayer =
[[MPMoviePlayerController alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
[self.view addSubview:_moviePlayer.view];
[_moviePlayer setFullscreen:YES animated:NO];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
@end`
Run Code Online (Sandbox Code Playgroud)
小智 18
有这个问题以及修复moviePlayBackDidFinish只需添加
player.fullscreen = NO;
Run Code Online (Sandbox Code Playgroud)
在从superview中删除视图之前
归档时间: |
|
查看次数: |
9232 次 |
最近记录: |