ios获取音频或者视频是时间长度

AVURLAsset* audioAsset =[AVURLAssetURLAssetWithURL:audioFileURL options:nil];

CMTime audioDuration = audioAsset.duration;

float audioDurationSeconds =CMTimeGetSeconds(audioDuration);

Note that AVFoundation is designed as a heavily asynchronous framework in order to improve performance and the overall user experience. Even performing simple tasks such as querying a media file's duration can take a long period of time which would cause your application to hang. You should use the AVAsynchronousKeyValueLoading protocol to asynchronously load the duration of the song, and then update your UI in the completion handler block.

posted on 2013-01-15 09:49  kiao295338444  阅读(1109)  评论(0编辑  收藏  举报

导航