사용자 정의 크기 화면에서 비디오 재생 - iPhone에서보기
-
07-07-2019 - |
문제
버튼의 사용자 탭과 비디오가 재생되기 시작한다고 가정 해 봅시다. 이제 비디오가 재생되면 항상 전체 화면 모드입니다.
비디오는 초상화 모드로 재생되어야합니다 (일반적으로 비디오는 조경 모드에서 재생됩니다). 어떻게 할 수 있습니까?
해결책
@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];
}
이 솔루션은 영화 플레이어의 세상이 개인 API이므로 Apple에 의해 거부됩니다. 조심해야하지만 Jailbroke iPhone에서 작동 할 수 있습니다.
다른 팁
최신 iPhone SDK 3.2+는 이제 프로그래머가 원하는 크기와 방향으로 비디오를 표시 할 수있게 해줄 새로운 MPMoviePlayerview가 제공되며 MPMoviePlayerController의 속성 인이보기에는 비디오가 있습니다. 당신의 견해에 대한 서브 뷰.
문서화 된 문서에서 나는 이것이 내장 미디어 플레이어를 사용하여 불가능하다고 생각하지 않습니다.
이것을 시도하십시오. 나는 새로운 것을 발견했다.
@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];
}
여기 내가 한 일이 있습니다. 비디오가 미리로드 될 때 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];
}
제휴하지 않습니다 StackOverflow