One Logo Pool Ball
CoreMedia · IOS API REFERENCE

CMTimebase

class · iOS 6.0+ · SDK 27.1

class CMTimebase

Members (34)

init · iOS 6.0+

init

TypeScript
static init(object: CMTimebase): CMTimebase
Swift declaration
init(referencing object: CMTimebase)
get · iOS 13.0+

timeJumped

TypeScript
static get timeJumped(): _Foundation_NSNotification_Name
Swift declaration
static let timeJumped: NSNotification.Name

Posted by a timebase after a discontinuous time jump.

get · iOS 13.0+ · Deprecated in iOS 15.0

masterClock

TypeScript
get masterClock(): (CMClock) | null
Swift declaration
var masterClock: CMClock? { get }

Deprecated synonym for sourceClock.

method · iOS 13.0+

removeTimer

TypeScript
removeTimer(timer: _Foundation_Timer): void
Swift declaration
func removeTimer(_ timer: Timer) throws

Removes the timer from the list of timers managed by the timebase. The timebase will no longer maintain the timer's "NextFireDate". If the timer is invalidated, the timebase will eventually remove it from its list and release it even if this function is not called.

method · iOS 13.0+

removeTimer

TypeScript
removeTimer62076(timer: _Dispatch_DispatchSource): void
Swift declaration
func removeTimer<T>(_ timer: T) throws where T : DispatchSourceTimer

Removes the timer dispatch source from the list of timers managed by the timebase. The timebase will no longer maintain the timer source's start time. If the timer source is cancelled, the timebase will eventually remove it from its list and release it even if this function is not called.

get · iOS 15.0+

sourceClock

TypeScript
get sourceClock(): (CMClock) | null
Swift declaration
var sourceClock: CMClock? { get }

Returns the immediate source clock. Returns `nil` if the timebase actually has a source timebase instead of a source clock.

get · iOS 13.0+

timeAndRate

TypeScript
get timeAndRate(): { "time": CMTime; "rate": number }
Swift declaration
var timeAndRate: (time: CMTime, rate: Double) { get }

The current time and rate. You can use this to take a consistent snapshot of the two values, avoiding possible inconsistencies due to external changes between retrieval of `time` and `rate`.

get · iOS 13.0+

effectiveRate

TypeScript
get effectiveRate(): number
Swift declaration
var effectiveRate: Double { get }

The effective rate (which combines its rate with the rates of all its master timebases). Calling `timebase.effectiveRate` is equivalent to calling `timebase.rate(relativeTo: timebase.ultimateMasterClock)`

method · iOS 13.0+

setAnchorTime

TypeScript
setAnchorTime(anchorTime: CMTime, referenceTime: CMTime): void
Swift declaration
func setAnchorTime(_ anchorTime: CMTime, referenceTime: CMTime) throws

Sets the time at a particular master time. `time` will be interpolated from that anchor time. `timebase.setTime(time)` is equivalent to calling `timebase.setAnchorTime(time, timebase.master.time)`

get · iOS 13.0+ · Deprecated in iOS 15.0

masterTimebase

TypeScript
get masterTimebase(): (CMTimebase) | null
Swift declaration
var masterTimebase: CMTimebase? { get }

Deprecated synonym for sourceTimebase.

get · iOS 15.0+

sourceTimebase

TypeScript
get sourceTimebase(): (CMTimebase) | null
Swift declaration
var sourceTimebase: CMTimebase? { get }

The immediate source timebase. Returns `nil` if the timebase actually has a source clock instead of a source timebase.

method · iOS 13.0+

notificationBarrier

TypeScript
notificationBarrier(): void
Swift declaration
func notificationBarrier() throws

Requests that the timebase wait until it is not posting any notifications.

get · iOS 13.0+ · Deprecated in iOS 15.0

ultimateMasterClock

TypeScript
get ultimateMasterClock(): CMClock
Swift declaration
var ultimateMasterClock: CMClock { get }

Deprecated synonym for ultimateSourceClock.

get · iOS 15.0+

ultimateSourceClock

TypeScript
get ultimateSourceClock(): CMClock
Swift declaration
var ultimateSourceClock: CMClock { get }

The source clock that is the source of all of the source timebases.

get · iOS 13.0+

effectiveRateChanged

TypeScript
static get effectiveRateChanged(): _Foundation_NSNotification_Name
Swift declaration
static let effectiveRateChanged: NSNotification.Name

