iphone – 默认以全屏播放视频

iphone – 默认以全屏播放视频,第1张

概述我正在使用MPMoviePlayerController播放视频: NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"myvideo.MOV" ofType:nil];NSURL *url = [NSURL fileURLWithPath:urlStr];moviePlayer = [[MPMoviePlayerContro 我正在使用MPMovIEPlayerController播放视频:

Nsstring *urlStr = [[NSBundle mainBundle] pathForResource:@"myvIDeo.MOV" ofType:nil];NSURL *url = [NSURL fileURLWithPath:urlStr];movIEPlayer = [[MPMovIEPlayerController alloc] initWithContentURL:url];[self.vIEw addSubvIEw:movIEPlayer.vIEw];movIEPlayer.vIEw.frame = CGRectMake(0,1024,675);  [movIEPlayer play];

但要求是默认情况下视频应全屏显示,当我最小化时,视频应在帧大小以上.

请帮帮我.

解决方法 尝试这个.

#define degreesToRadian(x) (M_PI * (x) / 180.0)-(voID)playMovIEAtURL:(NSURL*)movIEURL{    if ([NSClassFromString(@"MPMovIEPlayerController") instancesRespondToSelector:@selector(vIEw)])    { #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200        // running iOS 3.2 or better        mVIEwPlayer = [[MPMovIEPlayerVIEwController alloc] initWithContentURL:movIEURL];        mVIEwPlayer.modalTransitionStyle = UIModalTransitionStyleCrossdissolve;        CGRect newFrame = CGRectMake(0,self.vIEw.frame.size.wIDth,self.vIEw.frame.size.height);        mVIEwPlayer.vIEw.frame = newFrame;        CGAffinetransform landscapetransform;        landscapetransform = CGAffinetransformMakeRotation(degreesToRadian(90));        landscapetransform = CGAffinetransformTranslate(landscapetransform,80,80);        [mVIEwPlayer.vIEw settransform: landscapetransform];        [self.vIEw addSubvIEw:mVIEwPlayer.vIEw];        [mVIEwPlayer.movIEPlayer play];        [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(movIEDIDExitFullscreen:)                                                                                  name:MPMovIEPlayerPlaybackDIDFinishNotification                                                                                  object:[mVIEwPlayer movIEPlayer]];#endif    }    else     {        MPMovIEPlayerController *mMPPlayer = [[MPMovIEPlayerController alloc] initWithContentURL:movIEURL];        mMPPlayer.scalingMode=MPMovIEScalingModeFill;        mMPPlayer.backgroundcolor=[UIcolor blackcolor];        [mMPPlayer play];        [[NSNotificationCenter defaultCenter] addobserver:self                                                  selector:@selector(movIEPlayerDIDFinish:)                                                                    name:MPMovIEPlayerPlaybackDIDFinishNotification                                                                    object:mMPPlayer];    }}/*--------------------------------------------------------------------------- *  *--------------------------------------------------------------------------*/- (voID) movIEDIDExitFullscreen:(NSNotification*)notification {        //[[UIApplication sharedApplication] setStatusbarHIDden:YES];    /*/ Remove observer    [[NSNotificationCenter  defaultCenter]      removeObserver:self     name:MPMovIEPlayerPlaybackDIDFinishNotification      object:nil];    [self dismissModalVIEwControllerAnimated:YES];*/    [[NSNotificationCenter defaultCenter] removeObserver: self                                                    name:MPMovIEPlayerPlaybackDIDFinishNotification                                                  object: [notification object]];    MPMovIEPlayerController *theMovIE1 = [notification object];    [theMovIE1.vIEw removeFromSupervIEw];    [theMovIE1 release];}- (voID) movIEPlayBackDIDFinish:(NSNotification*)notification {        //[[UIApplication sharedApplication] setStatusbarHIDden:YES];    /*/ Remove observer    [[NSNotificationCenter  defaultCenter]      removeObserver:self     name:MPMovIEPlayerPlaybackDIDFinishNotification      object:nil];    [self dismissModalVIEwControllerAnimated:YES];*/    [[NSNotificationCenter defaultCenter] removeObserver: self                                                    name:MPMovIEPlayerPlaybackDIDFinishNotification                                                  object: [notification object]];    MPMovIEPlayerController *theMovIE1 = [notification object];    [theMovIE1.vIEw removeFromSupervIEw];    [theMovIE1 release];}
总结

以上是内存溢出为你收集整理的iphone – 默认以全屏播放视频全部内容,希望文章能够帮你解决iphone – 默认以全屏播放视频所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1085871.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存