Returns the sum of two CMTimes
.
SDKs
- iOS 4.0+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 6.0+
Framework
- Core Media
Declaration
Parameters
addend1
CMTime
to be added.addend2
Another
CMTime
to be added.
Return Value
A new CMTime
with the summed value of addend1
and addend2
.
Discussion
If the operands both have the same timescale, the timescale of the result will be the same as the operands' timescale. If the operands have different timescales, the timescale of the result will be the least common multiple of the operands' timescales. If that LCM timescale is greater than k
, the result timescale will be k
, and default rounding will be applied when converting the result to this timescale. If the result value overflows, the result timescale will be repeatedly halved until the result value no longer overflows. Again, default rounding will be applied when converting the result to this timescale. If the result value still overflows when timescale == 1, then the result will be either positive or negative infinity, depending on the direction of the overflow.
If any rounding occurs for any reason, the result's has
flag will be set. This flag will also be set if either of the operands has has
set. If either of the operands is invalid, the result will be invalid. If the operands are valid, but just one operand is infinite, the result will be similarly infinite. If the operands are valid, and both are infinite, the results will be as follows:
+infinity + +infinity == +infinity
-infinity + -infinity == -infinity
+infinity + -infinity == invalid
-infinity + +infinity == invalid
If the operands are valid, not infinite, and either or both is indefinite, the result will be indefinite. If the two operands are numeric (i.e.. valid, not infinite, not indefinite), but have different nonzero epochs, the result will be invalid. If they have the same nonzero epoch, the result will have epoch zero (a duration). Times in different epochs cannot be added or subtracted, because epoch length is unknown. Times in epoch zero are considered to be durations and can be added to times in other epochs. Times in different epochs can be compared, however, because numerically greater epochs always occur after numerically lesser epochs.