iOS 16 deprecation of asset.duration
Asked Answered
B

2

6

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?

Bores answered 25/9, 2022 at 17:36 Comment(1)
Adopting async/await is going upstairs. Please read developer.apple.com/documentation/avfoundation/media_assets/…Undercool
R
9
let duration = try await asset.load(.duration)
Rosemari answered 9/5, 2023 at 20:23 Comment(0)
M
2

Found this solution:

   Task {
         let duration = try await asset.load(.duration)
    }
Morocco answered 15/4 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.