BetterPlayerController class
Class used to control overall Better Player behavior. Main class to change state of Better Player.
Constructors
- BetterPlayerController(BetterPlayerConfiguration betterPlayerConfiguration, {BetterPlayerPlaylistConfiguration? betterPlayerPlaylistConfiguration, BetterPlayerDataSource? betterPlayerDataSource})
Properties
- betterPlayerAsmsAudioTrack → BetterPlayerAsmsAudioTrack?
-
Selected ASMS audio track
no setter
-
betterPlayerAsmsAudioTracks
→ List<
BetterPlayerAsmsAudioTrack> ? -
List of all possible audio tracks returned from ASMS stream
no setter
- betterPlayerAsmsTrack → BetterPlayerAsmsTrack?
-
Currently selected player track. Used only for HLS / DASH.
no setter
-
betterPlayerAsmsTracks
→ List<
BetterPlayerAsmsTrack> -
List of tracks available for current data source. Used only for HLS / DASH.
no setter
- betterPlayerConfiguration → BetterPlayerConfiguration
-
General configuration used in controller instance.
final
- betterPlayerControlsConfiguration → BetterPlayerControlsConfiguration
-
Controls configuration
no setter
- betterPlayerDataSource → BetterPlayerDataSource?
-
Currently used data source in player.
no setter
-
betterPlayerGlobalKey
→ GlobalKey<
State< ?StatefulWidget> > -
Getter of the GlobalKey
no setter
- betterPlayerPlaylistConfiguration → BetterPlayerPlaylistConfiguration?
-
Playlist configuration used in controller instance.
final
- betterPlayerSubtitlesSource → BetterPlayerSubtitlesSource?
-
Currently used subtitles source.
no setter
-
betterPlayerSubtitlesSourceList
→ List<
BetterPlayerSubtitlesSource> -
List of BetterPlayerSubtitlesSources.
no setter
-
controllerEventStream
→ Stream<
BetterPlayerControllerEvent> -
Stream of internal controller events. Shouldn't be used inside app. For
normal events, use eventListener.
no setter
- controlsAlwaysVisible → bool
-
Are controls always visible
no setter
- controlsEnabled → bool
-
Flag which determines if controls (UI interface) is shown. When false,
UI won't be shown (show only player surface).
no setter
-
controlsVisibilityStream
→ Stream<
bool> -
Stream which sends flag whenever visibility of controls changes
no setter
- eventListener → dynamic Function(BetterPlayerEvent)?
-
Defines a event listener where video player events will be send.
no setter
-
eventListeners
→ List<
dynamic Function(BetterPlayerEvent)?> -
Expose all active eventListeners
no setter
- hasCurrentDataSourceStarted → bool
-
Flag which determines whenever current data source has started.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFullScreen → bool
-
Flag used to store full screen mode state.
no setter
-
nextVideoTimeStream
→ Stream<
int?> -
no setter
- renderedSubtitle ↔ BetterPlayerSubtitle?
-
Currently displayed
BetterPlayerSubtitle
.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
subtitlesLines
↔ List<
BetterPlayerSubtitle> -
Subtitles lines for current data source.
getter/setter pair
- translations ↔ BetterPlayerTranslations
-
Currently used translations
getter/setter pair
- videoPlayerController ↔ VideoPlayerController?
-
Instance of video player controller which is adapter used to communicate
between flutter high level code and lower level native code.
getter/setter pair
Methods
-
addEventsListener(
dynamic eventListener(BetterPlayerEvent)) → void - Add event listener which listens to player events.
-
cancelNextVideoTimer(
) → void - Cancel next video timer. Used in playlist. Do not use manually.
-
clearCache(
) → Future< void> - Clear all cached data. Video player controller must be initialized to clear the cache.
-
disablePictureInPicture(
) → Future< void> ? - Disable Picture in Picture mode if it's enabled.
-
dispose(
{bool forceDispose = false}) → void -
Dispose BetterPlayerController. When
forceDispose
parameter is true, then autoDispose parameter will be overridden and controller will be disposed (if it wasn't disposed before). -
enablePictureInPicture(
GlobalKey< State< betterPlayerGlobalKey) → Future<StatefulWidget> >void> ? -
Enable Picture in Picture (PiP) mode.
betterPlayerGlobalKey
is required to open PiP mode in iOS. When device is not supported, PiP mode won't be open. -
enterFullScreen(
) → void - Enables full screen mode in player. This will trigger route change.
-
exitFullScreen(
) → void - Disables full screen mode in player. This will trigger route change.
-
getAspectRatio(
) → double? -
Get aspect ratio used in current video. If aspect ratio is null, then
aspect ratio from BetterPlayerConfiguration will be used. Otherwise
_overriddenAspectRatio
will be used. -
getFit(
) → BoxFit -
Get fit used in current video. If fit is null, then fit from
BetterPlayerConfiguration will be used. Otherwise
_overriddenFit
will be used. -
isBuffering(
) → bool? - Flag which determines whenever player is loading video data or not.
-
isLiveStream(
) → bool - Flag which determines whenever player is playing live data source.
-
isPictureInPictureSupported(
) → Future< bool> - Check if picture in picture mode is supported in this device.
-
isPlaying(
) → bool? - Flag which determines whenever player is playing or not.
-
isVideoInitialized(
) → bool? - Flag which determines whenever player data source has been initialized.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onPlayerVisibilityChanged(
double visibilityFraction) → void - Listener which handles state of player visibility. If player visibility is below 0.0 then video will be paused. When value is greater than 0, video will play again. If there's different handler of visibility then it will be used. If showNotification is set in data source or handleLifecycle is false then this logic will be ignored.
-
pause(
) → Future< void> - Stop video playback.
-
play(
) → Future< void> - Start video playback. Play will be triggered only if current lifecycle state is resumed.
-
playNextVideo(
) → void - Play next video form playlist. Do not use manually.
-
postEvent(
BetterPlayerEvent betterPlayerEvent) → void - Send player event. Shouldn't be used manually.
-
preCache(
BetterPlayerDataSource betterPlayerDataSource) → Future< void> -
PreCache a video. On Android, the future succeeds when
the requested size, specified in
BetterPlayerCacheConfiguration.preCacheSize, is downloaded or when the
complete file is downloaded if the file is smaller than the requested size.
On iOS, the whole file will be downloaded, since
maxCacheFileSize
is currently not supported on iOS. On iOS, the video format must be in this list: https://github.com/sendyhalim/Swime/blob/master/Sources/MimeType.swift -
removeEventsListener(
dynamic eventListener(BetterPlayerEvent)) → void - Remove event listener. This method should be called once you're disposing Better Player.
-
retryDataSource(
) → Future - Retry data source if playback failed.
-
seekTo(
Duration moment) → Future< void> - Move player to specific position/moment of the video.
-
setAppLifecycleState(
AppLifecycleState appLifecycleState) → void - Set current lifecycle state. If state is AppLifecycleState.resumed then player starts playing again. if lifecycle is in AppLifecycleState.paused state, then video playback will stop. If showNotification is set in data source or handleLifecycle is false then this logic will be ignored.
-
setAudioTrack(
BetterPlayerAsmsAudioTrack audioTrack) → void -
Set
audioTrack
in player. Works only for HLS or DASH streams. -
setAudioTracks(
dynamic tracks) → void -
setBetterPlayerControlsConfiguration(
BetterPlayerControlsConfiguration betterPlayerControlsConfiguration) → void -
Sets the new
betterPlayerControlsConfiguration
instance in the controller. -
setBetterPlayerGlobalKey(
GlobalKey< State< betterPlayerGlobalKey) → voidStatefulWidget> > - Set GlobalKey of BetterPlayer. Used in PiP methods called from controls.
-
setControlsAlwaysVisible(
bool controlsAlwaysVisible) → void - Setup controls always visible mode
-
setControlsEnabled(
bool enabled) → void - Enable/disable controls (when enabled = false, controls will be always hidden)
-
setControlsVisibility(
bool isVisible) → void - Show or hide controls manually
-
setLooping(
bool looping) → Future< void> - Enables/disables looping (infinity playback) mode.
-
setMixWithOthers(
bool mixWithOthers) → void - Enable or disable audio mixing with other sound within device.
-
setOverriddenAspectRatio(
double aspectRatio) → void - Setup overridden aspect ratio.
-
setOverriddenFit(
BoxFit fit) → void - Setup overridden fit.
-
setResolution(
String url) → void - Set different resolution (quality) for video
-
setSpeed(
double speed) → Future< void> - Set playback speed of video. Allows to set speed value between 0 and 2.
-
setTrack(
BetterPlayerAsmsTrack track) → void - Setup track parameters for currently played video. Can be only used for HLS or DASH data source.
-
setupDataSource(
BetterPlayerDataSource betterPlayerDataSource) → Future - Setup new data source in Better Player.
-
setupSubtitleSource(
BetterPlayerSubtitlesSource subtitlesSource, {bool sourceInitialize = false}) → Future< void> - Setup subtitles to be displayed from given subtitle source. If subtitles source is segmented then don't load videos at start. Videos will load with just in time policy.
-
setupTranslations(
Locale locale) → void - Setup translations for given locale. In normal use cases it shouldn't be called manually.
-
setVolume(
double volume) → Future< void> - Set volume of player. Allows values from 0.0 to 1.0.
-
startNextVideoTimer(
) → void - Start timer which will trigger next video. Used in playlist. Do not use manually.
-
stopPreCache(
BetterPlayerDataSource betterPlayerDataSource) → Future< void> -
Stop pre cache for given
betterPlayerDataSource
. If there was no pre cache started for givenbetterPlayerDataSource
then it will be ignored. -
toggleControlsVisibility(
bool isVisible) → void - Internal method, used to trigger CONTROLS_VISIBLE or CONTROLS_HIDDEN event once controls state changed.
-
toggleFullScreen(
) → void - Enables/disables full screen mode based on current fullscreen state.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
of(
BuildContext context) → BetterPlayerController - Get BetterPlayerController from context. Used in InheritedWidget.