Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 使用MPMoviePlayerController在ipad上安装1024x768_Objective C_Xcode_Mpmovieplayercontroller - Fatal编程技术网

Objective c 使用MPMoviePlayerController在ipad上安装1024x768

Objective c 使用MPMoviePlayerController在ipad上安装1024x768,objective-c,xcode,mpmovieplayercontroller,Objective C,Xcode,Mpmovieplayercontroller,在花了一整天的时间研究为什么1024x768视频不能在iPad3上运行,以及大量的论坛搜索之后。我找不到任何合理的办法来解决这个问题。似乎很多人都有同样的情况,只显示一个黑屏 解决方案是按照1024x 748的要求渲染视频。原因是iPad顶部显示的状态栏是20px 我希望这能解决很多用户在这种情况下遇到的问题 关于我的下一个问题…… #import "MainViewController.h" #import "VideoPlayerViewController.h" #import <M

在花了一整天的时间研究为什么1024x768视频不能在iPad3上运行,以及大量的论坛搜索之后。我找不到任何合理的办法来解决这个问题。似乎很多人都有同样的情况,只显示一个黑屏

解决方案是按照1024x 748的要求渲染视频。原因是iPad顶部显示的状态栏是20px

我希望这能解决很多用户在这种情况下遇到的问题

关于我的下一个问题……

#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
我目前有一个视频通过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
#导入“MainViewController.h”
#导入“VideoPlayerViewController.h”
#进口
#进口
@接口MainViewController()
@属性(非原子,保留)MPMoviePlayerController*playerViewController;
@属性(非原子,保留)VideoPlayerViewController*myPlayerViewController;
@结束
@实现主视图控制器
@合成playervewcontroller=\u playervewcontroller;
@合成myPlayerViewController=\u myPlayerViewController;
-(无效)解除锁定{
self.playervewcontroller=nil;
self.myplayervewcontroller=nil;
[super dealoc];
}
#pragma标记-视图生命周期
-(无效)按钮提示:(id)发件人{
//[[[UIAlertView alloc]initWithTitle:@“内容一”消息:@“此链接将链接到内容一视频”代理:无取消按钮:@“确定”其他按钮:无自动删除]显示];
NSURL*URLTOW=[[NSBundle mainBundle]URLForResource:@“BAE_BG_anim_pt2_748”,扩展名为:@“mov”];
MPMoviePlayerController*playervcontroller=[[MPMoviePlayerController alloc]init];
playervewcontroller.contentURL=urlTwo;
playervewcontroller.view.frame=CGRectMake(0,0,1024,768);
playerViewController.controlStyle=MPMovieControlStyleNone;
//playerViewController.repeatMode=MPMovierPeatModeOne;
[self.view addSubview:playervewcontroller.view];
[playerViewController播放];
self.playervewcontroller=playervewcontroller;
[播放服务控制器释放];
}
-(无效)按钮二:(id)发送者{
[[[UIAlertView alloc]initWithTitle:@“内容二”消息:@“这将链接到内容一视频”委托:无取消按钮:@“确定”其他按钮:无自动删除]显示];
}
-(无效)按钮三:(id)发送者{
[[[UIAlertView alloc]initWithTitle:@“内容三”消息:@“这将链接到内容一视频”代理:无取消按钮:@“确定”其他按钮:无自动删除]显示];
}
-(无效)viewDidLoad{
[超级视图下载];
NSURL*url=[[NSBundle mainBundle]URLForResource:@“BAE_Main_Loop_748”,扩展名:@“mov”];
//视频播放器
MPMoviePlayerController*playervcontroller=[[MPMoviePlayerController alloc]init];
playerViewController.contentURL=url;
[播放服务控制器准备播放];
playervewcontroller.view.frame=CGRectMake(0,0,1024,768);
playerViewController.controlStyle=MPMovieControlStyleNone;
playerViewController.repeatMode=MPMovierPeatModeOne;
[self.view addSubview:playervewcontroller.view];
[playerViewController播放];
self.playervewcontroller=playervewcontroller;
[播放服务控制器释放];
UIButton*btnOne=[UIButton按钮类型:UIButtonTypeCustom];
btnOne.frame=CGRectMake(260、350、150、50);
[BTONE setTitle:@”用于状态:UIControlStateNormal];
[btnOne addTarget:self action:@selector(buttonEventOne:)for controlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnOne];
UIButton*btnTwo=[UIButton按钮类型:UIButtonTypeCustom];
btnTwo.frame=CGRectMake(62035015050);
[btnTwo setTitle:@“for状态:uicontrol状态正常];
[btnTwo addTarget:self action:@selector(buttonEventTwo:)for controlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnTwo];
UIButton*btnThree=[UIButton按钮类型:UIButtonTypeCustom];
btnThree.frame=CGRectMake(45025015050);
[btnThree setTitle:@“for状态:UIControlStateNormal];
[btnThree addTarget:self action:@selector(buttonEventThree:)for ControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnThree];
}
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation{
返回(interfaceOrientation==UIInterfaceOrientationAndscapeLeft | |
interfaceOrientation==UIInterfaceOrientationAndscapeRight);
} 
@结束

您是否尝试注册播放通知,特别是
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.
}

您取消注册对通知的兴趣,然后开始播放下一部电影。因为您只在按下按钮时才注册兴趣,所以在电影结束之前,您不应该收到函数调用。

您可能希望通过单击解决您问题的答案上的“勾号”提纲来接受人们对您以前的问题给出的部分答案。啊,太棒了,我不知道您可以这么做!这个地方很棒,似乎很多人都愿意帮助或伸出援手,我希望我所遇到的问题已经解决了很多人的问题。我刚刚考虑过这个问题,我可以为我们设定一个布尔变量吗