Posted by a timebase after a change in effective rate.

method · iOS 13.0+

setRateAndAnchorTime

TypeScript
setRateAndAnchorTime(rate: number, anchorTime: CMTime, referenceTime: CMTime): void
Swift declaration
func setRateAndAnchorTime(rate: Double, anchorTime: CMTime, referenceTime: CMTime) throws

Sets the time at a particular master time, and changes the rate at exactly that time. `time` will be interpolated from that anchor time as though the timebase has been running at the requested rate since that time. `timebase.setRate(rate)` is approximately equivalent to calling ``` timebase.setRateAndAnchorTime(rate: rate, anchorTime: timebase.time, referenceTime: timebase.master.time) ``` except that `setRate` will not generate a `TimeJumped` notification, and `setRateAndAnchorTime` will.

method · iOS 13.0+

setTimerNextFireTime

TypeScript
setTimerNextFireTimeFireTime(timer: _Foundation_Timer, fireTime: CMTime): void
Swift declaration
func setTimerNextFireTime(_ timer: Timer, fireTime: CMTime) throws

Sets the `CMTime` on the timebase's timeline at which the timer should next be fired. The timer must be on the list of timers managed by the timebase. The timebase will continue to update the timer's "NextFireDate" according to time jumps and effective rate changes. If `fireTime` is not numeric, or if the timebase is not moving, the "NextFireDate" will be set to a date far, far in the future. IMPORTANT NOTE: Due to the way that `CFRunLoopTimer`s are implemented, if a timer passes through a state in which it is due to fire, it may fire even if its rescheduled before the runloop runs again. Clients should take care to avoid temporarily scheduling timers in the past. For example, set the timebase's rate or time before you set the timer's next fire time, if you are doing both at once. (If setting the timebase's rate or time might put the timer's fire time in the past, you may need to set the fire time to `CMTime.invalid` across the timebase change.)

method · iOS 13.0+

setTimerNextFireTime

TypeScript
setTimerNextFireTimeFireTime78006(timer: _Dispatch_DispatchSource, fireTime: CMTime): void
Swift declaration
func setTimerNextFireTime<T>(_ timer: T, fireTime: CMTime) throws where T : DispatchSourceTimer

Sets the `CMTime` on the timebase's timeline at which the timer dispatch source should next be fired. The timer source must be on the list of timers managed by the timebase. The timebase will continue to update the timer dispatch source's start time according to time jumps and effective rate changes. If `fireTime` is not numeric, or if the timebase is not moving, the start time will be set to `DispatchTime.distantFuture`. IMPORTANT NOTE: Due to the way that timer dispatch sources are implemented, if a timer passes through a state in which it is due to fire, it may fire even if its rescheduled before the event handler is run. Clients should take care to avoid temporarily scheduling timers in the past. For example, set the timebase's rate or time before you set the timer's next fire time, if you are doing both at once. (If setting the timebase's rate or time might put the timer's fire time in the past, you may need to set the fire time to `CMTime.invalid` across the timebase change.)

get · iOS 13.0+

veryLongTimeInterval

TypeScript
static get veryLongTimeInterval(): number
Swift declaration
static let veryLongTimeInterval: CFTimeInterval

Quite a while (256 years).

method · iOS 13.0+

setTimerToFireImmediately

TypeScript
setTimerToFireImmediately(timer: _Foundation_Timer): void
Swift declaration
func setTimerToFireImmediately(_ timer: Timer) throws

Sets the timer to fire immediately once, overriding any previous `setTimerNextFireTime` call. The timer must be on the list of timers managed by the timebase. This is equivalent to calling `CFRunLoopTimerSetNextFireDate(timer, CFAbsoluteTimeGetCurrent())` except that the timebase gets to know that it shouldn't interfere.

method · iOS 13.0+

setTimerToFireImmediately

TypeScript
setTimerToFireImmediately4442(timer: _Dispatch_DispatchSource): void
Swift declaration
func setTimerToFireImmediately<T>(_ timer: T) throws where T : DispatchSourceTimer

Sets the timer dispatch source to fire immediately once, overriding any previous `setTimerNextFireTime` call. The timer source must be on the list of timers managed by the timebase. This is equivalent to calling `timerSource.schedule(deadline: DispatchTime.now())` except that the timebase gets to know that it shouldn't interfere.

