From ab855d506bcd86401e4c3ac6ed8a5a70ce4d2142 Mon Sep 17 00:00:00 2001 From: OutdatedGuy Date: Tue, 12 Dec 2023 01:33:29 +0530 Subject: [PATCH] docs: added instructions for web platform (#5) --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95a2a5c..795f874 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Import the `cached_video_player_plus` package into your Dart file: import 'package:cached_video_player_plus/cached_video_player_plus.dart'; ``` -### 4. Use the package +### 4. Using the package (Android & iOS) #### If you are already using the [video_player] plugin @@ -78,6 +78,27 @@ return Scaffold( ); ``` +### 5. Using the package (Web) + +The web platform does not support caching. So, the plugin will use the +[video_player] plugin for the web platform. + +However, to achieve caching on the web platform, you can use the workaround +of defining `Cache-Control` headers in the `httpHeaders` parameter of the +`CachedVideoPlayerPlusController.network()` method. + +```dart +final controller = CachedVideoPlayerPlusController.network( + "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", + httpHeaders: { + "Cache-Control": "max-age=3600", + }, +)..initialize().then((value) { + controller.play(); + setState(() {}); + }); +``` + ## Credits This package is a cloned and modified version of the [cached_video_player]