fix iOS media duration deprecation
This commit is contained in:
@@ -31,7 +31,7 @@ final class HermesRepository: ObservableObject {
|
||||
errorCause = nil
|
||||
mockRoundIndex = 0
|
||||
currentSession = MockHermesData.session(localeCode: localeCode, appVersion: appVersion)
|
||||
currentRound = MockHermesData.round(index: mockRoundIndex, now: Date())
|
||||
currentRound = await MockHermesData.round(index: mockRoundIndex, now: Date())
|
||||
isLoading = false
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ final class HermesRepository: ObservableObject {
|
||||
isLoading = true
|
||||
errorCause = nil
|
||||
mockRoundIndex = (mockRoundIndex + 1) % MockHermesData.roundCount
|
||||
let round = MockHermesData.round(index: mockRoundIndex, now: Date())
|
||||
let round = await MockHermesData.round(index: mockRoundIndex, now: Date())
|
||||
currentRound = round
|
||||
isLoading = false
|
||||
return round
|
||||
@@ -193,9 +193,9 @@ enum MockHermesData {
|
||||
)
|
||||
}
|
||||
|
||||
static func round(index: Int, now: Date) -> HermesRound {
|
||||
static func round(index: Int, now: Date) async -> HermesRound {
|
||||
let scenarios = [
|
||||
scenario(
|
||||
await scenario(
|
||||
eventID: "10000000-0000-0000-0000-000000000001",
|
||||
marketID: "20000000-0000-0000-0000-000000000001",
|
||||
yesOutcomeID: "30000000-0000-0000-0000-000000000001",
|
||||
@@ -205,7 +205,7 @@ enum MockHermesData {
|
||||
winningOutcomeID: "30000000-0000-0000-0000-000000000001",
|
||||
now: now
|
||||
),
|
||||
scenario(
|
||||
await scenario(
|
||||
eventID: "10000000-0000-0000-0000-000000000011",
|
||||
marketID: "20000000-0000-0000-0000-000000000011",
|
||||
yesOutcomeID: "30000000-0000-0000-0000-000000000011",
|
||||
@@ -215,7 +215,7 @@ enum MockHermesData {
|
||||
winningOutcomeID: "30000000-0000-0000-0000-000000000012",
|
||||
now: now
|
||||
),
|
||||
scenario(
|
||||
await scenario(
|
||||
eventID: "10000000-0000-0000-0000-000000000021",
|
||||
marketID: "20000000-0000-0000-0000-000000000021",
|
||||
yesOutcomeID: "30000000-0000-0000-0000-000000000021",
|
||||
@@ -239,11 +239,11 @@ enum MockHermesData {
|
||||
sourceRef: String,
|
||||
winningOutcomeID: String,
|
||||
now: Date
|
||||
) -> HermesRound {
|
||||
) async -> HermesRound {
|
||||
let mediaURL = localMediaURL(named: "example-round.mov") ?? fallbackMediaURL
|
||||
let previewDurationMs = assetDurationMs(url: mediaURL) ?? 15_000
|
||||
let previewDurationMs = await assetDurationMs(url: mediaURL) ?? 15_000
|
||||
let revealURL = revealMediaURL()
|
||||
let revealDurationMs = assetDurationMs(url: revealURL) ?? 6_000
|
||||
let revealDurationMs = await assetDurationMs(url: revealURL) ?? 6_000
|
||||
let lockAt = now.addingTimeInterval(Double(previewDurationMs) / 1_000.0)
|
||||
let settleAt = lockAt.addingTimeInterval(6)
|
||||
|
||||
@@ -346,8 +346,11 @@ enum MockHermesData {
|
||||
return FileManager.default.fileExists(atPath: candidate.path) ? candidate : nil
|
||||
}
|
||||
|
||||
private static func assetDurationMs(url: URL) -> Int? {
|
||||
let duration = AVAsset(url: url).duration.seconds
|
||||
private static func assetDurationMs(url: URL) async -> Int? {
|
||||
let asset = AVURLAsset(url: url)
|
||||
guard let duration = try? await asset.load(.duration).seconds else {
|
||||
return nil
|
||||
}
|
||||
guard duration.isFinite, duration > 0 else {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user