我只是通过使用MPMoviePlayerController播放视频…我的代码是 -(void)playMovie:(NSURL *)url{ moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; if (IDIOM==IPAD) { [moviePlayer.view setFrame:CGRectMake(22,10
-(void)playMovie:(NSURL *)url { moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; if (IDIOM==IPAD) { [moviePlayer.view setFrame:CGRectMake(22,100, 720, 300)]; } else { (IS_IPHONE_5)? [moviePlayer.view setFrame:CGRectMake(22, 70, 280, 150)]:[moviePlayer.view setFrame:CGRectMake(22, 40, 260, 140)]; } [_scrollView addSubview:moviePlayer.view]; moviePlayer.scalingMode =MPMovieScalingModeFill; [moviePlayer prepareToPlay]; [moviePlayer play]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidEnterFullscreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:Nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidExitFullScreen:) name:MPMoviePlayerDidExitFullscreenNotification object:Nil]; } -(void)moviePlayerDidEnterFullscreen :(id)sender { NSLog(@"fullscreen"); [moviePlayer play]; moviePlayer.scalingMode =MPMovieScalingModeFill; } - (void) moviePlayerDidExitFullScreen:(id)sender { NSLog(@"exit full screen"); [moviePlayer play]; moviePlayer.scalingMode =MPMovieScalingModeFill; }
这里当我最初播放视频时将处于“MPMovieScalingModeFill”模式…但我的问题是如果我按全屏它会在全屏显示视频..当我按退出“全屏”然后我的视频模式转到“MPMovieScalingModeAspectFit “mode.but我需要始终处于”MPMovieScalingModeFill“模式.我的代码出错了.请帮帮我……
我相信这会生成MPMoviePlayerScalingModeDidChangeNotification.[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieScalingModeDidChange:) name:MPMoviePlayerScalingModeDidChangeNotification object:nil];
资料来源:Apple Doc
MPMoviePlayerScalingModeDidChangeNotification
在电影播放器的缩放模式发生变化时发布.没有userInfo字典.缩放模式可以通过编程或用户交互进行更改.要设置或检索影片播放器的缩放模式,请访问其scalingMode属性.状态已更改的电影播放器可用作与通知关联的对象.