preparePlayerController method

  1. @override
Future<VlcPlayerController> preparePlayerController(
  1. {required AppModel appModel,
  2. required WidgetRef ref,
  3. required MediaItem item}
)
override

Get the player controller to be used when a media item is loaded up,

Implementation

@override
Future<VlcPlayerController> preparePlayerController({
  required AppModel appModel,
  required WidgetRef ref,
  required MediaItem item,
}) async {
  String dataSource = item.mediaIdentifier;
  int startTime = item.position;

  List<String> videoParams = [
    VlcVideoOptions.dropLateFrames(false),
    VlcVideoOptions.skipFrames(false),
  ];
  List<String> advancedParams = [
    '--start-time=$startTime',
    VlcAdvancedOptions.networkCaching(20000),
  ];
  List<String> soutParams = [
    '--start-time=$startTime',
    VlcStreamOutputOptions.soutMuxCaching(20000),
  ];
  List<String> audioParams = [
    '--audio-language=${appModel.targetLanguage.languageCode},${appModel.appLocale.languageCode}',
    '--sub-track=99999',
    if (appModel.playerUseOpenSLES) '--aout=opensles',
  ];

  return VlcPlayerController.network(
    dataSource,
    hwAcc: appModel.playerHardwareAcceleration ? HwAcc.auto : HwAcc.disabled,
    options: VlcPlayerOptions(
      advanced: VlcAdvancedOptions(advancedParams),
      audio: VlcAudioOptions(audioParams),
      sout: VlcStreamOutputOptions(soutParams),
      video: VlcVideoOptions(videoParams),
    ),
  );
}