Configuring the player
Table of contents
The Flowplayer API
FPFlowplayer
tvOS SDK exposes the same functionality and behaves as it’s counterpart on iOS SDK FPFlowplayerViewController
. The only difference is that FPFlowplayer
is not a UIViewController
and does not handle any UI.
Available properties
All available properties of FPFlowplayer
:
Property | Type | Description |
---|---|---|
enableAnalytics |
Bool |
Flag to enable analytics by Flowplayer (enabled by default). |
autoStart |
Bool |
Flag that indicates if media playback should auto start when the player is ready to play. |
playbackStarted |
Bool |
Flag that indicates if media playback has started. |
isShowingAds |
Bool |
Flag that indicates if the player is displaying Ads at the current moment. |
currentSubtitleTrack |
FPSubtitleTrack? |
Currently selected subtitle track for the media playback. |
subtitleTracks |
[FPSubtitleTrack] |
All available FPSubtitleTracks of the current FPMedia . |
currentAudioTrack |
FPAudioTrack? |
Currently selected audio track for the media playback. |
audioTracks |
[FPAudioTrack] |
All available FPAudioTracks of the current FPMedia . |
controller |
UIViewController |
UIViewController where the instance AVPlayer is attached to. |
player |
AVPlayer |
Current AVPlayer instance that is handled by FPFlowplayer . |
delegate |
FPFlowplayerDelegate? |
The object that acts as the delegate of the FPFlowplayer object. |
media |
FPMedia? |
Current media item loaded into the player. |
duration |
Int64 |
Total duration of the current media item. |
currentPosition |
Int64 |
Current position of media playback. |
currentSpeed |
Float |
Current playback speed of media playback. |
Available methods
All available methods of FPFlowplayer
:
func load(external media: FPExternalMedia, autoStart: Bool)
Description
Load external media into AVPlayer
. This method needs to be called on an already presented UIViewController
where the instance of AVPlayer
is attached to.
If called before the UIViewController
was presented:
- Ads will fail to load.
- Media playback might return a
FPError
. - Weird behavior of
FPFlowplayer
might occur.
Parameters
external
: FPExternalMedia type of FPMedia.
autoStart
: Start the playback as soon as the media loaded.
func load(flowplayer media: FPFlowplayerMedia, autoStart: Bool)
Description
Load flowplayer media into AVPlayer
. This method needs to be called on an already presented UIViewController
where the instance of AVPlayer
is attached to.
If called before the UIViewController
was presented:
- Ads will fail to load.
- Media playback might return a
FPError
. - Weird behavior of
FPFlowplayer
might occur.
Parameters
flowplayer
: FPFlowplayerMedia type of FPMedia.
autoStart
: Start the playback as soon as the media loaded.
@discardableResult
func reload() -> Bool
Description
Reload the current media playback. This action will destroy the current session and refetch and load the every asset again.
Returns
Boolean indicating if media was reloaded.
func pause()
Description Pause the current media playback.
func play()
Description
Start/Resume the current media playback. If the playback has completed, then seek back to the beginning and start again.
func stop()
Description
Stop the current media playback. The current media session will be terminated and cleared.
func mute(_ state: Bool)
Description
Mute the current media playback.
Parameters
state
: If true will mute the current sound of the media playback.
func setVolume(_ volume: Float)
Description
Set the volume of the current media playback.
Parameters
volume
: Sound volume represented from 0.0 to 1.0.
func seek(_ position: Int64)
Description
Seek to the desired position of the current media playback.
Parameters
position
: Position of media playback.
func setSpeed(_ speed: Float)
Description
Set the playback rate/speed ot the current media playback.
Parameters
speed
: Speed of media playback.
func setAudioTrack(_ id: Int)
Description
Sets a new audio track for the media.
Parameters
id
: The id of the track to select.
func setSubtitleTrack(_ id: Int)
Description
Sets a new subtitle track for the media.
Parameters
id
: The id of the track to select.