2

假设用户点击一个按钮并且视频开始播放。现在,当视频播放时,它始终处于全屏模式。

视频应以纵向模式播放(但通常视频以横向模式播放)。我怎样才能做到这一点?

4

5 回答 5

6

只是一个更新,最新的 iPhone SDK 3.2+ 现在允许程序员以任何所需的大小和方向显示视频,提供了新的 MPMoviePlayerView,它是 MPMoviePlayerController 的一个属性,这个视图将包含视频,您可以将其添加为您的视图的子视图。

于 2010-04-10T12:51:33.030 回答
3
@interface MPMoviePlayerController (extend) 
 -(void)setOrientation:(int)orientation animated:(BOOL)value; 
@end 

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUR]; 
[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; 
if (moviePlayer) 
{ 
    [self.moviePlayer play]; 
} 

此解决方案将被 Apple 拒绝,因为电影播放器​​的 setOrientation 是私有 API。您需要小心,但它可能适用于越狱 iPhone。

于 2010-03-13T08:54:54.107 回答
1

从记录的文档中,我认为使用内置媒体播放器是不可能的

于 2009-09-14T17:57:12.110 回答
1

试试这个。我发现了一些新东西。

@interface MPMoviePlayerController (extend)
-(void)setOrientation:(int)orientation animated:(BOOL)value;
@end

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUR];
[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO];
if (moviePlayer)
{
    [self.moviePlayer play];
}
于 2009-09-14T22:44:51.093 回答
1

这就是我所做的。添加 NSNotification 以在视频预加载完成时通知您。

- (void)playVideoUrl:(NSString *)videoUrl {
    NSURL *url = [NSURL URLWithString:videoUrl];
    MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc]   
             initWithContentURL:url]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 

    //MPMoviePlayerContentPreloadDidFinishNotification
    [[NSNotificationCenter defaultCenter] addObserver:self                           
                       selector:@selector(myMovieFinishedPreloading:)                                            
                           name:MPMoviePlayerContentPreloadDidFinishNotification                                                
                         object:theMovie]; 


    // Movie playback is asynchronous, so this method returns immediately. 
    [theMovie play]; 
     }

回调选择器:

-(void)myMovieFinishedPreloading:(NSNotification*)aNotification  {
    NSArray *windows = [[UIApplication sharedApplication] windows];

    UIWindow *moviePlayerWindow = nil;
    if ([windows count] > 1) 
    {
        moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
    }

    CGAffineTransform transform = CGAffineTransformMakeScale(0.5, 0.5);
    transform = CGAffineTransformRotate(transform, -90.0f*M_PI/180.0f);
    [moviePlayerWindow setTransform:transform];

 }
于 2010-06-22T11:37:05.923 回答