开发者

Playing fullscreen video on iPhone without any user controls or interaction?

开发者 https://www.devze.com 2023-03-25 12:10 出处:网络
I\'m working on an iOS game that has an intro video. How do I play the video full screen without: 1) user controls like play/pause being visible

I'm working on an iOS game that has an intro video. How do I play the video full screen without:

1) user controls like play/pause being visible

2) touches like double-tap or 开发者_开发百科pinching changing the video's scale/zoom?

To disable taps on the video, can I just add a blank UIView overtop of the movie player view? How would I do that?


What kind of movie player are you using? If you're using MPMoviePlayerViewController/MPMoviePlayerController you can set the controlStyle property to MPMovieControlStyleNone. (If you use MPMoviePlayerViewController you first call the moviePlayer property so you get the MPMoviePlayerController which has the controlStyle property)

Example:

MPMoviePlayerViewController* moviePlayerViewController = [MPMoviePlayerViewController alloc] initWithContentURL:url];
moviePlayerViewController.moviePlayer.controlStyle = MPMovieControlStyleNone;


I went with adding a "blank" view overtop the MPMoviePlayerController. This is how I set it up. Didn't have to mess with event handlers.

mBlankView = [[UIView alloc] initWithFrame:viewFrame];
mBlankView.userInteractionEnabled = YES;
[mBlankView setMultipleTouchEnabled:YES];
[mBlankView setBackgroundColor:[UIColor clearColor]];
[window addSubview:mBlankView];    

viewFrame contains the size of the MPMoviePlayerController.


MPMoviePlayerViewController *playerViewController=[[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"XYZ" ofType:@"mp4"]]];
[self presentViewController:playerViewController animated:NO completion:nil];

MPMoviePlayerController *player = [playerViewController moviePlayer];
player.controlStyle=MPMovieControlStyleNone;   //hide the controls
[player play];
0

精彩评论

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