setGlobalCacheFolderPath method

Future<BoolMsg> setGlobalCacheFolderPath(
  1. StringMsg postfixPath
)

在短视频播放场景中,视频文件的本地缓存是很刚需的一个特性,对于普通用户而言,一个已经看过的视频再次观看时,不应该再消耗一次流量。 @格式支持:SDK 支持 HLS(m3u8) 和 MP4 两种常见点播格式的缓存功能。 @开启时机:SDK 并不默认开启缓存功能,对于用户回看率不高的场景,也并不推荐您开启此功能。 @开启方式:全局生效,在使用播放器开启。开启此功能需要配置两个参数:本地缓存目录及缓存大小。

该缓存路径默认设置到app沙盒目录下,postfixPath只需要传递相对缓存目录即可,不需要传递整个绝对路径。 e.g. postfixPath = 'testCache' Android 平台:视频将会缓存到sdcard的Android/data/your-pkg-name/files/testCache 目录。 iOS 平台:视频将会缓存到沙盒的Documents/testCache 目录。 @param postfixPath 缓存目录 @return true 设置成功 false 设置失败

Implementation

Future<BoolMsg> setGlobalCacheFolderPath(StringMsg postfixPath) async {
  final String pigeonVar_channelName = 'dev.flutter.pigeon.super_player.TXFlutterSuperPlayerPluginAPI.setGlobalCacheFolderPath$pigeonVar_messageChannelSuffix';
  final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
    pigeonVar_channelName,
    pigeonChannelCodec,
    binaryMessenger: pigeonVar_binaryMessenger,
  );
  final List<Object?>? pigeonVar_replyList =
      await pigeonVar_channel.send(<Object?>[postfixPath]) as List<Object?>?;
  if (pigeonVar_replyList == null) {
    throw _createConnectionError(pigeonVar_channelName);
  } else if (pigeonVar_replyList.length > 1) {
    throw PlatformException(
      code: pigeonVar_replyList[0]! as String,
      message: pigeonVar_replyList[1] as String?,
      details: pigeonVar_replyList[2],
    );
  } else if (pigeonVar_replyList[0] == null) {
    throw PlatformException(
      code: 'null-error',
      message: 'Host platform returned null value for non-null return value.',
    );
  } else {
    return (pigeonVar_replyList[0] as BoolMsg?)!;
  }
}