1

プロジェクト ディレクトリからビデオをロードするためにこれを試みています。

NSURL *myURL =[[NSBundle mainBundle] URLForResource:@"US_Very_High_Dive_Boudia_US_44_x264"   
withExtension:@"mp4"];

MPMoviePlayerController *player =
[[MPMoviePlayerController alloc] initWithContentURL: myURL];

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


[player prepareToPlay];
[player shouldAutoplay];
[player allowsAirPlay];
[self.view addSubview:player.view];
[player setFullscreen:YES animated:YES];

player.controlStyle=MPMovieControlStyleEmbedded;
4

2 に答える 2

2

このコードを試してください

.hファイルに以下を追加します

@property (nonatomic, strong) MPMoviePlayerController *controller;

.mファイル内

 -(IBAction)playMovie:(id)sender

           {
                NSString *filepath = [[NSBundle mainBundle] pathForResource:@"buyTutorial" ofType:@"mov"];
                NSURL *fileURL = [NSURL fileURLWithPath:filepath];
                MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
                [self.view addSubview:moviePlayerController.view];
                moviePlayerController.fullscreen = YES;
            [moviePlayerController prepareToPlay];
                [moviePlayerController play];
        [self setController:moviePlayerController];
            }
于 2013-02-21T07:28:11.063 に答える
0

URL を正しく設定していないようです - これを試してください:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"filename" ofType:@"mp4"]];
于 2013-02-21T07:32:07.517 に答える