2014-09-06 1 views
-1

나는 내 자신의 프로젝트를 생성하고 자신의 예에서와 같이 정확히 같은 코드를 작성 (하지만 내 프로젝트에 나는 스토리 보드를 사용)MPMoviePlayerController 블랙 loginview

https://github.com/arturfelipet/AnimatedLogin 라이브러리를 사용하기 위해 노력하고있어에서 화면하지만 비디오 만 검은 색 화면을 보여줍니다. 여기가 MPMoviePlayerController 만드는 방법 :

#import <AVFoundation/AVFoundation.h> 
#import <MediaPlayer/MediaPlayer.h> 
#import <QuartzCore/QuartzCore.h> 

@interface ViewController() { 
    MPMoviePlayerController *player; 
} 

@property (nonatomic, strong) MPMoviePlayerController *player; 

@end 

@implementation ViewController 
@synthesize player; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    CGRect screen = [[UIScreen mainScreen] bounds]; 

    NSURL *movieUrl = [[NSBundle mainBundle] URLForResource:@"background" withExtension:@"mp4"]; 

    self.player = [[MPMoviePlayerController alloc] initWithContentURL:movieUrl]; 

    player.view.frame = screen; 
    player.scalingMode = MPMovieScalingModeFill; 
    [self.player setControlStyle:MPMovieControlStyleNone]; 
    [self.view addSubview:player.view]; 
    [player prepareToPlay]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(playVideo) 
               name:MPMoviePlayerReadyForDisplayDidChangeNotification 
               object:player]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePlayerDidFinish:) 
               name:MPMoviePlayerPlaybackDidFinishNotification 
               object:self.player]; 

    [player play]; 
} 

- (void)moviePlayerDidFinish:(NSNotification *)note 
{ 
    if (note.object == self.player) { 
     NSInteger reason = [[note.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] integerValue]; 
     if (reason == MPMovieFinishReasonPlaybackEnded) 
     { 
      [self.player play]; 
     } 
    } 
} 

-(void)playVideo{ 
    [player play]; 
} 

@end 

는 그러나 응용 프로그램이 나타 경우에만 검은 화면입니다.

if (![PFUser currentUser]) 
     self.window.rootViewController = [UIStoryboard instansiateVCWithClass:[TPLoginViewController class]]; 

는 어쩌면 그와 함께 뭔가를 가지고 :이 같은 앱 위임에서 제시 내 LoginViewController이 코드를 사용하고 있습니다? 나는 많은 것을 시도했고 정말로 대답을 감사 할 것입니다.

감사합니다.

답변

1

귀하가 viewDidLoad에서 초기화를 모두하고 있기 때문입니다. 즉, 모든 작업이 완전히 완료 될 때까지 처리가 화면을 차단합니다.

방법에 그 코드를 넣어 사용하여 지연 후 전화 : 편집

[self performSelector:<#(SEL)#> withObject:<#(id)#> afterDelay:<#(NSTimeInterval)#>]; 

:으로는 @tracifycray에 확인 후 밝혀졌다, URL 몇 가지 문제가 있었다, 그것은 어떻게 든 전무을 선회했다 . 그가 말했듯이 "예, 작동하도록했습니다. 대신 .mov 파일을 사용하려고 시도하고 작동했습니다."

+0

그래서 함수에 넣으려고했습니다. - (void) moviePlay, 그리고 viewDidLoad에서 시도했습니다 : [self performSelector : @selector (moviePlay) withObject : self afterDelay : 2]; 하지만 2 초 동안 흰색 화면을 보여준 다음 검은 색 화면 만 보여줍니다. @ rptwsthi – tracifycray

+0

아이디어가 있으십니까? @rptwsthi – tracifycray

+0

귀하의 코드를 확인하고 있습니다. 문제를 파악할 수 있습니다 .. – rptwsthi