iOS 获取音频或是视频的时间
2014-01-19 10:28 三戒1993 阅读(127) 评论(0) 编辑 收藏 举报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.
版权声明:本文为博主原创文章,未经博主允许不得转载。