美文网首页iOS 多媒体
iOS 获取音频或是视频的时间

iOS 获取音频或是视频的时间

作者: 蜗蜗牛在奔跑 | 来源:发表于2016-08-26 17:18 被阅读2663次

相关文章

网友评论

  • 半生飘零:为什么我一直少一秒呢
  • CMD独白:您好,问一下我用模拟器可以获取的到录音的时长,可是用真机测试的时候时长返回的一直是0
    CMD独白:@L1先生 谢谢你的回复,找到原因了,忘记写这句话了[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
    蜗蜗牛在奔跑:@CMD独白 会不会是你的路径有问题,你打印看看
    蜗蜗牛在奔跑:@CMD独白 //获取时长
    - (CGFloat)durationWithVideo:(NSURL *)videoUrl{

    AVURLAsset* audioAsset =[AVURLAsset URLAssetWithURL:videoUrl options:nil];
    CMTime audioDuration = audioAsset.duration;

    float audioDurationSeconds =CMTimeGetSeconds(audioDuration);

    return audioDurationSeconds;
    }
    我用的没问题啊

本文标题:iOS 获取音频或是视频的时间

本文链接:https://www.haomeiwen.com/subject/nsszsttx.html