2

私はcocos2dを使用しています。私は映画を再生したいです。MPMoviePlayerControllerは仕事したくない

私はCCLayerサブクラスを作成しましたし、それがこのようなinit方法です再実装:

-(id) init 
{ 
    self = [super init]; 
    if (self) 
    { 
     NSURL *url = [NSURL fileURLWithPath:@"common/test-movie.mp4"]; 
     MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url]; 
     [[[CCDirector sharedDirector] openGLView] addSubview:[player view]]; 
     [player play]; 
    } 
    return self; 
} 

私はシーンに[[CCDirector sharedDirector] runWithScene:scene];を実行しただけで、この層が含まれています。しかし、何も:(ただ、黒い画面が表示されません

EDIT

はまた、それは常にすべての映画のための0時間を返し、私もiPhoneのカメラからビデオを再生しようとした - 。。同じ結果を

答えて

3

問題はNSURLにあった - 私は右ではない方法でそれを作成しました。ここの右のコードは次のとおりです。?

NSString *rootPath = [[NSBundle mainBundle] resourcePath]; 
NSString *filePath = [rootPath stringByAppendingPathComponent:@"test-movie.mp4"]; 
NSURL *url = [NSURL fileURLWithPath:filePath isDirectory:NO]; 
1

は、ビューの枠を設定してみてくださいでした

id parentView = [[CCDirector sharedDirector] openGLView]; 
[parentView addSubview:[player view]]; 
[[player view] setFrame:[parentView bounds]]; 
+0

は役に立ちませんでした。プレイヤーのコントロールは表示されません – Andrew

関連する問題