forked from alexiscn/MTTransitions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
152 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// CMTime+Extensions.swift | ||
// MTTransitions | ||
// | ||
// Created by Jim Wang on 2022/11/28. | ||
// | ||
|
||
import CoreMedia | ||
import Foundation | ||
|
||
extension CMTime { | ||
|
||
static func makeLoopTime(timeRange: CMTimeRange, at: CMTime = .zero, until: CMTime) -> [(at: CMTime, timeRange: CMTimeRange)] { | ||
let duration = timeRange.duration | ||
var t = at | ||
var times = [(at: CMTime, timeRange: CMTimeRange)]() | ||
while t < until { | ||
let adjustedDuration = CMTimeMinimum(CMTimeSubtract(until, t), duration) | ||
let adjustedTimeRange = CMTimeRange(start: timeRange.start, duration: adjustedDuration) | ||
times.append((at: t, timeRange: adjustedTimeRange)) | ||
t = CMTimeAdd(t, adjustedDuration) | ||
} | ||
return times | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters