PlayerPool

abstract class PlayerPool<PLAYER : Any> @JvmOverloads constructor(@IntRange(from = 1) poolSize: Int = DEFAULT_POOL_SIZE)

Definition of a pool to provide PLAYER instance for the consumer.

Constructors

Link copied to clipboard
fun PlayerPool(@IntRange(from = 1) poolSize: Int = DEFAULT_POOL_SIZE)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open fun clear()

Destroy all available PLAYER instances in the pool.

Link copied to clipboard
abstract fun createPlayer(media: Media): PLAYER

Create a new PLAYER instance that can be used to play the media object.

Link copied to clipboard
abstract fun destroyPlayer(player: PLAYER)

Destroy the PLAYER instance. After this, the player must not be reused.

Link copied to clipboard
fun getPlayer(media: Media): PLAYER

Acquire a PLAYER that can be used to play the media from the pool. If there is no available instance in the pool, this method will create a new one.

Link copied to clipboard
fun putPlayer(media: Media, player: PLAYER): Boolean

Release an unused PLAYER to the pool. If the pool is already full, this method must destroy the PLAYER instance. Return true if the instance is successfully put back to the pool, or false otherwise.

Link copied to clipboard
open fun resetPlayer(player: PLAYER)

Reset the internal state of the player instance before putting it back to the pool.