software decoding auto

This commit is contained in:
Osten
2025-02-01 23:16:32 +01:00
committed by GitHub
parent e5ac4a0f94
commit 6ff64637b6
6 changed files with 47 additions and 7 deletions

View File

@ -71,6 +71,8 @@ import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.mvvm.debugAssert
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
import com.lagradost.cloudstream3.ui.settings.Globals.TV
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle
import com.lagradost.cloudstream3.utils.AppContextUtils.isUsingMobileData
import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus
@ -739,12 +741,17 @@ class CS3IPlayer : IPlayer {
val exoPlayerBuilder =
ExoPlayer.Builder(context)
.setRenderersFactory { eventHandler, videoRendererEventListener, audioRendererEventListener, textRendererOutput, metadataRendererOutput ->
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
val softwareDecoding = settingsManager.getBoolean(
context.getString(R.string.software_decoding_key),
true
)
val current = settingsManager.getInt(context.getString(R.string.software_decoding_key), -1)
val softwareDecoding = when(current) {
0 -> true // yes
1 -> false // no
// -1 = automatic
else -> {
// we do not want tv to have software decoding, because of crashes
!isLayout(TV)
}
}
val factory = if (softwareDecoding) {
NextRenderersFactory(context).apply {

View File

@ -125,6 +125,9 @@ object Torrent {
/** Removes all torrents from the server, and returns if it is successful */
suspend fun clearAll(): Boolean {
if(TORRENT_SERVER_URL.isEmpty()) {
return true
}
return try {
val items = list()
var allSuccess = true

View File

@ -88,6 +88,24 @@ class SettingsPlayer : PreferenceFragmentCompat() {
return@setOnPreferenceClickListener true
}
getPref(R.string.software_decoding_key)?.setOnPreferenceClickListener {
val prefNames = resources.getStringArray(R.array.software_decoding_switch)
val prefValues = resources.getIntArray(R.array.software_decoding_switch_values)
val current = settingsManager.getInt(getString(R.string.software_decoding_key), -1)
activity?.showBottomDialog(
prefNames.toList(),
prefValues.indexOf(current),
getString(R.string.software_decoding),
true,
{}) {
settingsManager.edit()
.putInt(getString(R.string.software_decoding_key), prefValues[it])
.apply()
}
return@setOnPreferenceClickListener true
}
getPref(R.string.prefer_limit_title_rez_key)?.setOnPreferenceClickListener {
val prefNames = resources.getStringArray(R.array.limit_title_rez_pref_names)
val prefValues = resources.getIntArray(R.array.limit_title_rez_pref_values)

View File

@ -226,6 +226,18 @@
<item>2</item>
</array>
<array name="software_decoding_switch">
<item>@string/automatic</item>
<item>@string/yes</item>
<item>@string/no</item>
</array>
<array name="software_decoding_switch_values">
<item>-1</item>
<item>0</item>
<item>1</item>
</array>
<array name="confirm_exit">
<item>@string/automatic</item>
<item>@string/show</item>

View File

@ -829,7 +829,7 @@
<string name="subs_edge_size">Edge Size</string>
<string name="torrent_preferred_media">Enable torrent in Settings/Providers/Preferred media</string>
<string name="torrent_not_accepted">Not accepted torrent</string>
<string name="software_decoding_key" translatable="false">software_decoding_key</string>
<string name="software_decoding_key" translatable="false">software_decoding_key2</string>
<string name="software_decoding">Software decoding</string>
<string name="software_decoding_desc">Software decoding enables the player to play video files not supported by your phone, but may cause laggy or unstable playback on high resolution</string>
</resources>

View File

@ -105,7 +105,7 @@
android:title="@string/preview_seekbar"
app:defaultValue="true"
app:key="@string/preview_seekbar_key" />
<SwitchPreference
<Preference
android:icon="@drawable/ic_baseline_extension_24"
android:summary="@string/software_decoding_desc"
android:title="@string/software_decoding"