Platforms to show: All Mac Windows Linux Cross-Platform

Back to AVPlayerMBS class.

AVPlayerMBS.addBoundaryTimeObserverForTime(time as CMTimeMBS, tag as variant = nil) as AVPlayerTimeObserverMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Requests invocation of a event when specified time are traversed during normal playback.

time: A CMTimeMBS value representing the times at which to invoke event.
Returns an opaque object that you pass as the argument to removeTimeObserver to stop observation.

You must retain the returned value as long as you want the time observer to be invoked by the player. Each invocation of this method should be paired with a corresponding call to removeTimeObserver. This is done automatically for you by AVPlayerTimeObserverMBS class destructor.

Calls AVFoundationMBS.BoundaryTimeObserver event passing tag value.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

AVPlayerMBS.addBoundaryTimeObserverForTimes(times() as CMTimeMBS, tag as Variant = nil) as AVPlayerTimeObserverMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Requests invocation of a event when specified times are traversed during normal playback.

times: An array of NSValue objects containing CMTime values representing the times at which to invoke event.
Returns an opaque object that you pass as the argument to removeTimeObserver to stop observation.

You must retain the returned value as long as you want the time observer to be invoked by the player. Each invocation of this method should be paired with a corresponding call to removeTimeObserver. This is done automatically for you by AVPlayerTimeObserverMBS class destructor.

Calls AVFoundationMBS.BoundaryTimeObserver event passing tag value.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

AVPlayerMBS.addLoopTimeObserver(atTime as CMTimeMBS, jumpToTime as CMTimeMBS) as AVPlayerTimeObserverMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 19.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Requests invocation of a code to jump in time to another position.

atTime: A CMTimeMBS value representing the times at which to invoke event.
jumpToTime: The CMTImeMBS where to jump to.

Returns an opaque object that you pass as the argument to removeTimeObserver to stop observation.

You must retain the returned value as long as you want the time observer to be invoked by the player. Each invocation of this method should be paired with a corresponding call to removeTimeObserver. This is done automatically for you by AVPlayerTimeObserverMBS class destructor.

AVPlayerMBS.addPeriodicTimeObserverForInterval(interval as CMTimeMBS, tag as Variant = nil) as AVPlayerTimeObserverMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Requests invocation of a given event during playback to report changing time.

interval: The interval of invocation of the event during normal playback, according to progress of the current time of the player.
The event takes a single parameter:

Returns an opaque object that you pass as the argument to removeTimeObserver to cancel observation.

You must retain the returned value as long as you want the time observer to be invoked by the player. Each invocation of this method should be paired with a corresponding call to removeTimeObserver. This is done automatically for you by AVPlayerTimeObserverMBS class destructor.

The AVFoundationMBS.PeriodicTimeObserver event is invoked periodically at the interval specified, interpreted according to the timeline of the current item. The event is also invoked whenever time jumps and whenever playback starts or stops. If the interval corresponds to a very short interval in real time, the player may invoke the event less frequently than requested. Even so, the player will invoke the event sufficiently often for the client to update indications of the current time appropriately in its end-user interface.

Special Considerations
Releasing the observer object without invoking removeTimeObserver: will result in undefined behavior.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

Some examples using this method:

AVPlayerMBS.cancelPendingPrerolls

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Cancels the preloading of media data.

This method cancels any pending operations to prepare the render pipeline for the current item.
Available in OS X v10.8 and later.

AVPlayerMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The default constructor.

See also:

