2009-09-14 4 views
2

확인. 일부 새 쿼리가 있습니다.맞춤형 화면에서 동영상 재생 - iPhone에서보기


한다고 가정 사용자는 & 비디오 재생이 시작 버튼을 탭. 이제 동영상이 재생되면 항상 전체 화면 모드로 전환됩니다.

하지만 내가 필요한 것은 아래에 설명되어 있습니다.

비디오는 세로 모드에서 재생해야합니다. (일반적으로 비디오는 가로 모드로 재생됩니다).

어떻게? SO와 지식을 공유하기위한 사전에


감사합니다 ...이 미디어 플레이어에 내장

+0

: http://stackoverflow.com/questions/1347395/embedded-video-in-a-uiview-with-iphone –

+0

승인. 여기 내 요구 사항은 단지 세로 모드에서 비디오를 재생하는 것입니다. 새 수정 된 질문을 확인하십시오. –

+0

질문이 중복되었을 수 있습니다. 그러나 대답은 중복되지 않습니다. –

답변

3
@interface MPMoviePlayerController (extend) 
-(void)setOrientation:(int)orientation animated:(BOOL)value; 
@end 

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUR]; 
[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; 
if (moviePlayer) 
{ 
    [self.moviePlayer play]; 
} 

이 솔루션 은 애플에 의해 거부됩니다. 조심해야하지만 Jailbroke iPhones에서도 작동 할 수 있습니다.

1

. 새로운 것을 발견했습니다. 동영상 플레이어에 대한 setOrientation는 개인 API와 같이

@interface MPMoviePlayerController (extend) 
-(void)setOrientation:(int)orientation animated:(BOOL)value; 
@end 

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUR]; 
[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; 
if (moviePlayer) 
{ 
    [self.moviePlayer play]; 
} 
+0

맞춤형 미디어 플레이어를 만들 수 있습니까? –

+0

확인. 여기 내 요구 사항은 단지 세로 모드에서 비디오를 재생하는 것입니다. 새 수정 된 질문을 확인하십시오. –

+0

iPhone SDK 3.2 이상 버전에서 제공되는 새로운 MPMoviePlayerController를 사용해보십시오. UI를 사용자 정의하고 필요한 크기를 설정하며 방향을 변경할 수 있습니다. – RVN

1

이 밖으로 시도 사용 가능하다고 생각하지 않는 문서화 된 문서에서

6

최신 iPhone SDK 3.2 이상에서는 이제 프로그래머가 원하는 크기로 비디오를 표시 할 수 있으며 오리엔테이션은 MPMoviePlayerController의 속성 인 새로운 MPMoviePlayerView가 제공됩니다.이보기에는 u는 하위보기로보기에 추가 할 수 있습니다.

희망이 도움이됩니다.

감사합니다.

1

다음은 내가 한 일입니다. 비디오 미리로드가 완료되면 알려주는 NSNotification을 추가하십시오.

- (void)playVideoUrl:(NSString *)videoUrl { 
    NSURL *url = [NSURL URLWithString:videoUrl]; 
    MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] 
      initWithContentURL:url]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 

    //MPMoviePlayerContentPreloadDidFinishNotification 
    [[NSNotificationCenter defaultCenter] addObserver:self       
         selector:@selector(myMovieFinishedPreloading:)            
          name:MPMoviePlayerContentPreloadDidFinishNotification             
         object:theMovie]; 


    // Movie playback is asynchronous, so this method returns immediately. 
    [theMovie play]; 
    } 

콜백의 선택이이 질문의 중복

-(void)myMovieFinishedPreloading:(NSNotification*)aNotification { 
    NSArray *windows = [[UIApplication sharedApplication] windows]; 

    UIWindow *moviePlayerWindow = nil; 
    if ([windows count] > 1) 
    { 
     moviePlayerWindow = [[UIApplication sharedApplication] keyWindow]; 
    } 

    CGAffineTransform transform = CGAffineTransformMakeScale(0.5, 0.5); 
    transform = CGAffineTransformRotate(transform, -90.0f*M_PI/180.0f); 
    [moviePlayerWindow setTransform:transform]; 

} 
관련 문제