From 47ddca62c9811f57e42c8bb1c87c4d15d92396d2 Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:54:10 -0800 Subject: [PATCH] fix: cacheSize name --- .../exoplayer/ReactExoplayerView.java | 17 ++++++++++------- .../exoplayer/ReactExoplayerViewManager.java | 8 ++++---- docs/pages/component/props.md | 1 + examples/basic/src/VideoPlayer.tsx | 6 +++--- src/VideoNativeComponent.ts | 2 +- src/types/video.ts | 1 + 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 3c4a8f066f..2bcf37cc1b 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -16,7 +16,6 @@ import android.os.Looper; import android.os.Message; import android.text.TextUtils; -import android.util.Log; import android.view.View; import android.view.Window; import android.view.accessibility.CaptioningManager; @@ -2042,7 +2041,7 @@ public void setHideShutterView(boolean hideShutterView) { exoPlayerView.setHideShutterView(hideShutterView); } - public void setBufferConfig(int newMinBufferMs, int newMaxBufferMs, int newBufferForPlaybackMs, int newBufferForPlaybackAfterRebufferMs, double newMaxHeapAllocationPercent, double newMinBackBufferMemoryReservePercent, double newMinBufferMemoryReservePercent, int bufferSize) { + public void setBufferConfig(int newMinBufferMs, int newMaxBufferMs, int newBufferForPlaybackMs, int newBufferForPlaybackAfterRebufferMs, double newMaxHeapAllocationPercent, double newMinBackBufferMemoryReservePercent, double newMinBufferMemoryReservePercent, int cacheSize) { minBufferMs = newMinBufferMs; maxBufferMs = newMaxBufferMs; bufferForPlaybackMs = newBufferForPlaybackMs; @@ -2050,11 +2049,15 @@ public void setBufferConfig(int newMinBufferMs, int newMaxBufferMs, int newBuffe maxHeapAllocationPercent = newMaxHeapAllocationPercent; minBackBufferMemoryReservePercent = newMinBackBufferMemoryReservePercent; minBufferMemoryReservePercent = newMinBufferMemoryReservePercent; - SimpleCache simpleCache = new SimpleCache(new File(this.getContext().getCacheDir(), "RNVCache"), new LeastRecentlyUsedCacheEvictor((long) bufferSize*1024*1024), new StandaloneDatabaseProvider(this.getContext())); - cacheDataSourceFactory = - new CacheDataSource.Factory() - .setCache(simpleCache) - .setUpstreamDataSourceFactory(buildHttpDataSourceFactory(false)); + if (cacheSize == 0) { + cacheDataSourceFactory = null; + } else { + SimpleCache simpleCache = new SimpleCache(new File(this.getContext().getCacheDir(), "RNVCache"), new LeastRecentlyUsedCacheEvictor((long) cacheSize*1024*1024), new StandaloneDatabaseProvider(this.getContext())); + cacheDataSourceFactory = + new CacheDataSource.Factory() + .setCache(simpleCache) + .setUpstreamDataSourceFactory(buildHttpDataSourceFactory(false)); + } releasePlayer(); initializePlayer(); } diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index 1099b8417f..5836e9f16e 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -61,7 +61,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager { - // this.channelUp(); + !this.state.loop && this.channelUp(); }; toggleFullscreen() { @@ -759,7 +759,7 @@ class VideoPlayer extends Component { onAspectRatio={this.onAspectRatio} onReadyForDisplay={this.onReadyForDisplay} onBuffer={this.onVideoBuffer} - repeat + repeat={this.state.loop} selectedTextTrack={this.state.selectedTextTrack} selectedAudioTrack={this.state.selectedAudioTrack} playInBackground={false} @@ -768,7 +768,7 @@ class VideoPlayer extends Component { maxBufferMs: 50000, bufferForPlaybackMs: 2500, bufferForPlaybackAfterRebufferMs: 5000, - bufferSize: 200, + cacheSizeMB: 200, }} /> diff --git a/src/VideoNativeComponent.ts b/src/VideoNativeComponent.ts index 90032917de..c6b78c6a92 100644 --- a/src/VideoNativeComponent.ts +++ b/src/VideoNativeComponent.ts @@ -103,7 +103,7 @@ type BufferConfig = Readonly<{ maxHeapAllocationPercent?: number; minBackBufferMemoryReservePercent?: number; minBufferMemoryReservePercent?: number; - bufferSize?: number; + cacheSizeMB?: number; }>; type SelectedVideoTrack = Readonly<{ diff --git a/src/types/video.ts b/src/types/video.ts index 415c69c530..8d340007a5 100644 --- a/src/types/video.ts +++ b/src/types/video.ts @@ -68,6 +68,7 @@ export type BufferConfig = { maxHeapAllocationPercent?: number; minBackBufferMemoryReservePercent?: number; minBufferMemoryReservePercent?: number; + cacheSizeMB?: number; }; export enum SelectedTrackType {