Skip to main content
Version: 1.3.x

Standalone Player

This option allows you to trigger at will our stories player, from a button click for example.

Layout

  1. Create you own ViewController and import JoinStories library
import JoinStoriesSDK

For easy readable layout and constraints, you can use SnapKit. If you want to style the layout the same way, just import SnapKit library

import SnapKit

or set your constraints programmatically with anchors.

  1. Create any UIControl (for example a UIButton) with its target action
button.addTarget(self, action: #selector(_your_method_name_), for: .touchUpInside)

Trigger

To start the player, you need to call the startPlayer method:

JoinStories.startPlayer(config: "your_standalone_config", completion: { 
// your_completion_block_for_stories_fetch
...
}, onDismiss: { state in
// dismiss_code (we can present an alert)
})
ParameterTypeRequiredDescription
configJoinStoriesStandaloneConfigYESThe configuration object, that requires at least the JOIN Stories alias you were given
completionStoriesCompletionHandlerYESCompletion block called to handle stories API fetch. Can result in success or error.
onDismiss((StoryPlayer.DismissPlayer) -> Void)?NOCompletion block called when the StoryPlayer view is dismissed. Default value is nil

StoryPlayer.DismissPlayer has two possible states:

  • manual : triggered when the cross is clicked or swiped down. Default value
  • auto : triggered when the story is finished or when you go back to the first story

Configuration

You can fine tune SDK behavior and UI, by specifying optional values on JoinStoriesStandaloneConfig.

Available configuration parameters:

NameTypeDefault ValueDescription
aliasStringYESThe Join Stories alias you were given to configure your integration
requestTimeoutIntervalTimeInterval60Timeout used for the stories fetching network requests (call and read)
playerBackgroundColorUIColorUIColor.blackColor of the player's background, if the player height is smaller than screen dimensions
playerStandaloneAnimationOriginPlayerStandaloneAnimationOrigin.bottomDirection from where the custom transition comes from in standonlone mode for StoryPlayer. Enum cases are: default, top, topLeft, topRight, bottom, bottomLeft, bottomRight
playerVerticalAnchorPlayerVerticalAnchor.bottomIf the player's height is smaller than screen height, anchor it to the top or bottom of the screen
playerShowShareButtonBooleantrueChange the visibility of the share button displayed on the Player view
playerClosingButtonBooleantrueChange the visibility of the close button displayed on the Player view
playerHorizontalMarginsInt0Apply the margin to the left and right of the player view. To maintain ratio, it also changes the height of the player view.
playerCornerRadiusInt0Apply radius to the 4 corners of the player view
playerProgressBarDefaultColorString?nilChange the background color of the progress bar in the player view. If no value or nil is filled, the default color will be used. Format is ##RRGGBB or #RRGGBBAA
playerProgressBarFillColorString?nilChange the fill color of the progress bar in the player view. If no value or nil is filled, the default color will be used. Format is ##RRGGBB or #RRGGBBAA
playerProgressBarThicknessInt?nilChange the thickness of the progress bar in the player view. If no value or nil is filled, the default thickness will be used.
playerProgressBarRadiusInt?nilChange the radius of the progress bar in the player view. If no value or nil is filled, the default thickness will be used. Radius will be applied to the 4 corners.

Stop player

To stop the player programmatically, you just need to call

JoinStories.stopPlayer()