cacheVideo method
Caches a video using the specified mediaId. Optionally, a customPlayerId
and languageCode can be provided to customize the pre-caching process.
This method only works on Android; on iOS and web platforms, it will output a message indicating lack of support and return early.
mediaId: The unique identifier of the media to be cached.customPlayerId: Optional identifier for a custom player.languageCode: Optional language code for the media.
Usage:
final config = Config(cacheSizeInMb: 10);
final cacheManager = VdoPreCacheManager(config: config);
cacheManager.cacheVideo("sampleMediaId");
Implementation
void cacheVideo(String mediaId,
{String? customPlayerId, String? languageCode}) {
if (Platform.isIOS) {
debugPrint('API not supported on iOS platform');
return;
}
if (kIsWeb) {
debugPrint('API not supported on web platform');
return;
}
final cacheSizeInMb = config.cacheSizeInMb;
final Map<String, Object?> vdoPrecacheReqMap = {
"mediaId": mediaId,
"vdoCustomPlayerId": customPlayerId,
"vdoLanguageCode": languageCode,
"cacheSizeInMb": cacheSizeInMb,
};
_methodChannel.invokeMethod("vdoPlayerPreCaching", vdoPrecacheReqMap);
}