MeeduPlayerController constructor
MeeduPlayerController({
- ScreenManager screenManager = const ScreenManager(),
- Color colorTheme = Colors.redAccent,
- Widget? loadingWidget,
- bool controlsEnabled = true,
- bool manageWakeLock = true,
- bool manageBrightness = true,
- bool showLogs = true,
- bool excludeFocus = true,
- bool autoHideControls = true,
- String? errorText,
- ControlsStyle controlsStyle = ControlsStyle.primary,
- Widget? header,
- Widget? bottomRight,
- List<
BoxFit> fits = const [BoxFit.contain, BoxFit.cover, BoxFit.fill, BoxFit.fitHeight, BoxFit.fitWidth, BoxFit.scaleDown], - bool pipEnabled = false,
- CustomIcons customIcons = const CustomIcons(),
- EnabledButtons enabledButtons = const EnabledButtons(),
- EnabledControls enabledControls = const EnabledControls(),
- EnabledOverlays enabledOverlays = const EnabledOverlays(),
- CustomCallbacks customCallbacks = const CustomCallbacks(),
- Responsive? responsive,
- Durations durations = const meeduDurations.Durations(),
- void onVideoPlayerClosed()?,
- BoxFit? initialFit,
creates an instance of MeeduPlayerController
screenManager
the device orientations and overlays
controlsEnabled
if the player must show the player controls
manageWakeLock
if the player should use wakelock
errorText
message to show when the load process failed
Implementation
MeeduPlayerController({
this.screenManager = const ScreenManager(),
this.colorTheme = Colors.redAccent,
Widget? loadingWidget,
this.controlsEnabled = true,
this.manageWakeLock = true,
this.manageBrightness = true,
this.showLogs = true,
this.excludeFocus = true,
this.autoHideControls = true,
String? errorText,
this.controlsStyle = ControlsStyle.primary,
this.header,
this.bottomRight,
this.fits = const [
BoxFit.contain,
BoxFit.cover,
BoxFit.fill,
BoxFit.fitHeight,
BoxFit.fitWidth,
BoxFit.scaleDown
],
this.pipEnabled = false,
this.customIcons = const CustomIcons(),
this.enabledButtons = const EnabledButtons(),
this.enabledControls = const EnabledControls(),
this.enabledOverlays = const EnabledOverlays(),
this.customCallbacks = const CustomCallbacks(),
Responsive? responsive,
this.durations = const meeduDurations.Durations(),
this.onVideoPlayerClosed,
BoxFit? initialFit,
}) : _videoFit = Rx(initialFit ?? BoxFit.fill) {
if (responsive != null) {
this.responsive = responsive;
}
if (!manageBrightness) {
enabledControls = enabledControls.copyWith(brightnessSwipes: false);
}
if (initialFit == null) {
getUserPreferenceForFit();
}
_errorText = errorText;
tag = DateTime.now().microsecondsSinceEpoch.toString();
this.loadingWidget = loadingWidget ??
SpinKitWave(
size: 30,
color: colorTheme,
);
if ((UniversalPlatform.isWindows ||
UniversalPlatform.isLinux ||
UniversalPlatform.isMacOS ||
UniversalPlatform.isWeb)) {
desktopOrWeb = true;
}
if ((defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.android)) {
mobileControls = true;
}
//check each
if (!desktopOrWeb && enabledControls.volumeSwipes) {
VolumeController().listener((newVolume) {
volume.value = newVolume;
});
}
_playerEventSubs = onPlayerStatusChanged.listen(
(PlayerStatus status) {
if (status == PlayerStatus.playing) {
if (manageWakeLock) {
WakelockPlus.enable();
}
} else {
if (manageWakeLock) {
WakelockPlus.disable();
}
}
},
);
_pipAvailable.value = false;
if (pipEnabled) {
if (UniversalPlatform.isAndroid) {
// get the OS version and check if pip is available
_pipManager.checkPipAvailable().then(
(value) => _pipAvailable.value = value,
);
// listen the pip mode changes
_pipModeWorker = _pipManager.isInPipMode.ever(_onPipModeChanged);
} else if (UniversalPlatform.isDesktop) {
_pipAvailable.value = true;
}
}
}