- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 iPad 应用程序中,我有一个 UIButton,它调用 IBAction 来调用 View Controller 作为模态来显示视频。我希望模态显示为 720x405,这部分看起来没问题。这是按钮正在执行的 IBAction 代码:
-(IBAction)videoPlayerTest:(id)sender {
VideoModalViewController *vc = [[VideoModalViewController alloc] initWithNibName: @"VideoModalViewController" bundle: nil];
vc.fileName = @"testvideo.m4v";
vc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:vc animated: YES];
vc.view.superview.frame = CGRectMake(0, 0, 720, 405);
vc.view.superview.center = self.view.center;
[vc release];
}
模式出现在我想要的地方,控件在 MPMoviePlayerController 上响应;慢跑栏、暂停、播放等,但如果用户点击全屏按钮,视频确实可以全屏显示,但之后 MPMoviePlayerController 将不会响应播放器控件上的任何后续点击。如果我删除 modalPresentationStyle 行它会工作,但模式出现在全屏 View 而不是我想要的 720x405 模式。我已经添加了 Observers 来尝试调整框架大小并在用户使电影 Controller 全屏并返回窗口时重新居中,但它似乎根本没有帮助。这是代码。
- (void)willEnterFullscreen:(NSNotification*)notification {
NSLog(@"willEnterFullscreen");
[self setModalPresentationStyle:UIModalPresentationFullScreen];
self.view.frame = CGRectMake(0, 0, 1024, 768);
self.view.center = self.view.center;
}
- (void)willExitFullscreen:(NSNotification*)notification {
NSLog(@"willExitFullscreen");
[self setModalPresentationStyle:UIModalPresentationFormSheet];
self.view.frame = CGRectMake(0, 0, 720, 405);
self.view.center = self.view.center;
}
- (void)playMovie {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullscreen:) name:MPMoviePlayerWillExitFullscreenNotification object:nil];
NSString *videoString = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:fileName];
NSURL *videoURL = [NSURL fileURLWithPath:videoString];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[self.view addSubview:moviePlayer.view];
moviePlayer.view.frame = CGRectMake(0, 0, 720, 405);
moviePlayer.view.backgroundColor = [UIColor grayColor];
[moviePlayer prepareToPlay];
[moviePlayer play];
}
这是我的第一篇文章——希望我做对了,并提供了有关我遇到的问题的足够信息。
最佳答案
我已经解决了我的问题。我不知道 MPMoviePlayerViewController,我创建了它并将其用作我的模态。效果很好。
-(void)playVideo:(NSString *)fileName {
NSString *videoString = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:fileName];
NSURL *videoURL = [NSURL fileURLWithPath:videoString];
mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
[self presentModalViewController:mpViewController animated:NO];
[[mpViewController moviePlayer] play];
}
-(IBAction)videoPlayerTest:(id)sender {
[self playVideo:@"testvideo.m4v"];
}
我想我会发布我的想法,以防其他人遇到同样的情况
关于objective-c - MPMoviePlayerController 控件在 UIModalPresentationFormSheet 样式模式中打开并且用户使视频全屏时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7740436/
我有这个 MPMovePlayerController 和一个自定义 slider (它不是一个 slider ,但它具有相同的目的)。考虑到我的“ slider ”可以返回我需要的任何浮点值,我怎样
我正在使用 m3u8 视频格式来流式传输视频,现在我需要显示相同的字幕。 我在 Apple 文档中搜索,发现我可以通过使用 closedCaptionDisplayEnabled 来实现这一点。 AV
我正在使用 MPMoviePlayerController 在我的应用程序中播放一个视频。下面是我播放视频的代码。 **NSURL *url=[[NSURL alloc] initFileUR
请检查以下代码: (void) moviePlayerDidExitFullscreen:(NSNotification*)notification { MPMoviePlayerControlle
为了在我的应用中播放视频,我设置了 MPMoviePlayerController并将其添加到 subview 。用户可以使用捏合手势更改为全屏模式。 在此 viewController (包含电影播
有没有捕捉异常的方法(特别是对于网络错误 /没有可用连接)当使用 MPMoviePlayerController 时? 我特别担心一旦播放器的实例被初始化为 initWithURL:您无法知道电影加载
这真让我抓狂。 很简单,我有一个 MPMoviePlayerViewController 并且想要全屏显示电影。 在 iOS 5.0+ 上使用 ARC 我想让这个播放器应用程序范围内可重用。 这部电影
MPMoviePlayerController 似乎存在问题,一旦您处于全屏模式并按住快进按钮,让它向前搜索(以快速播放)一直到视频结尾。 此后,你只会得到一个黑屏,它被卡住了。换句话说,它不响应任何
我正在使用 MPMoviePlayerController 在 iPad 上播放电影。 当用户将设备旋转到横向时,我将其设置为全屏。 如果用户随后点击“退出全屏”或“完成”,电影将动画回到其小帧( n
我正在将应用程序移植到 iOS 8。我有一些代码可以播放以前可以运行的视频,但现在不能了。 当我运行它时,我收到以下错误: ( "", "", "", "", "", "", "", "", "" )
MPMoviePlayerController 支持哪些格式? 最佳答案 根据the documentation : 支持的格式 此类播放 iOS 支持的任何电影或音频文件。这包括流式内容和固定长度文
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
这是代码 - (void)applicationDidFinishLaunching:(UIApplication *)application { NSBundle *bundle = [NSBu
每次我的应用程序更改显示的动画(这是一部循环电影)时,他都会暂停,直到最终开始播放电影。MoviePlayerConntroller 是这样创建的 self.moviePlayer = [MP
MPMoviePlayerController 几乎按照我想要的方式工作,除了它覆盖了屏幕上的任何其他项目,例如我的导航栏。有没有办法阻止这种情况发生? 最佳答案 它的播放器是基于 UIView 的,
我们可以像MPMoviePlayerController中的默认Slider一样制作自定义控件吗用于前进和后退电影? 最佳答案 虽然您无法修改 MPMoviePlayerController 类,但您
我想自定义 MPMoviePlayerController 来为视频播放器添加更多控制。我可以添加额外的控件,但顶部缓冲控件被删除。我怎样才能让它可见? 最佳答案 我对你的问题的理解是你想在 MPMo
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:video_url]
如何调整 MPMoviePlayerController 的帧大小? 最佳答案 通过新版本的 MPMoviePlayerController,您可以做到。 关于iphone - MPMoviePlay
我需要在没有播放器任何覆盖的情况下播放电影。没有播放/停止按钮,没有时间线,没有开始/结束时间,没有进度条,什么都没有。只是 subview 中的普通裸体电影。然后这部电影可能会被我自己的图形覆盖。该
我是一名优秀的程序员,十分优秀!