mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
more video cache settings
This commit is contained in:
parent
fb78871a94
commit
5b02a37fc1
10 changed files with 170 additions and 31 deletions
|
@ -339,14 +339,21 @@ abstract class AbstractPlayerFragment(
|
||||||
SubtitlesFragment.applyStyleEvent += ::onSubStyleChanged
|
SubtitlesFragment.applyStyleEvent += ::onSubStyleChanged
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context?.let {
|
context?.let { ctx ->
|
||||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(
|
||||||
it
|
ctx
|
||||||
)
|
)
|
||||||
val currentPrefSize =
|
|
||||||
settingsManager.getInt(getString(R.string.video_cache_key), 300)
|
|
||||||
|
|
||||||
player.cacheSize = currentPrefSize * 1024L * 1024L
|
val currentPrefCacheSize =
|
||||||
|
settingsManager.getInt(getString(R.string.video_buffer_size_key), 0)
|
||||||
|
val currentPrefDiskSize =
|
||||||
|
settingsManager.getInt(getString(R.string.video_buffer_disk_key), 0)
|
||||||
|
val currentPrefBufferSec =
|
||||||
|
settingsManager.getInt(getString(R.string.video_buffer_length_key), 0)
|
||||||
|
|
||||||
|
player.cacheSize = currentPrefCacheSize * 1024L * 1024L
|
||||||
|
player.simpleCacheSize = currentPrefDiskSize * 1024L * 1024L
|
||||||
|
player.videoBufferMs = currentPrefBufferSec * 1000L
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logError(e)
|
logError(e)
|
||||||
|
|
|
@ -39,8 +39,9 @@ const val TAG = "CS3ExoPlayer"
|
||||||
class CS3IPlayer : IPlayer {
|
class CS3IPlayer : IPlayer {
|
||||||
private var isPlaying = false
|
private var isPlaying = false
|
||||||
private var exoPlayer: ExoPlayer? = null
|
private var exoPlayer: ExoPlayer? = null
|
||||||
var cacheSize = 300L * 1024L * 1024L // 300 mb
|
var cacheSize = 0L
|
||||||
private val simpleCacheSize : Long get() = cacheSize / 2 // idk chosen at random kinda
|
var simpleCacheSize = 0L
|
||||||
|
var videoBufferMs = 0L
|
||||||
|
|
||||||
private val seekActionTime = 30000L
|
private val seekActionTime = 30000L
|
||||||
|
|
||||||
|
@ -423,6 +424,7 @@ class CS3IPlayer : IPlayer {
|
||||||
playBackSpeed: Float,
|
playBackSpeed: Float,
|
||||||
subtitleOffset: Long,
|
subtitleOffset: Long,
|
||||||
cacheSize: Long,
|
cacheSize: Long,
|
||||||
|
videoBufferMs: Long,
|
||||||
playWhenReady: Boolean = true,
|
playWhenReady: Boolean = true,
|
||||||
cacheFactory: CacheDataSource.Factory? = null,
|
cacheFactory: CacheDataSource.Factory? = null,
|
||||||
trackSelector: TrackSelector? = null,
|
trackSelector: TrackSelector? = null,
|
||||||
|
@ -460,10 +462,11 @@ class CS3IPlayer : IPlayer {
|
||||||
)
|
)
|
||||||
.setBufferDurationsMs(
|
.setBufferDurationsMs(
|
||||||
DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
|
DefaultLoadControl.DEFAULT_MIN_BUFFER_MS,
|
||||||
maxOf(
|
if(videoBufferMs <= 0) {
|
||||||
DefaultLoadControl.DEFAULT_MAX_BUFFER_MS,
|
DefaultLoadControl.DEFAULT_MAX_BUFFER_MS
|
||||||
((cacheSize * 75L) / 32768L).toInt()
|
} else {
|
||||||
), // 500mb = 20min
|
videoBufferMs.toInt()
|
||||||
|
},
|
||||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
|
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS,
|
||||||
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
|
DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS
|
||||||
).build()
|
).build()
|
||||||
|
@ -574,6 +577,7 @@ class CS3IPlayer : IPlayer {
|
||||||
playbackPosition,
|
playbackPosition,
|
||||||
playBackSpeed,
|
playBackSpeed,
|
||||||
cacheSize = cacheSize,
|
cacheSize = cacheSize,
|
||||||
|
videoBufferMs = videoBufferMs,
|
||||||
playWhenReady = isPlaying, // this keep the current state of the player
|
playWhenReady = isPlaying, // this keep the current state of the player
|
||||||
cacheFactory = cacheFactory,
|
cacheFactory = cacheFactory,
|
||||||
subtitleOffset = currentSubtitleOffset
|
subtitleOffset = currentSubtitleOffset
|
||||||
|
|
|
@ -209,21 +209,61 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
setPreferencesFromResource(R.xml.settings, rootKey)
|
setPreferencesFromResource(R.xml.settings, rootKey)
|
||||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
|
|
||||||
getPref(R.string.video_cache_key)?.setOnPreferenceClickListener {
|
getPref(R.string.video_buffer_length_key)?.setOnPreferenceClickListener {
|
||||||
val prefNames = resources.getStringArray(R.array.video_cache_size_names)
|
val prefNames = resources.getStringArray(R.array.video_buffer_length_names)
|
||||||
val prefValues = resources.getIntArray(R.array.video_cache_size_values)
|
val prefValues = resources.getIntArray(R.array.video_buffer_length_values)
|
||||||
|
|
||||||
val currentPrefSize =
|
val currentPrefSize =
|
||||||
settingsManager.getInt(getString(R.string.video_cache_key), 300)
|
settingsManager.getInt(getString(R.string.video_buffer_length_key), 0)
|
||||||
|
|
||||||
activity?.showBottomDialog(
|
activity?.showDialog(
|
||||||
prefNames.toList(),
|
prefNames.toList(),
|
||||||
prefValues.indexOf(currentPrefSize),
|
prefValues.indexOf(currentPrefSize),
|
||||||
getString(R.string.video_cache_settings),
|
getString(R.string.video_buffer_length_settings),
|
||||||
true,
|
true,
|
||||||
{}) {
|
{}) {
|
||||||
settingsManager.edit()
|
settingsManager.edit()
|
||||||
.putInt(getString(R.string.video_cache_key), prefValues[it])
|
.putInt(getString(R.string.video_buffer_length_key), prefValues[it])
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
return@setOnPreferenceClickListener true
|
||||||
|
}
|
||||||
|
|
||||||
|
getPref(R.string.video_buffer_size_key)?.setOnPreferenceClickListener {
|
||||||
|
val prefNames = resources.getStringArray(R.array.video_buffer_size_names)
|
||||||
|
val prefValues = resources.getIntArray(R.array.video_buffer_size_values)
|
||||||
|
|
||||||
|
val currentPrefSize =
|
||||||
|
settingsManager.getInt(getString(R.string.video_buffer_size_key), 0)
|
||||||
|
|
||||||
|
activity?.showDialog(
|
||||||
|
prefNames.toList(),
|
||||||
|
prefValues.indexOf(currentPrefSize),
|
||||||
|
getString(R.string.video_buffer_size_settings),
|
||||||
|
true,
|
||||||
|
{}) {
|
||||||
|
settingsManager.edit()
|
||||||
|
.putInt(getString(R.string.video_buffer_size_key), prefValues[it])
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
return@setOnPreferenceClickListener true
|
||||||
|
}
|
||||||
|
|
||||||
|
getPref(R.string.video_buffer_disk_key)?.setOnPreferenceClickListener {
|
||||||
|
val prefNames = resources.getStringArray(R.array.video_buffer_size_names)
|
||||||
|
val prefValues = resources.getIntArray(R.array.video_buffer_size_values)
|
||||||
|
|
||||||
|
val currentPrefSize =
|
||||||
|
settingsManager.getInt(getString(R.string.video_buffer_disk_key), 0)
|
||||||
|
|
||||||
|
activity?.showDialog(
|
||||||
|
prefNames.toList(),
|
||||||
|
prefValues.indexOf(currentPrefSize),
|
||||||
|
getString(R.string.video_buffer_disk_settings),
|
||||||
|
true,
|
||||||
|
{}) {
|
||||||
|
settingsManager.edit()
|
||||||
|
.putInt(getString(R.string.video_buffer_disk_key), prefValues[it])
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
return@setOnPreferenceClickListener true
|
return@setOnPreferenceClickListener true
|
||||||
|
|
|
@ -232,7 +232,7 @@
|
||||||
<string name="dont_show_again">لا تظهر مرة أخرى</string>
|
<string name="dont_show_again">لا تظهر مرة أخرى</string>
|
||||||
<string name="update">تحديث</string>
|
<string name="update">تحديث</string>
|
||||||
<string name="watch_quality_pref">جودة المشاهدة المفضلة</string>
|
<string name="watch_quality_pref">جودة المشاهدة المفضلة</string>
|
||||||
<string name="video_cache_settings">حجم ذاكرة التخزين المؤقت للفيديو</string>
|
<string name="video_buffer_size_settings">حجم ذاكرة التخزين المؤقت للفيديو</string>
|
||||||
<string name="dns_pref">DNS فوق HTTPS</string>
|
<string name="dns_pref">DNS فوق HTTPS</string>
|
||||||
<string name="dns_pref_summary">مفيد لتجاوز كتل مزود خدمة الإنترنت</string>
|
<string name="dns_pref_summary">مفيد لتجاوز كتل مزود خدمة الإنترنت</string>
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
\n%s -> %s</string>
|
\n%s -> %s</string>
|
||||||
<string name="filler" formatted="true">Épisode spécial</string>
|
<string name="filler" formatted="true">Épisode spécial</string>
|
||||||
<string name="watch_quality_pref">Qualité de visionnage préférée</string>
|
<string name="watch_quality_pref">Qualité de visionnage préférée</string>
|
||||||
<string name="video_cache_settings">Taille de la mémoire cache</string>
|
<string name="video_buffer_size_settings">Taille de la mémoire cache</string>
|
||||||
<string name="resize_fill">Étendre</string>
|
<string name="resize_fill">Étendre</string>
|
||||||
<string name="legal_notice">Non-responsabilité</string>
|
<string name="legal_notice">Non-responsabilité</string>
|
||||||
<string name="primary_color_settings">Couleur principale</string>
|
<string name="primary_color_settings">Couleur principale</string>
|
||||||
|
|
|
@ -269,7 +269,7 @@
|
||||||
<string name="dont_show_again">Non mostrare di nuovo</string>
|
<string name="dont_show_again">Non mostrare di nuovo</string>
|
||||||
<string name="update">Aggiorna</string>
|
<string name="update">Aggiorna</string>
|
||||||
<string name="watch_quality_pref">Risoluzione preferita</string>
|
<string name="watch_quality_pref">Risoluzione preferita</string>
|
||||||
<string name="video_cache_settings">Dimensione cache video</string>
|
<string name="video_buffer_size_settings">Dimensione cache video</string>
|
||||||
<string name="dns_pref">DNS over HTTPS</string>
|
<string name="dns_pref">DNS over HTTPS</string>
|
||||||
<string name="dns_pref_summary">Utile per bypassare i blocchi ISP</string>
|
<string name="dns_pref_summary">Utile per bypassare i blocchi ISP</string>
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@
|
||||||
<string name="dont_show_again">Không hiển thị lại</string>
|
<string name="dont_show_again">Không hiển thị lại</string>
|
||||||
<string name="update">Cập nhật</string>
|
<string name="update">Cập nhật</string>
|
||||||
<string name="watch_quality_pref">Tự động chọn chất lượng phim</string>
|
<string name="watch_quality_pref">Tự động chọn chất lượng phim</string>
|
||||||
<string name="video_cache_settings">Kích thước video cache</string>
|
<string name="video_buffer_size_settings">Kích thước video cache</string>
|
||||||
<string name="dns_pref_summary">Rất hữu ích để bỏ chặn ISP</string>
|
<string name="dns_pref_summary">Rất hữu ích để bỏ chặn ISP</string>
|
||||||
|
|
||||||
<string name="download_path_pref">Đường dẫn tải xuống</string>
|
<string name="download_path_pref">Đường dẫn tải xuống</string>
|
||||||
|
|
|
@ -56,20 +56,88 @@
|
||||||
<item>1</item>
|
<item>1</item>
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
</array>
|
</array>
|
||||||
<array name="video_cache_size_names">
|
|
||||||
<item>@string/none</item>
|
<array name="video_buffer_length_names">
|
||||||
|
<item>@string/automatic</item>
|
||||||
|
<item>1min</item>
|
||||||
|
<item>1min 30s</item>
|
||||||
|
<item>2min</item>
|
||||||
|
<item>2min 30s</item>
|
||||||
|
<item>3min</item>
|
||||||
|
<item>3min 30s</item>
|
||||||
|
<item>4min</item>
|
||||||
|
<item>5min</item>
|
||||||
|
<item>6min</item>
|
||||||
|
<item>7min</item>
|
||||||
|
<item>8min</item>
|
||||||
|
<item>9min</item>
|
||||||
|
<item>10min</item>
|
||||||
|
<item>15min</item>
|
||||||
|
<item>20min</item>
|
||||||
|
<item>30min</item>
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<array name="video_buffer_length_values">
|
||||||
|
<item>0</item>
|
||||||
|
<item>60</item>
|
||||||
|
<item>90</item>
|
||||||
|
<item>120</item>
|
||||||
|
<item>150</item>
|
||||||
|
<item>180</item>
|
||||||
|
<item>210</item>
|
||||||
|
<item>240</item>
|
||||||
|
<item>300</item>
|
||||||
|
<item>360</item>
|
||||||
|
<item>420</item>
|
||||||
|
<item>480</item>
|
||||||
|
<item>540</item>
|
||||||
|
<item>600</item>
|
||||||
|
<item>900</item>
|
||||||
|
<item>1200</item>
|
||||||
|
<item>1800</item>
|
||||||
|
</array>
|
||||||
|
|
||||||
|
<array name="video_buffer_size_names">
|
||||||
|
<item>@string/automatic</item>
|
||||||
|
<item>10MB</item>
|
||||||
|
<item>20MB</item>
|
||||||
|
<item>30MB</item>
|
||||||
|
<item>40MB</item>
|
||||||
|
<item>50MB</item>
|
||||||
|
<item>60MB</item>
|
||||||
|
<item>70MB</item>
|
||||||
|
<item>80MB</item>
|
||||||
|
<item>90MB</item>
|
||||||
<item>100MB</item>
|
<item>100MB</item>
|
||||||
|
<item>150MB</item>
|
||||||
<item>200MB</item>
|
<item>200MB</item>
|
||||||
|
<item>250MB</item>
|
||||||
<item>300MB</item>
|
<item>300MB</item>
|
||||||
|
<item>350MB</item>
|
||||||
<item>400MB</item>
|
<item>400MB</item>
|
||||||
|
<item>450MB</item>
|
||||||
<item>500MB</item>
|
<item>500MB</item>
|
||||||
</array>
|
</array>
|
||||||
<array name="video_cache_size_values">
|
|
||||||
|
<array name="video_buffer_size_values">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
|
<item>10</item>
|
||||||
|
<item>20</item>
|
||||||
|
<item>30</item>
|
||||||
|
<item>40</item>
|
||||||
|
<item>50</item>
|
||||||
|
<item>60</item>
|
||||||
|
<item>70</item>
|
||||||
|
<item>80</item>
|
||||||
|
<item>90</item>
|
||||||
<item>100</item>
|
<item>100</item>
|
||||||
|
<item>150</item>
|
||||||
<item>200</item>
|
<item>200</item>
|
||||||
|
<item>250</item>
|
||||||
<item>300</item>
|
<item>300</item>
|
||||||
|
<item>350</item>
|
||||||
<item>400</item>
|
<item>400</item>
|
||||||
|
<item>450</item>
|
||||||
<item>500</item>
|
<item>500</item>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
<string name="subtitle_settings_key" translatable="false">subtitle_settings_key</string>
|
<string name="subtitle_settings_key" translatable="false">subtitle_settings_key</string>
|
||||||
<string name="subtitle_settings_chromecast_key" translatable="false">subtitle_settings_chromecast_key</string>
|
<string name="subtitle_settings_chromecast_key" translatable="false">subtitle_settings_chromecast_key</string>
|
||||||
<string name="quality_pref_key" translatable="false">quality_pref_key</string>
|
<string name="quality_pref_key" translatable="false">quality_pref_key</string>
|
||||||
<string name="video_cache_key" translatable="false">video_cache_key</string>
|
<string name="video_buffer_size_key" translatable="false">video_buffer_size_key</string>
|
||||||
|
<string name="video_buffer_length_key" translatable="false">video_buffer_length_key</string>
|
||||||
|
<string name="video_buffer_disk_key" translatable="false">video_buffer_disk_key</string>
|
||||||
<string name="prerelease_commit_hash" translatable="false">unknown_prerelease</string>
|
<string name="prerelease_commit_hash" translatable="false">unknown_prerelease</string>
|
||||||
<string name="use_system_brightness_key" translatable="false">use_system_brightness_key</string>
|
<string name="use_system_brightness_key" translatable="false">use_system_brightness_key</string>
|
||||||
<string name="swipe_enabled_key" translatable="false">swipe_enabled_key</string>
|
<string name="swipe_enabled_key" translatable="false">swipe_enabled_key</string>
|
||||||
|
@ -319,7 +321,11 @@
|
||||||
<string name="dont_show_again">Don\'t show again</string>
|
<string name="dont_show_again">Don\'t show again</string>
|
||||||
<string name="update">Update</string>
|
<string name="update">Update</string>
|
||||||
<string name="watch_quality_pref">Preferred watch quality</string>
|
<string name="watch_quality_pref">Preferred watch quality</string>
|
||||||
<string name="video_cache_settings">Video cache size</string>
|
<string name="video_buffer_size_settings">Video buffer size</string>
|
||||||
|
<string name="video_buffer_length_settings">Video buffer length</string>
|
||||||
|
<string name="video_buffer_disk_settings">Video cache on disk</string>
|
||||||
|
<string name="video_buffer_description">May cause problems on systems with low ram or storage such as Android TV devices or old phones if you set it too high</string>
|
||||||
|
|
||||||
<string name="dns_pref">DNS over HTTPS</string>
|
<string name="dns_pref">DNS over HTTPS</string>
|
||||||
<string name="dns_pref_summary">Useful for bypassing ISP blocks</string>
|
<string name="dns_pref_summary">Useful for bypassing ISP blocks</string>
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,7 @@
|
||||||
android:key="@string/quality_pref_key"
|
android:key="@string/quality_pref_key"
|
||||||
android:title="@string/watch_quality_pref"
|
android:title="@string/watch_quality_pref"
|
||||||
android:icon="@drawable/ic_baseline_hd_24" />
|
android:icon="@drawable/ic_baseline_hd_24" />
|
||||||
<Preference
|
|
||||||
android:key="@string/video_cache_key"
|
|
||||||
android:title="@string/video_cache_settings"
|
|
||||||
android:icon="@drawable/ic_baseline_storage_24" />
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:icon="@drawable/ic_baseline_picture_in_picture_alt_24"
|
android:icon="@drawable/ic_baseline_picture_in_picture_alt_24"
|
||||||
app:key="@string/pip_enabled_key"
|
app:key="@string/pip_enabled_key"
|
||||||
|
@ -66,6 +63,23 @@
|
||||||
android:title="@string/double_tap_to_pause_settings"
|
android:title="@string/double_tap_to_pause_settings"
|
||||||
android:summary="@string/double_tap_to_pause_settings_des"
|
android:summary="@string/double_tap_to_pause_settings_des"
|
||||||
app:defaultValue="false" />
|
app:defaultValue="false" />
|
||||||
|
<Preference
|
||||||
|
android:key="@string/video_buffer_disk_key"
|
||||||
|
android:title="@string/video_buffer_disk_settings"
|
||||||
|
android:summary="@string/video_buffer_description"
|
||||||
|
android:icon="@drawable/ic_baseline_storage_24" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="@string/video_buffer_size_key"
|
||||||
|
android:title="@string/video_buffer_size_settings"
|
||||||
|
android:summary="@string/video_buffer_description"
|
||||||
|
android:icon="@drawable/ic_baseline_storage_24" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="@string/video_buffer_length_key"
|
||||||
|
android:title="@string/video_buffer_length_settings"
|
||||||
|
android:summary="@string/video_buffer_description"
|
||||||
|
android:icon="@drawable/ic_baseline_storage_24" />
|
||||||
<!--
|
<!--
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:icon="@drawable/ic_baseline_brightness_7_24"
|
android:icon="@drawable/ic_baseline_brightness_7_24"
|
||||||
|
|
Loading…
Reference in a new issue