public class FlowplayerView implements LifecycleListener, Flowplayer, Flowplayer.StateListener
The core component of the Flowplayer SDK. This view is the actual player view.
It is recommend to use class FlowplayerSupportFragment
or class FlowplayerFragment
instead of class FlowplayerView
when possible, in order to automatically handle lifecycle events and orientation changes.
For more control over the player's behaviour, class FlowplayerView
can also be used directly in a parent container. In that case, however, it is important that the application
make sure to map the container activity's/fragment's lifecycle to the PlayerView.
If the container activity/fragment implements androidx.lifecycle.LifecycleOwner, then this is very easy to achieve using class FlowplayerLifecycleObserver
.
Otherwise, the container activity/fragment should manually call the lifecycle related methods onStart
, onResume
, onPause
, onStop
, and onDestroy
.
Constructor and Description |
---|
FlowplayerView(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
The core component of the Flowplayer SDK. This view is the actual player view.
It is recommend to use
class FlowplayerSupportFragment or class FlowplayerFragment instead of class FlowplayerView
when possible, in order to automatically handle lifecycle events and orientation changes.
For more control over the player's behaviour, class FlowplayerView can also be used directly in a parent container. In that case, however, it is important that the application
make sure to map the container activity's/fragment's lifecycle to the PlayerView. |
FlowplayerView(android.content.Context context,
android.util.AttributeSet attrs)
The core component of the Flowplayer SDK. This view is the actual player view.
It is recommend to use
class FlowplayerSupportFragment or class FlowplayerFragment instead of class FlowplayerView
when possible, in order to automatically handle lifecycle events and orientation changes.
For more control over the player's behaviour, class FlowplayerView can also be used directly in a parent container. In that case, however, it is important that the application
make sure to map the container activity's/fragment's lifecycle to the PlayerView. |
FlowplayerView(android.content.Context context)
The core component of the Flowplayer SDK. This view is the actual player view.
It is recommend to use
class FlowplayerSupportFragment or class FlowplayerFragment instead of class FlowplayerView
when possible, in order to automatically handle lifecycle events and orientation changes.
For more control over the player's behaviour, class FlowplayerView can also be used directly in a parent container. In that case, however, it is important that the application
make sure to map the container activity's/fragment's lifecycle to the PlayerView. |
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(EventListener listener)
Adds an event listener.
|
long |
getCurrentPosition()
Returns the player's current position (in seconds).
|
long |
getDuration()
Returns the current media's duration (in seconds).
|
Flowplayer.State |
getPlaybackState()
Returns the player's current playback state.
|
boolean |
getUseControls()
Returns true if the player is set to use the built-in controls. False, otherwise. The default value is true.
|
boolean |
isFullscreen()
Returns true if the player is currently in fullscreen. False, otherwise.
|
void |
mute(boolean state)
Tells the player to mute or unmute.
|
void |
onAdError(com.google.ads.interactivemedia.v3.api.AdErrorEvent event) |
void |
onAdEvent(com.google.ads.interactivemedia.v3.api.AdEvent event) |
protected void |
onAttachedToWindow() |
void |
onDestroy()
Triggered when the parent Activity's/Fragment's onDestroy() is called.
|
void |
onLoadingChanged(boolean isLoading) |
void |
onPause()
Triggered when the parent Activity's/Fragment's onPause() is called.
|
void |
onPlaybackParametersChanged(com.google.android.exoplayer2.PlaybackParameters playbackParameters) |
void |
onPlayerControlError(BuiltInControlException error) |
void |
onPlayerError(com.google.android.exoplayer2.ExoPlaybackException error) |
void |
onPlayerStateChanged(boolean playWhenReady,
int playbackState) |
void |
onPositionDiscontinuity(int reason) |
void |
onRepeatModeChanged(int repeatMode) |
void |
onResume()
Triggered when the parent Activity's/Fragment's onResume() is called.
|
void |
onSeekProcessed() |
void |
onShuffleModeEnabledChanged(boolean shuffleModeEnabled) |
void |
onStart()
Triggered when the parent Activity's/Fragment's onStart() is called.
|
void |
onStateChanged(Flowplayer.State previousState,
Flowplayer.State currentState)
Called every time the playback state changes.
|
void |
onStop()
Triggered when the parent Activity's/Fragment's onStop() is called.
|
void |
onTimelineChanged(com.google.android.exoplayer2.Timeline timeline,
java.lang.Object manifest,
int reason) |
void |
onTracksChanged(com.google.android.exoplayer2.source.TrackGroupArray trackGroups,
com.google.android.exoplayer2.trackselection.TrackSelectionArray trackSelections) |
void |
onVolumeChanged(float volume) |
void |
pause()
Tells the player to pause the playback. If the player is not yet ready, then the playback will remain paused after the player is prepared.
|
void |
play()
Tells the player to start the playback. If the player is not yet ready, then the playback will start as soon the player is prepared.
|
void |
prepare(FlowplayerVideo video,
boolean autoStart)
Prepares the player with a
class FlowplayerVideo . |
void |
prepare(ExternalVideo video,
boolean autoStart)
Prepares the player with a
class ExternalVideo . |
void |
reload()
If the player was previously prepared but the playback has stopped unexpected, calling this method will try to prepare the player again with the
previously specified video.
|
void |
removeEventListener(EventListener listener)
Removes a previously added event listener.
|
void |
seek(long position)
Tells the player to seek to a new position.
|
void |
setControlConfig(PlayerControlConfig config)
Sets optional control configurations. Build config using
class PlayerControlConfig.Builder . |
void |
setFullscreen(boolean fullscreen)
Toggles the player's fullscreen state. The result is also affected by whether
setFullscreenControlOrientation is set to true (by default it is true).
If setFullscreenControlOrientation is set to true and setFullscreen is called, then the device's orientation will automatically change to
landscape for fullscreen and to portrait for non-fullscreen. |
void |
setFullscreen(boolean fullscreen,
java.lang.Integer requestedOrientation)
Toggles the player's fullscreen state.
|
void |
setFullscreenControlOrientation(boolean controlOrientation)
Tells the player whether or not toggling the fullscreen state should also change the device's orientation.
|
void |
setFullscreenManager(FullscreenManager manager)
Sets a custom
interface FullscreenManager to dictate how fullscreen should handled. |
void |
setSpeed(float speed)
Sets a new playback speed.
|
void |
setUseControls(boolean useControls)
Tells the player whether or not it should use the built-in controls
|
void |
setVolume(float volume)
Adjusts volume.
|
void |
stop()
Tells the player to stop the playback. This will reset the player and in order to start playback again, the player needs to be again prepared.
|
onDestroy, onPause, onResume, onStart, onStop
addEventListener, getCurrentPosition, getDuration, getPlaybackState, getUseControls, isFullscreen, mute, pause, play, prepare, prepare, reload, removeEventListener, seek, setControlConfig, setFullscreen, setFullscreen, setFullscreenControlOrientation, setFullscreenManager, setSpeed, setUseControls, setVolume, stop
onStateChanged
@JvmOverloads public FlowplayerView(@NotNull android.content.Context context, @Nullable android.util.AttributeSet attrs, int defStyleAttr)
The core component of the Flowplayer SDK. This view is the actual player view.
It is recommend to use class FlowplayerSupportFragment
or class FlowplayerFragment
instead of class FlowplayerView
when possible, in order to automatically handle lifecycle events and orientation changes.
For more control over the player's behaviour, class FlowplayerView
can also be used directly in a parent container. In that case, however, it is important that the application
make sure to map the container activity's/fragment's lifecycle to the PlayerView.
If the container activity/fragment implements androidx.lifecycle.LifecycleOwner, then this is very easy to achieve using class FlowplayerLifecycleObserver
.
Otherwise, the container activity/fragment should manually call the lifecycle related methods onStart
, onResume
, onPause
, onStop
, and onDestroy
.
@JvmOverloads public FlowplayerView(@NotNull android.content.Context context, @Nullable android.util.AttributeSet attrs)
The core component of the Flowplayer SDK. This view is the actual player view.
It is recommend to use class FlowplayerSupportFragment
or class FlowplayerFragment
instead of class FlowplayerView
when possible, in order to automatically handle lifecycle events and orientation changes.
For more control over the player's behaviour, class FlowplayerView
can also be used directly in a parent container. In that case, however, it is important that the application
make sure to map the container activity's/fragment's lifecycle to the PlayerView.
If the container activity/fragment implements androidx.lifecycle.LifecycleOwner, then this is very easy to achieve using class FlowplayerLifecycleObserver
.
Otherwise, the container activity/fragment should manually call the lifecycle related methods onStart
, onResume
, onPause
, onStop
, and onDestroy
.
@JvmOverloads public FlowplayerView(@NotNull android.content.Context context)
The core component of the Flowplayer SDK. This view is the actual player view.
It is recommend to use class FlowplayerSupportFragment
or class FlowplayerFragment
instead of class FlowplayerView
when possible, in order to automatically handle lifecycle events and orientation changes.
For more control over the player's behaviour, class FlowplayerView
can also be used directly in a parent container. In that case, however, it is important that the application
make sure to map the container activity's/fragment's lifecycle to the PlayerView.
If the container activity/fragment implements androidx.lifecycle.LifecycleOwner, then this is very easy to achieve using class FlowplayerLifecycleObserver
.
Otherwise, the container activity/fragment should manually call the lifecycle related methods onStart
, onResume
, onPause
, onStop
, and onDestroy
.
protected void onAttachedToWindow()
public void onStart()
Triggered when the parent Activity's/Fragment's onStart() is called.
public void onResume()
Triggered when the parent Activity's/Fragment's onResume() is called.
public void onPause()
Triggered when the parent Activity's/Fragment's onPause() is called.
public void onStop()
Triggered when the parent Activity's/Fragment's onStop() is called.
public void onDestroy()
Triggered when the parent Activity's/Fragment's onDestroy() is called.
public void setControlConfig(@NotNull PlayerControlConfig config)
Sets optional control configurations. Build config using class PlayerControlConfig.Builder
.
config
- Contains information about optional control features.class PlayerControlConfig.Builder
public void prepare(@NotNull FlowplayerVideo video, boolean autoStart)
Prepares the player with a class FlowplayerVideo
.
video
- Contains information about the media to be played.autoStart
- If true, the playback will start automatically as soon as the player is prepared. The default is true.class FlowplayerVideo
public void prepare(@NotNull ExternalVideo video, boolean autoStart)
Prepares the player with a class ExternalVideo
.
video
- Contains information about the media to be played.autoStart
- If true, the playback will start automatically as soon as the player is prepared. The default is true.class ExternalVideo
public void reload()
If the player was previously prepared but the playback has stopped unexpected, calling this method will try to prepare the player again with the previously specified video.
public void play()
Tells the player to start the playback. If the player is not yet ready, then the playback will start as soon the player is prepared.
public void pause()
Tells the player to pause the playback. If the player is not yet ready, then the playback will remain paused after the player is prepared.
public void stop()
Tells the player to stop the playback. This will reset the player and in order to start playback again, the player needs to be again prepared.
public void mute(boolean state)
Tells the player to mute or unmute.
state
- True to mute the player, false to bring it back to the system volume.public void setSpeed(float speed)
Sets a new playback speed.
speed
- The factor by which playback will be sped up. Must be greater than zero.public void setVolume(float volume)
Adjusts volume.
volume
- Volume level in scale 0.0f - 1.0f.public void seek(long position)
Tells the player to seek to a new position.
position
- The position (in seconds) to which the player should seek.public long getDuration()
Returns the current media's duration (in seconds).
public long getCurrentPosition()
Returns the player's current position (in seconds).
@NotNull public Flowplayer.State getPlaybackState()
Returns the player's current playback state.
public boolean isFullscreen()
Returns true if the player is currently in fullscreen. False, otherwise.
public void setFullscreen(boolean fullscreen)
Toggles the player's fullscreen state. The result is also affected by whether setFullscreenControlOrientation
is set to true (by default it is true).
If setFullscreenControlOrientation
is set to true and setFullscreen
is called, then the device's orientation will automatically change to
landscape for fullscreen and to portrait for non-fullscreen.
If setFullscreenControlOrientation
is set to false, then the device's orientation will not be affected by the player's fullscreen state changes.
fullscreen
- True to enter fullscreen, false to exit.setFullscreenControlOrientation
,
setFullscreenControlOrientation
,
setFullscreen
,
setFullscreenControlOrientation
public void setFullscreen(boolean fullscreen, @Nullable java.lang.Integer requestedOrientation)
Toggles the player's fullscreen state.
fullscreen
- True to enter fullscreen, false to exit.requestedOrientation
- If set, it will request the activity to change to the specified orientation. Should be one of orientation values defined in android.content.pm.ActivityInfo.public void setFullscreenManager(@NotNull FullscreenManager manager)
Sets a custom interface FullscreenManager
to dictate how fullscreen should handled.
interface FullscreenManager
public void setFullscreenControlOrientation(boolean controlOrientation)
Tells the player whether or not toggling the fullscreen state should also change the device's orientation.
controlOrientation
- If true, the activity that contains the player will be rotated to landscape every time the player enters fullscreenand to portrait every time the player exits fullscreen. If set to false, the activity's orientation will not be affected by the player's fullscreen state.The default value is true.public void setUseControls(boolean useControls)
Tells the player whether or not it should use the built-in controls
useControls
- If true, the player will use the built-in controls. Otherwise, no controls will be shown automatically. The default value is true.public boolean getUseControls()
Returns true if the player is set to use the built-in controls. False, otherwise. The default value is true.
public void addEventListener(@NotNull EventListener listener)
Adds an event listener.
public void removeEventListener(@NotNull EventListener listener)
Removes a previously added event listener.
public void onStateChanged(@NotNull Flowplayer.State previousState, @NotNull Flowplayer.State currentState)
Called every time the playback state changes.
previousState
- The previous state before it changed to its current one.currentState
- The player's new playback state.public void onPlayerControlError(@NotNull BuiltInControlException error)
public void onPlaybackParametersChanged(@NotNull com.google.android.exoplayer2.PlaybackParameters playbackParameters)
public void onSeekProcessed()
public void onTracksChanged(@Nullable com.google.android.exoplayer2.source.TrackGroupArray trackGroups, @Nullable com.google.android.exoplayer2.trackselection.TrackSelectionArray trackSelections)
public void onPlayerError(@NotNull com.google.android.exoplayer2.ExoPlaybackException error)
public void onLoadingChanged(boolean isLoading)
public void onPositionDiscontinuity(int reason)
public void onRepeatModeChanged(int repeatMode)
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled)
public void onTimelineChanged(@Nullable com.google.android.exoplayer2.Timeline timeline, @Nullable java.lang.Object manifest, int reason)
public void onPlayerStateChanged(boolean playWhenReady, int playbackState)
public void onAdEvent(@NotNull com.google.ads.interactivemedia.v3.api.AdEvent event)
public void onAdError(@NotNull com.google.ads.interactivemedia.v3.api.AdErrorEvent event)
public void onVolumeChanged(float volume)