播放按钮和电影放映之间的延迟
我有一个简单的视图,当用户按下按钮时,使用 PresentMoviePlayerViewControllerAnimated: 方法创建 MPMoviePlayerViewController。新的视图控制器滑入并显示电影播放器,到目前为止一切顺利。
但是,当按下按钮时,当前视图控制器会滑出底部,显示丑陋的(可能是默认的)白色视图,该视图会在任何地方停留半秒到几秒,直到显示电影视图控制器。看起来它依赖于我的网络连接,就好像电影视图控制器在显示播放器之前下载电影的部分内容一样。
我做错了什么吗,或者我该如何解决这个问题?我真的更喜欢直接显示电影视图控制器,甚至可能不需要滑出之前保存播放按钮的视图控制器,但仍然像模态视图控制器一样进行动画处理。
谢谢!
克里斯托夫
I have a simple view that creates a MPMoviePlayerViewController when the user presses a button, using the presentMoviePlayerViewControllerAnimated: method. The new view controller slides in and shows the movie player, so far so good.
However, when the button is pushed, the current view controller slides out the bottom, showing a ugly (probably default) white view, that sticks around anywhere from half a second to a few seconds, until the movie view controller is shown. It seems like it's dependent on my network connection, as if the movie view controller is downloading parts of the movie before showing the player.
Am I doing something wrong, or how can I work around this? I'd really prefer to just show the movie view controller directly, maybe even without sliding out the previous view controller that holds the play button, but still animated like a modal view controller.
Thanks!
Christoph
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
解决方案是在创建父视图时初始化播放器视图控制器,然后在其中的
moviePlayer
上调用prepareToPlay
。这消除了按下播放按钮时的延迟,并且(我猜)将其移动到用户到达可以播放电影的父视图时。编辑:
这消除了延迟,但由于某种原因,初始化电影视图控制器也会在加载时自动播放它,所以这不是一个好的解决方案。
The solution was to init the player view controller when the parent view is created, and then call
prepareToPlay
on themoviePlayer
inside it. That removes the latency when the play button is pushed and (I guess) moves it to when the user gets to the parent view from which he can play the movie.EDIT:
This removes the delay, but for some reason, initializing the movie view controller also autoplays it when it's loaded, so that's not a good solution.
我最终只是将视图的背景设置为黑色。不修复延迟,但使其看起来更好:
I ended up just setting the background of the view to black. Doesn't fix the delay, but makes it look much nicer:
这就是我为 iOS 所做的> 3.2 :
因此
,在 viewdidload 中,您可以实例化您想要的内容(例如 UIActivityIndicatorView)。仅当预加载完成后,视图控制器才会被替换。
this is what i do for iOS > 3.2 :
and
Thus in the viewdidload you can instantiate what you want (UIActivityIndicatorView for example). The view controller will only be replaced when the preload is finished.
我在我的应用程序中注意到同样的问题。有人有避免这个问题的建议吗?
就我而言,我将 MPMoviePlayerViewController 作为模式弹出窗口推送到 UI。
I'm noticing the same issue in my app. Anyone have suggestions to avoid this issue?
In my case, I'm pushing the MPMoviePlayerViewController to the UI as a modal popup.