1
 AVURLAsset* audioAsset = [[AVURLAsset alloc]initWithURL:assetURL options:@{AVURLAssetPreferPreciseDurationAndTimingKey:@YES}]; 
 // audio asset url  create object and specifies its method....

this audio asset can get value in only second?

I want to know how above code works and role of AVURLAsset

Kumar
  • 1,882
  • 2
  • 27
  • 44

2 Answers2

1

AVURLAsset is a subclass of AVAsset. AVAsset is used to get information about the asset such as metadata (like track titles, author, composer, and so on). The "asset" is usually a sound or video file.

In the example you have given, you are creating an AVAsset from a URL, and you are specifying that you want precise duration and timing. Because of that option, when you ask for the duration, there may be a significant amount of work required for the AVAsset method to compute a precise time. This is clearly stated in the Apple documentation. The documentation also suggests that you usually do not need the precise duration and timing.

0

The (no-)difference between AVAsset and AVURLAsset as of 2022-12-08:

https://developer.apple.com/documentation/avfoundation/avurlasset

This class is a concrete subclass of AVAsset. When you create an asset as shown below, the system creates and returns an instance of AVURLAsset.

let url: URL = // A local or remote asset URL.
let asset = AVAsset(url: url)
Fred Klein
  • 448
  • 6
  • 13