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.
Param | Type | Description | Android | iOS | Windows |
---|---|---|---|---|---|
options | MetadataOptions | The options | |||
options.ratingType | RatingType | The rating type | β | β | β |
options.forwardJumpInterval | number | The interval in seconds for the jump forward buttons (if only one is given then we use that value for both) | β | β | β |
options.backwardJumpInterval | number | The interval in seconds for the jump backward buttons (if only one is given then we use that value for both) | β | β | β |
options.stoppingAppPausesPlayback | boolean | Whether the player will be destroyed when the app closes | β | β | β |
options.alwaysPauseOnInterruption | boolean | Whether the remote-duck event will be triggered on every interruption | β | β | β |
options.likeOptions | FeedbackOptions | The media controls that will be enabled | β | β | β |
options.dislikeOptions | FeedbackOptions | The media controls that will be enabled | β | β | β |
options.bookmarkOptions | FeedbackOptions | The media controls that will be enabled | β | β | β |
options.capabilities | Capability[] | The media controls that will be enabled | β | β | β |
options.notificationCapabilities | Capability[] | The buttons that it will show in the notification. Defaults to data.capabilities | β | β | β |
options.compactCapabilities | Capability[] | The buttons that it will show in the compact notification | β | β | β |
options.icon | Resource Object | The notification iconΒΉ | β | β | β |
options.playIcon | Resource Object | The play iconΒΉ | β | β | β |
options.pauseIcon | Resource Object | The pause iconΒΉ | β | β | β |
options.stopIcon | Resource Object | The stop iconΒΉ | β | β | β |
options.previousIcon | Resource Object | The previous iconΒΉ | β | β | β |
options.nextIcon | Resource Object | The next iconΒΉ | β | β | β |
options.rewindIcon | Resource Object | The jump backward iconΒΉ | β | β | β |
options.forwardIcon | Resource Object | The jump forward iconΒΉ | β | β | β |
options.color | number | The 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.
Param | Type | Description |
---|---|---|
seconds | number | The position in seconds |
setVolume(volume)
β
Sets the volume of the player.
Param | Type | Description |
---|---|---|
volume | number | The 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
Param | Type | Description |
---|---|---|
rate | number | The 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>