2012-05-11 13 views
0

`ios5のXcodeプログラミングでmp4ビデオを実行するためのコードを開発する際に問題が発生しています。 私は注目にアプリケーションを実行clip2.mp4ファイルは私のbundle.pleaseであるもののビデオプレーヤーがXcode 4.2で動作していません

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

    NSString *url = [[NSBundle mainBundle] 
       pathForResource:@"clip2" 
       ofType:@"mp4"]; 
player =[[MPMoviePlayerController alloc] 
    initWithContentURL:[NSURL fileURLWithPath:url]]; 
    [player prepareToPlay]; 
    [player play];  


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

    //---play movie--- 

} 

    - (void) movieFinishedCallback:(NSNotification*) aNotification { 
    MPMoviePlayerController *play= [aNotification object]; 
    [[NSNotificationCenter defaultCenter] 
    removeObserver:self 
    name:MPMoviePlayerPlaybackDidFinishNotification 
    object:play];  
//[player autorelease];  
    } ` 

答えて

0

くれ 適切な解決策を与えることが

player = [[MPMoviePlayerController alloc] initWithContentURL:url]; 

urlする必要があります表示されることはすでにNSURLです。 -fileURLWithPath:は、ファイルパスを含むNSStringからNSURLを作成するために使用される(すなわち/path/to/file)がなく、通常のURLよりも(すなわち、http://stackoverflow.com/

関連する問題