Platforms to show: All Mac Windows Linux Cross-Platform

AVPlayerLooperMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class AVFoundation MBS AVFoundation Plugin 22.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: AVPlayerLooperMBS is a helper object that repeatedly plays an AVPlayerItemMBS with an AVQueuePlayerMBS.

// Create player and configure
Dim player As New AVQueuePlayerMBS
Dim playerLayer As New AVPlayerLayerMBS(player)

// Create looping item
Dim file As FolderItem = SpecialFolder.Desktop.Child("")
Dim itemToLoop As New AVPlayerItemMBS(file)

// Create looping helper object. Loop item segment from 5sec to 7sec
Dim startTime As CMTimeMBS = CMTimeMBS.Make(5000, 1000)
Dim duration As CMTimeMBS = CMTimeMBS.Make(2000, 1000)
Dim timeRange As CMTimeRangeMBS = CMTimeRangeMBS.Make(startTime, duration)
Dim looper As New AVPlayerLooperMBS(player, itemToLoop, timeRange)

// Perform any other set up operations like setting AVPlayerItemDataOutputs on the looping item replicas
// Start playback

// itemToLoop between 5s and 7s plays repeatedly
// To end the looping
// Player will play through the end of the current looping item
The same result can be accomplished with AVQueuePlayer directly, but AVPlayerLooper provides a simpler interface to loop a single AVPlayerItem with an option to specify a time range. AVPlayerLooper only supports looping for forward playback (positive player rate). Behavior is undefined for negative player rate.

Note that the transition at the loop point is not guaranteed to be gapless.

Requires macOS 10.13, iOS 10.0 or newer.


Constant Value Description
StatusCancelled 3 Indicates that the looper is no longer looping because -disableLooping was invoked.
StatusFailed 2 Indicates that the looper is not able to perform looping playback because of an error. The error is described by the value of the error property.
StatusReady 1 Indicates that the looper is ready for looping playback.
StatusUnknown 0 Indicates that the status of the looper is not yet known.

This class has no sub classes.

Blog Entries

Xojo Developer Magazine

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

AVPlayerLayerMBS   -   AVPlayerMBS

💬 Ask a question or report a problem
The biggest plugin in space...

Start Chat