get · iOS 13.0+

rate

TypeScript
get rate(): number
Swift declaration
var rate: Double { get }

The current rate. This is the rate relative to its immediate master clock or timebase. For example, if a timebase is running at twice the rate of its master, its rate is 2.0.

method · iOS 13.0+

time

TypeScript
timeWithTimescaleRounding(timescale: number, rounding?: CMTimeRoundingMethod): CMTime
Swift declaration
func time(withTimescale timescale: CMTimeScale, rounding: CMTimeRoundingMethod = .`default`) -> CMTime

Retrieves the current time in the specified timescale.

get · iOS 13.0+

time

TypeScript
get time(): CMTime
Swift declaration
var time: CMTime { get }

The current time.

get · iOS 13.0+ · Deprecated in iOS 15.0

master

TypeScript
get master(): SDKHandle
Swift declaration
var master: any CMSyncProtocol { get set }

Deprecated synonym for source.

set · iOS 13.0+ · Deprecated in iOS 15.0

master

TypeScript
set master(value: SDKHandle)
Swift declaration
var master: any CMSyncProtocol { get set }

Deprecated synonym for source.

get · iOS 15.0+

source

TypeScript
get source(): SDKHandle
Swift declaration
var source: any CMSyncProtocol { get set }

Returns the immediate source (either timebase or clock).

set · iOS 15.0+

source

TypeScript
set source(value: SDKHandle)
Swift declaration
var source: any CMSyncProtocol { get set }

Returns the immediate source (either timebase or clock).

get · iOS 13.0+

typeID

TypeScript
static get typeID(): number
Swift declaration
static var typeID: CFTypeID { get }

The `CFTypeID` corresponding to `CMTimebase`.

method · iOS 13.0+

setRate

TypeScript
setRate(rate: number): void
Swift declaration
func setRate(_ rate: Double) throws

Sets the rate.

method · iOS 13.0+

setTime

TypeScript
setTime(time: CMTime): void
Swift declaration
func setTime(_ time: CMTime) throws

Sets the current time.

method · iOS 13.0+

addTimer

TypeScript
addTimerOn(timer: _Foundation_Timer, runloop: _Foundation_RunLoop): void
Swift declaration
func addTimer(_ timer: Timer, on runloop: RunLoop) throws

Adds the timer to the list of timers managed by the timebase. The timer must be a repeating run loop timer (with a very long interval at least as long as .veryLongTimeInterval), attached to a runloop. The timebase will retain the timer, and will maintain its "NextFireDate" according to the `CMTime` set using `setTimerNextFireTime`. Until the first call to `setTimerNextFireTime`, the "NextFireDate" will be set far, far in the future. The runloop that timer is attached to must be passed in and the timebase will retain that runloop. The retained runloop will be used to call `CFRunLoopWakeUp()` any time the timebase modifies the timer's fire date.

method · iOS 13.0+

addTimer

TypeScript
addTimer(timer: _Dispatch_DispatchSource): void
Swift declaration
func addTimer<T>(_ timer: T) throws where T : DispatchSourceTimer

Adds the timer dispatch source to the list of timers managed by the timebase. The timer source must have been created by calling `DispatchSource.makeTimerSource(flags: [], queue: some_dispatch_queue)` and should have had an event handler associated with it via `timerSource.setEventHandler { /* timer fired */ } Don't forget to call `timerSource.activate()` as dispatch sources are created in an inactive state. The timebase will retain the timer source, and will maintain its start time according to the `CMTime` set using `setTimerNextFireTime`. Until the first call to `setTimerNextFireTime`, the start time will be set to `DispatchTime.distantFuture`.

get · iOS 13.0+

farFuture

TypeScript
static get farFuture(): number
Swift declaration
static let farFuture: CFAbsoluteTime

Quite a while from 2001 (2257).

Skipped declarations

5 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

CMTimebase.NotificationKey

The iOS SDK compiler rejected this binding: type 'CMTimebase.NotificationKey' does not conform to protocol 'OneSDKNamedConstants'

CMTimebase.rate(relativeTo:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

CMTimebase.rateAndAnchorTime(relativeTo:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

CMTimebase.convertTime(_:to:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

CMTimebase.mightDrift(relativeTo:)

This declaration needs Swift generic type arguments. (no canonical witness for T)

All CoreMedia types →