我只是使用的MPMoviePlayerController播放視頻......我的代碼是的MPMoviePlayerController縮放模式問題
-(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」模式。whats錯誤與我的代碼..請幫助我...
你不應該在全屏通知內觸發'play'。 – Till
但它停止播放,所以我在全屏幕通知中再次呼叫該遊戲 – jafar
這完全沒有意義。從屏幕切換到全屏時,不應停止播放。你的代碼中必須有一些東西,你沒有告訴我們停止播放。我的猜測是,在「viewWill/DidAppear」/「viewWill/DidDisappear」中會出現一些內容 - 當全屏模式完全隱藏viewController的視圖時,會在離開或進入全屏時觸發這些外觀通知。 – Till