开发者

i cannot see movie playing in iphone simulator

i have created a application that plays movie on button click..my application is running without any warning or error. But i am not able to see the movie don't know why? I have added the Media player framework and also imported the #import in viewController.h my butt开发者_如何学编程on action code is as follow... -(IBAction)playMyMovie:(id)sender{

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

}

Please tell me what i am missing..


in iPhone simulator you could not play movie properly.

test the applcation on iPhone (Real instrument).

It will work fine.


You are creating a MPMoviePlayerController. It has a view property - that is its view. It is your job to put that view into your interface. If you don't, you won't see anything.


try add this line before the [theMovie play]

[self.view addSubview:theMovie.view];

and also remember to setFullScreen:

[self.theMovie setFullscreen:YES];

if you dont want fullscreen but want to embed into the view, you can ignore the "setFullscreen", but set the frame for the MPMoviePlayerController view:

[self.theMovie.view setFrame:CGRectMake("add in the size you want here")];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