fix iOS demo round timing
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import AVFoundation
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
@@ -239,9 +240,12 @@ enum MockHermesData {
|
||||
winningOutcomeID: String,
|
||||
now: Date
|
||||
) -> HermesRound {
|
||||
let lockAt = now.addingTimeInterval(15)
|
||||
let settleAt = lockAt.addingTimeInterval(6)
|
||||
let mediaURL = localMediaURL(named: "example-round.mov") ?? fallbackMediaURL
|
||||
let previewDurationMs = assetDurationMs(url: mediaURL) ?? 15_000
|
||||
let revealURL = revealMediaURL()
|
||||
let revealDurationMs = assetDurationMs(url: revealURL) ?? 6_000
|
||||
let lockAt = now.addingTimeInterval(Double(previewDurationMs) / 1_000.0)
|
||||
let settleAt = lockAt.addingTimeInterval(6)
|
||||
|
||||
let event = HermesEvent(
|
||||
id: UUID(uuidString: eventID) ?? UUID(),
|
||||
@@ -251,9 +255,9 @@ enum MockHermesData {
|
||||
titleSv: promptKey,
|
||||
status: "active",
|
||||
previewStartMs: 0,
|
||||
previewEndMs: 12_000,
|
||||
revealStartMs: 12_000,
|
||||
revealEndMs: 18_000,
|
||||
previewEndMs: previewDurationMs,
|
||||
revealStartMs: 0,
|
||||
revealEndMs: revealDurationMs,
|
||||
lockAt: lockAt,
|
||||
settleAt: settleAt
|
||||
)
|
||||
@@ -264,11 +268,11 @@ enum MockHermesData {
|
||||
mediaType: "hls_main",
|
||||
hlsMasterUrl: mediaURL,
|
||||
posterUrl: nil,
|
||||
durationMs: 18_000,
|
||||
durationMs: previewDurationMs,
|
||||
previewStartMs: 0,
|
||||
previewEndMs: 12_000,
|
||||
revealStartMs: 12_000,
|
||||
revealEndMs: 18_000
|
||||
previewEndMs: previewDurationMs,
|
||||
revealStartMs: 0,
|
||||
revealEndMs: revealDurationMs
|
||||
)
|
||||
|
||||
let marketUUID = UUID(uuidString: marketID) ?? UUID()
|
||||
@@ -336,4 +340,13 @@ enum MockHermesData {
|
||||
let candidate = repoRoot.appendingPathComponent(fileName)
|
||||
return FileManager.default.fileExists(atPath: candidate.path) ? candidate : nil
|
||||
}
|
||||
|
||||
private static func assetDurationMs(url: URL) -> Int? {
|
||||
let duration = AVAsset(url: url).duration.seconds
|
||||
guard duration.isFinite, duration > 0 else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return Int((duration * 1_000.0).rounded())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user