gpt4 book ai didi

ios - 在 iOS 5.0+ 中获取捕获视频的第一帧

转载 作者:行者123 更新时间:2023-11-29 11:17:27 26 4
gpt4 key购买 nike

我的应用过去可以使用以下代码获取第一个视频帧 - 适用于 iOS 4.0+。但是一旦我的设备升级到 iOS 5.0.1,返回的图像总是 NULL。

+(UIImage *)fFirstVideoFrame:(NSString *)path
{
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc]
initWithContentURL:[NSURL URLWithString:path]];
UIImage *img = [mp thumbnailImageAtTime:0.0
timeOption:MPMovieTimeOptionNearestKeyFrame];
[mp stop];
[mp release];
return img;
}

有谁知道如何在 iOS 5.0+ 中获取视频帧?谢谢。

最佳答案

原因如下(来自 MPMoviePlayerController documentation ):

Behavior in iOS 4.3 and Earlier

In iOS 4.3 and earlier, a new movie player was automatically prepared to play. Starting in iOS 5.0, in order to facilitate finer-grained playback control, a new movie player is not automatically prepared to play. See the discussion for the initWithContentURL: instance method.

讨论部分说:

.. To prepare a new movie player for playback, call the prepareToPlay method ..

To be notified when a new movie player is ready to play, register for the MPMoviePlayerLoadStateDidChangeNotification notification. You can then check load state by accessing the loadState property.

一旦电影准备好播放,您就可以从中请求缩略图。

关于ios - 在 iOS 5.0+ 中获取捕获视频的第一帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8813304/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com