0

UIButton이있는보기에서 재생할 비디오로 응용 프로그램을 만들려고합니다. 참고 :이 코드 MPMoviePlayerView 다른보기 안에 있으므로 탭 표시 컨트롤러와 함께 스토리 보드를 사용하고 있습니다. 때문에 캐치되지 않는 예외 'NSInvalidArgumentException', 이유에 * 응용 프로그램을 종료 :MPMoviePlayer가 응용 프로그램에서 작동하지 않습니다.

나는이 오류가 계속은 '* - [NSURL initFileURLWithPath는 :] : 무기 호 문자열 매개 변수'

다음

내 코드입니다

VideoTefViewController.h

#import <UIKit/UIKit.h> 

@interface VideoTefViewController : UIViewController 


-(IBAction)playMovie; 
@end 

VideoTefViewController.m

#import "VideoTefViewController.h" 
#import <MediaPlayer/MediaPlayer.h> 
@interface VideoTefViewController() 

@end 

@implementation VideoTefViewController 

-(IBAction)playMovie { 

    NSBundle *bundle = [NSBundle mainBundle]; 
    NSString *moviePath = [bundle pathForResource:@"tef" ofType:@"mp4"]; 
    NSURL *movieURL = [NSURL fileURLWithPath:moviePath]; 
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
    theMovie.scalingMode = MPMovieScalingModeAspectFill; 
    [theMovie play]; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 

} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

@end 

답변

0

fileURLWithPath :에 대한 인수가 nil이므로 오류가 발생하여 어떤 이유로 moviePath가 nil입니다. 번들에 tef.mp4라는 파일이 있습니까?

+0

저는 프로젝트에 tef.mp4라는 파일이 있습니다. xcode의 내 Supporting Files/Resources Files 폴더에 있습니다. 다른 곳에 넣어야합니까? – jakife

+0

@YuvalMarcus, moviePath를 생성 한 행 바로 다음에 로깅을 시도하고 nil인지 확인하십시오. – rdelmar

+0

그래서 써야합니까 : NSlog 무엇? – jakife