5

Using Xcode 14.0, iOS 16, Swift 5.7,

I get the following deprecation warning due to iOS 16:

'duration' was deprecated in iOS 16.0: Use load(.duration) instead

Here is my code:

var actualTime: CMTime = CMTimeMake(value: 0, timescale: asset.duration.timescale)

What do I need to change in order to get rid of this warning?

I tried:

var actualTime: CMTime = CMTimeMake(value: 0, timescale: asset.load(.duration).timescale)

But this makes everything async. Do I really need to go down that road?

TylerP
  • 9,600
  • 4
  • 39
  • 43
iKK
  • 6,394
  • 10
  • 58
  • 131
  • 5
    Adopting `async/await` is *going upstairs*. Please read https://developer.apple.com/documentation/avfoundation/media_assets/loading_media_data_asynchronously – vadian Sep 25 '22 at 17:52

1 Answers1

6
let duration = try await asset.load(.duration)
Timchang Wuyep
  • 629
  • 7
  • 10