You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -71,6 +72,7 @@ Try the online demo here : [🎥 Live Demo](https://kdroidfilter.github.io/Compo
71
72
-**Fullscreen Mode**: Toggle between windowed and fullscreen playback modes.
72
73
-**Picture-in-Picture (PiP)**: Continue watching in a floating window on Android (8.0+) and iOS.
73
74
-**Audio Mode**: Configure audio interruption behavior and iOS silent switch handling.
75
+
-**Video Caching**: Opt-in disk caching for video data on Android and iOS, ideal for scroll-based UIs.
74
76
-**Error handling** Simple error handling for network or playback issues.
75
77
76
78
## ✨ Supported Video Formats
@@ -549,6 +551,40 @@ val playerState = rememberVideoPlayerState(
549
551
> [!NOTE]
550
552
> Audio mode is only effective on **Android** and **iOS**. On desktop and web, the parameter is accepted but ignored.
551
553
554
+
### 💾 Video Caching
555
+
556
+
You can enable disk-based caching so that video data fetched via `openUri()` is stored locally. Subsequent plays of the same URL load from the cache instead of re-downloading, which is especially useful for scroll-based UIs like TikTok/Reels-style `VerticalPager`.
557
+
558
+
```kotlin
559
+
val playerState = rememberVideoPlayerState(
560
+
cacheConfig =CacheConfig(
561
+
enabled =true,
562
+
maxCacheSizeBytes =200L*1024L*1024L// 200 MB
563
+
)
564
+
)
565
+
```
566
+
567
+
| Parameter | Description | Default |
568
+
| :--- | :--- | :---: |
569
+
|`enabled`| Whether caching is active |`false`|
570
+
|`maxCacheSizeBytes`| Maximum disk space for the cache (LRU eviction) |`100 MB`|
571
+
572
+
To clear the cache programmatically:
573
+
574
+
```kotlin
575
+
playerState.clearCache()
576
+
```
577
+
578
+
| Platform | Status | Implementation |
579
+
| :--- | :---: | :--- |
580
+
|**Android**| ✅ | Media3 `SimpleCache` with `LeastRecentlyUsedCacheEvictor`|
581
+
|**iOS**| ✅ |`NSURLCache` with increased disk capacity |
582
+
|**Desktop**| ❌ | No-op (config accepted but ignored) |
583
+
|**Web**| ❌ | No-op (browser manages its own HTTP cache) |
584
+
585
+
> [!NOTE]
586
+
> Caching only applies to URIs opened via `openUri()`. Local files and assets are not cached. The cache is shared across all player instances, so multiple players benefit from the same cached data.
0 commit comments