mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
added video cache
This commit is contained in:
parent
47745ec9e3
commit
c35364fb82
7 changed files with 107 additions and 73 deletions
|
@ -18,6 +18,7 @@ import androidx.annotation.StringRes
|
|||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.media.session.MediaButtonReceiver
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.PlaybackException
|
||||
|
@ -332,6 +333,17 @@ abstract class AbstractPlayerFragment(
|
|||
subStyle = SubtitlesFragment.getCurrentSavedStyle()
|
||||
player.initSubtitles(subView, subtitle_holder, subStyle)
|
||||
SubtitlesFragment.applyStyleEvent += ::onSubStyleChanged
|
||||
|
||||
try {
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
val currentPrefSize =
|
||||
settingsManager.getInt(getString(R.string.video_cache_key), 300)
|
||||
|
||||
player.cacheSize = currentPrefSize * 1024L * 1024L
|
||||
} catch (e : Exception) {
|
||||
logError(e)
|
||||
}
|
||||
}
|
||||
|
||||
/*context?.let { ctx ->
|
||||
|
|
|
@ -37,11 +37,11 @@ import javax.net.ssl.SSLSession
|
|||
const val TAG = "CS3ExoPlayer"
|
||||
|
||||
/** Cache */
|
||||
private const val cacheSize = 300L * 1024L * 1024L // 300 mb TODO MAKE SETTING
|
||||
|
||||
class CS3IPlayer : IPlayer {
|
||||
private var isPlaying = false
|
||||
private var exoPlayer: ExoPlayer? = null
|
||||
var cacheSize = 300L * 1024L * 1024L // 300 mb
|
||||
|
||||
private val seekActionTime = 30000L
|
||||
|
||||
|
|
|
@ -197,6 +197,28 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
val preferedMediaTypePreference = findPreference<Preference>(getString(R.string.prefer_media_type_key))!!
|
||||
val appThemePreference = findPreference<Preference>(getString(R.string.app_theme_key))!!
|
||||
val subPreference = findPreference<Preference>(getString(R.string.subtitle_settings_key))!!
|
||||
val videoCachePreference = findPreference<Preference>(getString(R.string.video_cache_key))!!
|
||||
|
||||
videoCachePreference.setOnPreferenceClickListener {
|
||||
val prefNames = resources.getStringArray(R.array.video_cache_size_names)
|
||||
val prefValues = resources.getIntArray(R.array.video_cache_size_values)
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
val currentPrefSize =
|
||||
settingsManager.getInt(getString(R.string.video_cache_key), 300)
|
||||
|
||||
activity?.showBottomDialog(
|
||||
prefNames.toList(),
|
||||
prefValues.indexOf(currentPrefSize),
|
||||
getString(R.string.video_cache_settings),
|
||||
true,
|
||||
{}) {
|
||||
settingsManager.edit()
|
||||
.putInt(getString(R.string.video_cache_key), prefValues[it])
|
||||
.apply()
|
||||
}
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
|
||||
subPreference.setOnPreferenceClickListener {
|
||||
SubtitlesFragment.push(activity, false)
|
||||
|
|
5
app/src/main/res/drawable/ic_baseline_storage_24.xml
Normal file
5
app/src/main/res/drawable/ic_baseline_storage_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M2,20h20v-4L2,16v4zM4,17h2v2L4,19v-2zM2,4v4h20L22,4L2,4zM6,7L4,7L4,5h2v2zM2,14h20v-4L2,10v4zM4,11h2v2L4,13v-2z"/>
|
||||
</vector>
|
|
@ -56,6 +56,22 @@
|
|||
<item>1</item>
|
||||
<item>2</item>
|
||||
</array>
|
||||
<array name="video_cache_size_names">
|
||||
<item>@string/none</item>
|
||||
<item>100MB</item>
|
||||
<item>200MB</item>
|
||||
<item>300MB</item>
|
||||
<item>400MB</item>
|
||||
<item>500MB</item>
|
||||
</array>
|
||||
<array name="video_cache_size_values">
|
||||
<item>0</item>
|
||||
<item>100</item>
|
||||
<item>200</item>
|
||||
<item>300</item>
|
||||
<item>400</item>
|
||||
<item>500</item>
|
||||
</array>
|
||||
|
||||
<array name="episode_long_click_options">
|
||||
<item>@string/episode_action_chomecast_episode</item>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<string name="benene_count" translatable="false">benene_count</string>
|
||||
<string name="subtitle_settings_key" translatable="false">subtitle_settings_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="prerelease_commit_hash" translatable="false">unknown_prerelease</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>
|
||||
|
@ -296,6 +297,7 @@
|
|||
<string name="dont_show_again">Don\'t show again</string>
|
||||
<string name="update">Update</string>
|
||||
<string name="watch_quality_pref">Preferred watch quality</string>
|
||||
<string name="video_cache_settings">Video cache size</string>
|
||||
<string name="dns_pref">DNS over HTTPS</string>
|
||||
<string name="dns_pref_summary">Useful for bypassing ISP blocks</string>
|
||||
|
||||
|
|
|
@ -1,72 +1,66 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory/>
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory />
|
||||
<PreferenceCategory
|
||||
android:key="video"
|
||||
android:title="Player"
|
||||
app:isPreferenceVisible="true"
|
||||
>
|
||||
app:isPreferenceVisible="true">
|
||||
<Preference
|
||||
android:key="@string/subtitle_settings_key"
|
||||
android:title="@string/player_subtitles_settings"
|
||||
android:icon="@drawable/ic_outline_subtitles_24"
|
||||
app:summary="@string/player_subtitles_settings_des">
|
||||
</Preference>
|
||||
app:summary="@string/player_subtitles_settings_des" />
|
||||
<Preference
|
||||
android:key="@string/quality_pref_key"
|
||||
android:title="@string/watch_quality_pref"
|
||||
android:icon="@drawable/ic_baseline_hd_24">
|
||||
</Preference>
|
||||
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
|
||||
android:icon="@drawable/ic_baseline_picture_in_picture_alt_24"
|
||||
app:key="@string/pip_enabled_key"
|
||||
android:title="@string/picture_in_picture"
|
||||
android:summary="@string/picture_in_picture_des"
|
||||
app:defaultValue="true"
|
||||
/>
|
||||
app:defaultValue="true" />
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_aspect_ratio_24"
|
||||
app:key="@string/player_resize_enabled_key"
|
||||
android:title="@string/player_size_settings"
|
||||
android:summary="@string/player_size_settings_des"
|
||||
app:defaultValue="true"
|
||||
/>
|
||||
app:defaultValue="true" />
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_speed_24"
|
||||
app:key="@string/playback_speed_enabled_key"
|
||||
android:title="@string/eigengraumode_settings"
|
||||
android:summary="@string/eigengraumode_settings_des"
|
||||
app:defaultValue="false"
|
||||
/>
|
||||
app:defaultValue="false" />
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_ondemand_video_24"
|
||||
app:key="@string/swipe_enabled_key"
|
||||
android:title="@string/swipe_to_seek_settings"
|
||||
android:summary="@string/swipe_to_seek_settings_des"
|
||||
app:defaultValue="true"
|
||||
/>
|
||||
app:defaultValue="true" />
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_ondemand_video_24"
|
||||
app:key="@string/swipe_vertical_enabled_key"
|
||||
android:title="@string/swipe_to_change_settings"
|
||||
android:summary="@string/swipe_to_change_settings_des"
|
||||
app:defaultValue="true"
|
||||
/>
|
||||
app:defaultValue="true" />
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_touch_app_24"
|
||||
app:key="@string/double_tap_enabled_key"
|
||||
android:title="@string/double_tap_to_seek_settings"
|
||||
android:summary="@string/double_tap_to_seek_settings_des"
|
||||
app:defaultValue="false"
|
||||
/>
|
||||
app:defaultValue="false" />
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/netflix_pause"
|
||||
app:key="@string/double_tap_pause_enabled_key"
|
||||
android:title="@string/double_tap_to_pause_settings"
|
||||
android:summary="@string/double_tap_to_pause_settings_des"
|
||||
app:defaultValue="false"
|
||||
/>
|
||||
app:defaultValue="false" />
|
||||
<!--
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/ic_baseline_brightness_7_24"
|
||||
|
@ -80,84 +74,70 @@
|
|||
<PreferenceCategory
|
||||
android:key="general"
|
||||
android:title="@string/general"
|
||||
app:isPreferenceVisible="true"
|
||||
>
|
||||
app:isPreferenceVisible="true">
|
||||
<Preference
|
||||
android:icon="@drawable/ic_baseline_language_24"
|
||||
android:key="@string/provider_lang_key"
|
||||
android:title="@string/provider_lang_settings">
|
||||
</Preference>
|
||||
android:title="@string/provider_lang_settings" />
|
||||
<Preference
|
||||
android:key="@string/locale_key"
|
||||
android:title="@string/app_language"
|
||||
android:icon="@drawable/ic_baseline_language_24">
|
||||
</Preference>
|
||||
android:icon="@drawable/ic_baseline_language_24" />
|
||||
<Preference
|
||||
android:key="@string/prefer_media_type_key"
|
||||
android:title="@string/preferred_media_settings"
|
||||
android:icon="@drawable/ic_baseline_play_arrow_24">
|
||||
</Preference>
|
||||
android:key="@string/prefer_media_type_key"
|
||||
android:title="@string/preferred_media_settings"
|
||||
android:icon="@drawable/ic_baseline_play_arrow_24" />
|
||||
<Preference
|
||||
android:key="@string/display_sub_key"
|
||||
android:title="@string/display_subbed_dubbed_settings"
|
||||
android:icon="@drawable/ic_outline_voice_over_off_24">
|
||||
</Preference>
|
||||
android:icon="@drawable/ic_outline_voice_over_off_24" />
|
||||
<SwitchPreference
|
||||
android:key="@string/show_fillers_key"
|
||||
android:icon="@drawable/ic_baseline_skip_next_24"
|
||||
android:title="@string/show_fillers_settings"
|
||||
android:defaultValue="true"/>
|
||||
android:defaultValue="true" />
|
||||
<Preference
|
||||
android:key="@string/dns_key"
|
||||
android:title="@string/dns_pref"
|
||||
android:summary="@string/dns_pref_summary"
|
||||
android:icon="@drawable/ic_baseline_dns_24">
|
||||
</Preference>
|
||||
android:icon="@drawable/ic_baseline_dns_24" />
|
||||
<Preference
|
||||
android:key="@string/download_path_key"
|
||||
android:title="@string/download_path_pref"
|
||||
android:icon="@drawable/netflix_download">
|
||||
</Preference>
|
||||
android:icon="@drawable/netflix_download" />
|
||||
<Preference
|
||||
android:icon="@drawable/ic_baseline_tv_24"
|
||||
android:key="@string/app_layout_key"
|
||||
android:title="@string/app_layout">
|
||||
</Preference>
|
||||
android:title="@string/app_layout" />
|
||||
<Preference
|
||||
android:icon="@drawable/ic_baseline_color_lens_24"
|
||||
android:key="@string/primary_color_key"
|
||||
android:title="@string/primary_color_settings">
|
||||
</Preference>
|
||||
android:title="@string/primary_color_settings" />
|
||||
<Preference
|
||||
android:icon="@drawable/ic_baseline_color_lens_24"
|
||||
android:key="@string/app_theme_key"
|
||||
android:title="@string/app_theme_settings">
|
||||
</Preference>
|
||||
android:title="@string/app_theme_settings" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="search"
|
||||
android:title="@string/search"
|
||||
app:isPreferenceVisible="true"
|
||||
>
|
||||
app:isPreferenceVisible="true">
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/search_icon"
|
||||
app:key="advanced_search"
|
||||
android:title="@string/advanced_search"
|
||||
android:summary="@string/advanced_search_des"
|
||||
app:defaultValue="true"
|
||||
/>
|
||||
app:defaultValue="true" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="info"
|
||||
android:title="@string/settings_info"
|
||||
app:isPreferenceVisible="true"
|
||||
>
|
||||
app:isPreferenceVisible="true">
|
||||
<Preference
|
||||
android:key="@string/legal_notice_key"
|
||||
android:title="@string/legal_notice"
|
||||
android:icon="@drawable/ic_baseline_warning_24">
|
||||
</Preference>
|
||||
android:icon="@drawable/ic_baseline_warning_24" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="acra.disable"
|
||||
|
@ -165,65 +145,62 @@
|
|||
android:title="@string/pref_disable_acra"
|
||||
android:summaryOff="@string/bug_report_settings_off"
|
||||
android:summaryOn="@string/bug_report_settings_on"
|
||||
android:defaultValue="false"/>
|
||||
android:defaultValue="false" />
|
||||
<SwitchPreference
|
||||
app:key="@string/auto_update_key"
|
||||
android:title="@string/updates_settings"
|
||||
android:summary="@string/updates_settings_des"
|
||||
app:defaultValue="true"
|
||||
android:icon="@drawable/ic_baseline_notifications_active_24"
|
||||
/>
|
||||
android:icon="@drawable/ic_baseline_notifications_active_24" />
|
||||
<SwitchPreference
|
||||
app:key="@string/prerelease_update_key"
|
||||
android:title="@string/uprereleases_settings"
|
||||
android:summary="@string/uprereleases_settings_des"
|
||||
app:defaultValue="false"
|
||||
android:icon="@drawable/ic_baseline_developer_mode_24"
|
||||
/>
|
||||
android:icon="@drawable/ic_baseline_developer_mode_24" />
|
||||
<Preference
|
||||
android:title="@string/check_for_update"
|
||||
app:summary="@string/app_version"
|
||||
app:key="@string/manual_check_update_key"
|
||||
app:icon="@drawable/ic_baseline_system_update_24"
|
||||
/>
|
||||
app:icon="@drawable/ic_baseline_system_update_24" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/mal_key"
|
||||
android:icon="@drawable/mal_logo">
|
||||
</Preference>
|
||||
android:icon="@drawable/mal_logo" />
|
||||
|
||||
<Preference
|
||||
android:key="@string/anilist_key"
|
||||
android:icon="@drawable/ic_anilist_icon">
|
||||
</Preference>
|
||||
android:icon="@drawable/ic_anilist_icon" />
|
||||
|
||||
<Preference
|
||||
android:title="@string/github"
|
||||
android:icon="@drawable/ic_github_logo"
|
||||
app:summary="https://github.com/LagradOst/CloudStream-3">
|
||||
<intent android:action="android.intent.action.VIEW"
|
||||
android:data="https://github.com/LagradOst/CloudStream-3"/>
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://github.com/LagradOst/CloudStream-3" />
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:title="@string/lightnovel"
|
||||
android:icon="@drawable/quick_novel_icon"
|
||||
app:summary="https://github.com/LagradOst/QuickNovel">
|
||||
<intent android:action="android.intent.action.VIEW"
|
||||
android:data="https://github.com/LagradOst/QuickNovel"/>
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://github.com/LagradOst/QuickNovel" />
|
||||
</Preference>
|
||||
<Preference
|
||||
android:title="@string/discord"
|
||||
android:icon="@drawable/ic_baseline_discord_24"
|
||||
app:summary="https://discord.gg/5Hus6fM">
|
||||
<intent android:action="android.intent.action.VIEW"
|
||||
android:data="https://discord.gg/5Hus6fM"/>
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://discord.gg/5Hus6fM" />
|
||||
</Preference>
|
||||
<Preference
|
||||
android:key="@string/benene_count"
|
||||
android:title="@string/benene"
|
||||
android:icon="@drawable/benene"
|
||||
app:summary="@string/benene_des">
|
||||
</Preference>
|
||||
app:summary="@string/benene_des" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Reference in a new issue