Manual Player dismiss
You may want to dismiss the StoryPlayer on your own, without user interaction, for example on a back press event. To help you with that behavior, you have two options.
With StoryPlayer
The StoryPlayer object exposes:
- a isVisible property, indicating whether the player is currently displayed or not
- a dismiss() method, to force the play dismiss.
Example for a back press:
override fun onBackPressed() {
if (story_player.isVisible) {
story_player.dismiss()
} else {
super.onBackPressed()
}
}
With JoinStories
JoinStories object directly exposes a method to dismiss the player:
fun onPause() {
JoinStories.stopPlayer()
super.onPause()
}
That method checks if there is an active player, no need to check about it before calling it.