解决方案是将视频呈现为1024x 748.原因是iPad顶部显示的状态栏为20px。
我希望这可以解决他们在这种情况下遇到的许多用户问题。
在我的下一个问题上......
我目前通过MPMoviePlayerController将视频嵌入到我的视图中。此视频处于恒定循环(动画菜单)。然后我在视频顶部分层有三个隐形按钮,调用方法。我目前只有一个工作,另外两个只是显示警报。
我目前遇到的问题是,当点击按钮时,我想播放另一个视频。这是完美的工作,但我想第一个视频到第一个播放到最后播放下一个视频,原因是,我需要它也是无缝的,并不明显它从一个视频到另一个视频。
对此的任何反馈都会很棒....
#import "MainViewController.h"
#import "VideoPlayerViewController.h"
#import <MediaPlayer/MediaPlayer.h>
#import <UIKit/UIKit.h>
@interface MainViewController ()
@property (nonatomic, retain) MPMoviePlayerController *playerViewController;
@property (nonatomic, retain) VideoPlayerViewController *myPlayerViewController;
@end
@implementation MainViewController
@synthesize playerViewController = _playerViewController;
@synthesize myPlayerViewController = _myPlayerViewController;
- (void)dealloc {
self.playerViewController = nil;
self.myPlayerViewController = nil;
[super dealloc];
}
#pragma mark - View lifecycle
-(void)buttonEventOne:(id)sender {
//[[[[UIAlertView alloc] initWithTitle:@"CONTENT ONE" message:@"This will link to content one video" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show];
NSURL *urlTwo = [[NSBundle mainBundle] URLForResource:@"BAE_BG_anim_pt2_748" withExtension:@"mov"];
MPMoviePlayerController *playerViewController = [[MPMoviePlayerController alloc] init];
playerViewController.contentURL = urlTwo;
playerViewController.view.frame = CGRectMake(0, 0, 1024, 768);
playerViewController.controlStyle = MPMovieControlStyleNone;
//playerViewController.repeatMode = MPMovieRepeatModeOne;
[self.view addSubview:playerViewController.view];
[playerViewController play];
self.playerViewController = playerViewController;
[playerViewController release];
}
-(void)buttonEventTwo:(id)sender {
[[[[UIAlertView alloc] initWithTitle:@"CONTENT TWO" message:@"This will link to content one video" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show];
}
-(void)buttonEventThree:(id)sender {
[[[[UIAlertView alloc] initWithTitle:@"CONTENT THREE" message:@"This will link to content one video" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"BAE_Main_Loop_748" withExtension:@"mov"];
// video player
MPMoviePlayerController *playerViewController = [[MPMoviePlayerController alloc] init];
playerViewController.contentURL = url;
[playerViewController prepareToPlay];
playerViewController.view.frame = CGRectMake(0, 0, 1024, 768);
playerViewController.controlStyle = MPMovieControlStyleNone;
playerViewController.repeatMode = MPMovieRepeatModeOne;
[self.view addSubview:playerViewController.view];
[playerViewController play];
self.playerViewController = playerViewController;
[playerViewController release];
UIButton * btnOne = [UIButton buttonWithType:UIButtonTypeCustom];
btnOne.frame = CGRectMake(260, 350, 150, 50);
[btnOne setTitle:@"" forState:UIControlStateNormal];
[btnOne addTarget:self action:@selector(buttonEventOne:)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnOne];
UIButton * btnTwo = [UIButton buttonWithType:UIButtonTypeCustom];
btnTwo.frame = CGRectMake(620, 350, 150, 50);
[btnTwo setTitle:@"" forState:UIControlStateNormal];
[btnTwo addTarget:self action:@selector(buttonEventTwo:)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnTwo];
UIButton * btnThree = [UIButton buttonWithType:UIButtonTypeCustom];
btnThree.frame = CGRectMake(450, 250, 150, 50);
[btnThree setTitle:@"" forState:UIControlStateNormal];
[btnThree addTarget:self action:@selector(buttonEventThree:)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnThree];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
@end
答案 0 :(得分:0)
您是否尝试过注册播放通知,特别是MPMoviePlayerPlaybackDidFinishNotification
,引人注目?如果您在按下按钮时注册通知:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(introMovieFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.playerViewController];
然后在那个功能中:
- (void)introMovieFinished:(NSNotification*)note {
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.playerViewController];
// Do stuff.
}
您取消注册您对通知的兴趣,然后开始播放下一部电影。因为您只在按下按钮时注册了兴趣,所以在电影结束之前不应该接收函数调用。