MPMoviePlayerController 缩略图ImageAtTime 返回空 UIImage

发布于 2024-09-17 23:00:13 字数 748 浏览 1 评论 0原文

我正在开发一个 iPad 应用程序,该应用程序使用 MPMoviePlayerController 播放视频,并基于用户交互,使用thumbnailImageAtTime 尝试从视频中抓取图像。

我尝试过使用 MPMovieTimeOptionNearestKeyFrame 和 MPMovieTimeOptionExact 这两个选项。无论哪种选择,我发现有时会返回一个空的 UIImage。也就是说,返回的 UIImage 似乎是一个有效的对象(!nil),但是当我尝试显示此图像(在 UImageView 中)时,我什么也看不到。

在其他时候,它工作正常并返回良好的缩略图。

在试图缩小情况范围时,我能说的最好的是,问题更有可能在我第一次调用它时出现(即在电影的早期)。一旦失败,它更有可能在连续的调用中工作。

在每种情况下,在调用thumbnailImageAtTime后,我都会停止电影播放器​​并释放它。后来,我重新创建电影播放器​​对象并加载同一部电影,并使用 setInitialPlaybackTime 使电影在创建缩略图时同时播放。

之后,如果我再次调用 setInitialPlaybackTime,它几乎总是有效 - 但并非总是如此!

有其他人看到过这种行为或知道为什么会发生这种情况吗?

我的下一步是创建一个示例应用程序,它播放视频并有一个“获取缩略图”按钮,它将调用 setInitialPlaybackTime 并在屏幕上显示缩略图,而无需每次停止播放器,作为实验。或者,您的一些意见可能会帮助我避免所有这些苦差事!

谢谢!

I'm working on an iPad app that plays a video with MPMoviePlayerController and - based on user interaction - uses thumbnailImageAtTime to try to grab an image from the video.

I've tried using both options MPMovieTimeOptionNearestKeyFrame and MPMovieTimeOptionExact. Regardless of which option, I find that I sometimes get back an empty UIImage. That is to say the UIImage returned appears to be a valid object (!nil) but when I attempt to display this image (in a UImageView) I see nothing.

At other times, it works fine and returns a good thumbnail.

In trying to narrow down the circumstances, the best I can say is that the problem is more likely to appear the first time I call it (ie. early in the movie). Once it has failed, it is more likely to work on successive calls.

In each case, after I call thumbnailImageAtTime I stop the movie player and release it. Later, I re-create the movie player object and load the same movie and use setInitialPlaybackTime to get the movie playing at the same time it was it when the thumbnail was created.

After that, if I call setInitialPlaybackTime again, it almost always works - but not always!

Has anyone else seen this behavior or have a clue as to why this is happening?

My next step is to create a sample app which plays a video and has a button "Get Thumbnail" which will call setInitialPlaybackTime and show the thumbnail on the screen WITHOUT stopping the player each time, as an experiment. Alternately, some input from you might help me avoid all that drudgery!

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

杀手六號 2024-09-24 23:00:13

好吧,我错了,问题是放置图像的视图的 alpha 意外设置为 0。我犯了错,没关系……

Ok, I was mistaken, the problem was the view the image was placed in had its alpha set to 0 accidentally. MEA CULPA and Nevermind...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文