MeeduPlayerController constructor

MeeduPlayerController({
  1. ScreenManager screenManager = const ScreenManager(),
  2. Color colorTheme = Colors.redAccent,
  3. Widget? loadingWidget,
  4. bool controlsEnabled = true,
  5. bool manageWakeLock = true,
  6. bool manageBrightness = true,
  7. bool showLogs = true,
  8. bool excludeFocus = true,
  9. bool autoHideControls = true,
  10. String? errorText,
  11. ControlsStyle controlsStyle = ControlsStyle.primary,
  12. Widget? header,
  13. Widget? bottomRight,
  14. List<BoxFit> fits = const [BoxFit.contain, BoxFit.cover, BoxFit.fill, BoxFit.fitHeight, BoxFit.fitWidth, BoxFit.scaleDown],
  15. bool pipEnabled = false,
  16. CustomIcons customIcons = const CustomIcons(),
  17. EnabledButtons enabledButtons = const EnabledButtons(),
  18. EnabledControls enabledControls = const EnabledControls(),
  19. EnabledOverlays enabledOverlays = const EnabledOverlays(),
  20. CustomCallbacks customCallbacks = const CustomCallbacks(),
  21. Responsive? responsive,
  22. dynamic durations = const Durations(),
  23. void onVideoPlayerClosed()?,
  24. 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_plus 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 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;
    }
  }
}