start method
Starts the cache server and returns the VideoCacheServer instance.
Implementation
Future<VideoCacheServer> start() async {
Directory cacheDirectory = Directory(_cacheDir);
if (cacheDirectory.existsSync() && cacheDirectory.statSync().type != FileSystemEntityType.directory) {
throw AsyncError('The location which the cacheDir[$_cacheDir] indicates to is not a type of directory!', StackTrace.current);
}
cacheDirectory.createSync(recursive: true);
// 加载缓存信息
await _loadCacheInfo();
_server = await _serve(_address, _port, securityContext: securityContext);
_port = _server!.port;
_started = true;
if (quiet != true) {
log('Video Cache Server serving at http${securityContext == null ? "" : "s"}://${_server!.address.host}:${_server!.port}');
}
return this;
}