1

我需要在应用程序启动时播放视频

我的代码非常适合 Iphone Ipad Simulator

但物理上不在设备上的 Ipad

怎么了??

- (void)viewDidLoad
    {

         if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {

            NSURL* url = [[NSBundle mainBundle] URLForResource:@"Intro3" withExtension:@"mp4"];

            m_player = [[MPMoviePlayerController alloc] initWithContentURL:url];
            [m_player.backgroundView setBackgroundColor:[UIColor blackColor]];
            [m_player.view setBackgroundColor:[UIColor blackColor]];
            [m_player setControlStyle:MPMovieControlStyleNone];
            [[m_player view] setFrame:[self.view bounds]];

            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
            [m_player play];
            [self.view addSubview:[m_player view]];

            }
            else{
               ---play video in iphone---
            }

    }
4

2 回答 2

2

该代码完美运行!

问题是视频的分辨率太大了。

调整大小并工作 =)

于 2012-11-11T19:47:33.650 回答
0

我建议您改用MPMoviePlayerViewController

 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {

            NSURL* url = [[NSBundle mainBundle] URLForResource:@"Intro3" withExtension:@"mp4"];

            MPMoviePlayerViewController * controller = [[MPMoviePlayerViewController alloc]initWithContentURL:url];
            [self  presentMoviePlayerViewControllerAnimated:controller];
            [controller release];
}
于 2012-11-11T19:05:32.727 回答