setDataSource method

  1. @override
Future<void> setDataSource(
  1. int? textureId,
  2. DataSource dataSource
)
override

Set data source of video.

Implementation

@override
Future<void> setDataSource(int? textureId, DataSource dataSource) async {
  Map<String, dynamic>? dataSourceDescription;
  switch (dataSource.sourceType) {
    case DataSourceType.asset:
      dataSourceDescription = <String, dynamic>{
        'key': dataSource.key,
        'asset': dataSource.asset,
        'package': dataSource.package,
        'useCache': false,
        'maxCacheSize': 0,
        'maxCacheFileSize': 0,
        'showNotification': dataSource.showNotification,
        'title': dataSource.title,
        'author': dataSource.author,
        'imageUrl': dataSource.imageUrl,
        'notificationChannelName': dataSource.notificationChannelName,
        'overriddenDuration': dataSource.overriddenDuration?.inMilliseconds,
        'activityName': dataSource.activityName
      };
      break;
    case DataSourceType.network:
      dataSourceDescription = <String, dynamic>{
        'key': dataSource.key,
        'uri': dataSource.uri,
        'formatHint': dataSource.rawFormalHint,
        'headers': dataSource.headers,
        'useCache': dataSource.useCache,
        'maxCacheSize': dataSource.maxCacheSize,
        'maxCacheFileSize': dataSource.maxCacheFileSize,
        'cacheKey': dataSource.cacheKey,
        'showNotification': dataSource.showNotification,
        'title': dataSource.title,
        'author': dataSource.author,
        'imageUrl': dataSource.imageUrl,
        'notificationChannelName': dataSource.notificationChannelName,
        'overriddenDuration': dataSource.overriddenDuration?.inMilliseconds,
        'licenseUrl': dataSource.licenseUrl,
        'certificateUrl': dataSource.certificateUrl,
        'drmHeaders': dataSource.drmHeaders,
        'activityName': dataSource.activityName,
        'clearKey': dataSource.clearKey,
        'videoExtension': dataSource.videoExtension,
      };
      break;
    case DataSourceType.file:
      dataSourceDescription = <String, dynamic>{
        'key': dataSource.key,
        'uri': dataSource.uri,
        'useCache': false,
        'maxCacheSize': 0,
        'maxCacheFileSize': 0,
        'showNotification': dataSource.showNotification,
        'title': dataSource.title,
        'author': dataSource.author,
        'imageUrl': dataSource.imageUrl,
        'notificationChannelName': dataSource.notificationChannelName,
        'overriddenDuration': dataSource.overriddenDuration?.inMilliseconds,
        'activityName': dataSource.activityName,
        'clearKey': dataSource.clearKey
      };
      break;
  }
  await _channel.invokeMethod<void>(
    'setDataSource',
    <String, dynamic>{
      'textureId': textureId,
      'dataSource': dataSourceDescription,
    },
  );
  return;
}