Closed DizzyDuan closed 3 years ago
That's a very good question. Why was it closed?
@jenniestrongbow You can refer to my method
CacheManager cacheManager = VideoCacheManager.instance;
FileInfo fileInfo = await cacheManager.getFileFromCache(
widget.videoUrl,
ignoreMemCache: true,
);
if (fileInfo != null && fileInfo.source == FileSource.Cache) {
_controller = VideoPlayerController.file(fileInfo.file);
} else {
_controller = VideoPlayerController.network(widget.videoUrl);
}
await _controller.initialize().then((_) {
cacheManager.downloadFile(
widget.videoUrl,
key: widget.videoUrl,
force: true,
);
});
Thanks for the quick reply. Now, how can I stream a video using your cache manager?
I noticed there is a getFileStream method. I suppose it allows viewing a video before it is fully downloaded but I don't know how to use it with video player.
Thanks
Using flutter_cache_manager plug-in. My plan is to make sure it's completely downloaded. If you want to watch the video before downloading it completely, you need another solution. But also need to consider the cut-off situation, I can not provide you with a solution.
I can provide you with a reference plug-in to see if it is what you need. https://pub.flutter-io.cn/packages/cached_video_player
Fair enough. I love your plugin and I understand how it works now. I'll make sure I download the video upfront. Thanks!!!
Hi,
CacheManager cacheManager = VideoCacheManager.instance;
VideoCacheManager does not exist. Can you please explain how I can use this?
Thanks
I guess it should have been DefaultCacheManager();
import 'package:flutter_cache_manager/flutter_cache_manager.dart'
hide ImageCacheManager;
export 'package:flutter_cache_manager/flutter_cache_manager.dart'
hide ImageCacheManager;
class VideoCacheManager {
static const key = "anything";
static CacheManager instance = CacheManager(
Config(
key,
stalePeriod: const Duration(days: 7),
maxNrOfCacheObjects: 25,
repo: JsonCacheInfoRepository(databaseName: key),
),
);
}
You can also use the DefaultCacheManager
Thanks a lot!!!!!!!!!!
💬 Questions and Help
For questions or help we recommend checking: