开发者

Custom UIView to display video

Hey All, Im working on an app for the iPad and Ive run across an issue that I need some guidance on. I have an app that uses the TabBarController. The TabBarController contains 4 UIViewController...one for each screen in the app. On each of these 4 screens, there are 4 tiles that need to act as buttons and play a video when clicked. I would like to play the video in a view that hovers over the rest of the screen and is dismissed if the user touches anywhere outside the playing video.

My question is: How do I go about implementing the custom view to play the video? It seems to me that it 开发者_StackOverflowshould be just another view with a viewController...but I dont know if that is the correct way to go about this. Also, how do I get it to play the right video depending on what button was clicked? Any advice is greatly appreciated. Thanks Alex


I'm not sure if I entirely get what the question is, if my answer is not enough please be more precise.

first you initialize your video player view controller class MPMoviePlayerController, then you can do whatever you want with it's .view property, or the container view to display your 4 buttons.

NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"someMovie" ofType:@"m4v"];

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
player.view.frame = CGRectMake(someX, someY, someWidth, someHeight);

[self.view addSubview:player.view];
[player play];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