【问题标题】:AVPlayer Item get a nan duration (invalid)AVPlayer 项目获得 nan 持续时间(无效)
【发布时间】:2016-10-26 04:49:54
【问题描述】:

我正在使用AVAsset 类并传递了 url。但它没有提供持续时间。我只收到nan

CMTime audioDuration = audioAsset.duration;
float audioDurationSeconds = CMTimeGetSeconds(audioDuration);
double duration = CMTimeGetSeconds(asset.duration);

【问题讨论】:

    标签: ios objective-c avasset


    【解决方案1】:

    试试下面的代码,

     AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:info[UIImagePickerControllerMediaURL] options:nil];   // info[UIImagePickerControllerMediaURL] is url(file url) here. You should pass your url here
    
       CMTime videoDuration = asset1.duration;
    
      float videoDurationInSeconds = CMTimeGetSeconds(videoDuration);
    

    并确保您的网址是文件网址!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多