Skip to main content
Version: 2.1

Player

updateOptions(options)​

Updates the configuration for the components.

All parameters are optional. You also only need to specify the ones you want to update.

These parameters are different than the ones set using setupPlayer(). Parameters other than those listed below will not be applied.

Some parameters are unused depending on platform.

ParamTypeDescriptionAndroidiOSWindows
optionsMetadataOptionsThe options
options.ratingTypeRatingTypeThe rating typeβœ…βŒβŒ
options.forwardJumpIntervalnumberThe interval in seconds for the jump forward buttons (if only one is given then we use that value for both)βœ…βœ…βŒ
options.backwardJumpIntervalnumberThe interval in seconds for the jump backward buttons (if only one is given then we use that value for both)βœ…βœ…βœ…
options.stoppingAppPausesPlaybackbooleanWhether the player will be destroyed when the app closesβœ…βŒβŒ
options.alwaysPauseOnInterruptionbooleanWhether the remote-duck event will be triggered on every interruptionβœ…βŒβŒ
options.likeOptionsFeedbackOptionsThe media controls that will be enabledβŒβœ…βŒ
options.dislikeOptionsFeedbackOptionsThe media controls that will be enabledβŒβœ…βŒ
options.bookmarkOptionsFeedbackOptionsThe media controls that will be enabledβŒβœ…βŒ
options.capabilitiesCapability[]The media controls that will be enabledβœ…βœ…βœ…
options.notificationCapabilitiesCapability[]The buttons that it will show in the notification. Defaults to data.capabilitiesβœ…βŒβŒ
options.compactCapabilitiesCapability[]The buttons that it will show in the compact notificationβœ…βŒβŒ
options.iconResource ObjectThe notification iconΒΉβœ…βŒβŒ
options.playIconResource ObjectThe play iconΒΉβœ…βŒβŒ
options.pauseIconResource ObjectThe pause iconΒΉβœ…βŒβŒ
options.stopIconResource ObjectThe stop iconΒΉβœ…βŒβŒ
options.previousIconResource ObjectThe previous iconΒΉβœ…βŒβŒ
options.nextIconResource ObjectThe next iconΒΉβœ…βŒβŒ
options.rewindIconResource ObjectThe jump backward iconΒΉβœ…βŒβŒ
options.forwardIconResource ObjectThe jump forward iconΒΉβœ…βŒβŒ
options.colornumberThe notification color in an ARGB hexβœ…βŒβŒ

ΒΉ - The custom icons will only work in release builds

play()​

Plays or resumes the current track.

pause()​

Pauses the current track.

stop()​

Stops the current track.

seekTo(seconds)​

Seeks to a specified time position in the current track.

ParamTypeDescription
secondsnumberThe position in seconds

setVolume(volume)​

Sets the volume of the player.

ParamTypeDescription
volumenumberThe volume in a range from 0 to 1

getVolume()​

Gets the volume of the player (a number between 0 and 1).

Returns: Promise<number>

setRate(rate)​

Sets the playback rate

ParamTypeDescription
ratenumberThe playback rate where 1 is the regular speed

getRate()​

Gets the playback rate, where 1 is the regular speed.

Returns: Promise<number>

getDuration()​

Gets the duration of the current track in seconds.

Note: react-native-track-player is a streaming library, which means it slowly buffers the track and doesn't know exactly when it ends. The duration returned by this function is determined through various tricks and may not be exact or may not be available at all.

You should only trust the result of this function if you included the duration property in the Track Object.

Returns: Promise<number>

getPosition()​

Gets the position of the player in seconds.

Returns: Promise<number>

getBufferedPosition()​

Gets the buffered position of the player in seconds.

Returns: Promise<number>

getState()​

Gets the state of the player.

Returns: Promise<State>