AVPlayerMBS.Constructor(File as folderitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes a new player to play a single audiovisual resource referenced by a given file.

File: A folderitem that identifies an audiovisual resource.
This method implicitly creates an AVPlayerItem object. You can get the player item using currentItem.

See also:

AVPlayerMBS.Constructor(item as AVPlayerItemMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes a new player to play a given single audiovisual item.

You can use this method to play items for which you have an existing AVAsset object (see Constructor in AVPlayerItem).

See also:

AVPlayerMBS.Constructor(URL as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes a new player to play a single audiovisual resource referenced by a given URL.

URL: An URL that identifies an audiovisual resource.
This method implicitly creates an AVPlayerItem object. You can get the player item using currentItem.

See also:

AVPlayerMBS.mediaSelectionCriteriaForMediaCharacteristic(mediaCharacteristic as string) as AVPlayerMediaSelectionCriteriaMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 14.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the automatic selection criteria for media that has the specified media characteristic.

mediaCharacteristic: The media characteristic for which the selection criteria is to be returned. Supported values include AVMediaCharacteristicAudible, AVMediaCharacteristicLegible, and AVMediaCharacteristicVisual.

Returns the automatic media selection criteria for mediaCharacteristic.

Available in OS X v10.9 and later.

AVPlayerMBS.pause

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Pauses playback.

This is the same as setting rate to 0.0.

AVPlayerMBS.play

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Begins playback of the current item.

This is the same as setting rate to 1.0.

AVPlayerMBS.prerollAtRate(rate as Double, tag as Variant)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Begins loading media data to prime the media pipelines for playback.

rate: The playback rate to use when determining how much data to load.

Calls AVFoundationMBS.prerollAtRateFinished event when the player finishes the load attempt.

This method loads data starting at the item's current playback time. The current rate for the playback item should always be 0 prior to calling this method. After the method calls the completion handler, you can change the item's playback rate to begin playback.

If the player object is not ready to play (its status property is not AVPlayerStatusReadyToPlay), this method throws an exception.
Available in OS X v10.8 and later.

AVPlayerMBS.replaceCurrentItemWithPlayerItem(item as AVPlayerItemMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Replaces the player item with a new player item.

item: A player item.

You can only use this method with players created without queues. If the player was not initialized with a single item and no queue, the method throws an exception.

The item replacement occurs asynchronously; observe the currentItem property to find out when the replacement will/did occur.

Special Considerations
The new item must have the same compositor as the item it replaces, or have no compositor.

Some examples using this method:

AVPlayerMBS.seekToDate(date as date, fireEvent as boolean = false, tag as Variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 14.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Moves the playback cursor to the specified time.

If FireEvent is true, the AVFoundationMBS.playerSeekToDateFinished event is called.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

See also:

AVPlayerMBS.seekToDate(date as dateTime, fireEvent as boolean = false, tag as variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 20.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Moves the playback cursor to the specified time.

If FireEvent is true, the AVFoundationMBS.playerSeekToDateFinished event is called.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

See also:

AVPlayerMBS.seekToTime(time as CMTimeMBS, fireEvent as boolean = false, tag as Variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Moves the playback cursor to a given time.

time: The time to which to move the playback cursor.

Use this method to seek to a specified time for the current player item and be notified when the operation completes. If the seek request completes without being interrupted (either by another seek request or by any other operation), the AVFoundationMBS.playerSeekToTimeFinished is executed with the finished parameter set to true.

If another seek request is already in progress when you call this method, the event for the in-progress seek request is executed immediately with the finished parameter set to false.

If fireevent is true, the AVFoundationMBS.playerSeekToTimeFinished event is run later.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

See also:

AVPlayerMBS.seekToTime(time as CMTimeMBS, toleranceBefore as CMTimeMBS, toleranceAfter as CMTimeMBS, fireEvent as boolean = false, tag as Variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Moves the playback cursor within a specified time bound and invokes the event when the seek operation has either been completed or been interrupted.

If fireevent is true, the AVFoundationMBS.playerSeekToTimeFinished event is run later.

time: The time to which you would like to move the playback cursor.
toleranceBefore: The tolerance allowed before time.
toleranceAfter: The tolerance allowed after time.

Use this method to seek to a specified time for the current player item and to be notified when the seek operation is complete.

The time seeked to will be within the range [time-beforeTolerance, time+afterTolerance], and may differ from the specified time for efficiency. If you pass kCMTimeZero for both toleranceBefore and toleranceAfter (to request sample accurate seeking), you may incur additional decoding delay.

Invoking this method with toleranceBefore set to kCMTimePositiveInfinity and toleranceAfter set to kCMTimePositiveInfinity is the same as invoking seekToTime:.

The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter set to false. If the new request completes without being interrupted by another seek request or by any other operation the event will be invoked with the finished parameter set to true.

With tag you can pass any value you like to the event later. This can be for example an object reference or a number in an array. Be aware that the reference to this tag value is kept until the event is called and can cause memory reference cycles.

See also:

AVPlayerMBS.setMediaSelectionCriteria(criteria as AVPlayerMediaSelectionCriteriaMBS, mediaCharacteristic as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 14.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Applies automatic selection criteria for media that has the specified media characteristic.

criteria: An instance of AVPlayerMediaSelectionCriteria that specifies the selection criteria.
mediaCharacteristic: The media characteristic for which the selection criteria are to be applied. Supported values include AVMediaCharacteristicAudible, AVMediaCharacteristicLegible, and AVMediaCharacteristicVisual.

Criteria will be applied to an AVPlayerItem instance when:

  • It is made ready to play.
  • Specific media selections are made by the AVPlayerItem instance using the method selectMediaOption in a different group. The automatic choice in one group may be influenced by a specific selection in another group.
  • Underlying system preferences change, e.g. system language, accessibility captions.
Specific selections made by the AVPlayerItem instance using the method selectMediaOption method within any group will override automatic selection in that group until the player item receives a selectMediaOptionAutomaticallyInMediaSelectionGroup message.

Available in OS X v10.9 and later.

AVPlayerMBS.setRate(rate as Double, time as CMTimeMBS, HostTime as CMTimeMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Synchronizes the playback rate and time of the current item with an external source.

rate: The playback rate for the item.
itemTime: The precise time at which to match playback of the item. To use the current item's current time, specify kCMTimeInvalid.
hostClockTime: The host time at which to synchronize playback. If you specify kCMTimeInvalid, the rate and time are set together without any external synchronization.

This method adjusts the current item's timebase so that the time in itemTime is in sync with the time in hostClockTime. Thus, if hostClockTime specifies a time in the past, the item's timebase is adjusted to make it appear as if the item has been running at the specified rate since itemTime. And if hostClockTime specifies a time in the future, playback is adjusted backward (if possible) so that the value in itemTime occurs at the precise moment the host's clock reaches the value in hostClockTime. If there is no content to play before the time specified by itemTime, playback holds until the two times come into sync.

This method does not ensure that media data is loaded before the timebase starts moving. However, if you specify a host time in the near future, that would give you some time to load the media data and prepare for playback.

The items on this page are in the following plugins: MBS AVFoundation Plugin.


The biggest plugin in space...