Skip to content

Commit

Permalink
feat: gpu-next setting
Browse files Browse the repository at this point in the history
  • Loading branch information
abdallahmehiz committed Jun 4, 2024
1 parent 57358c4 commit df75611
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import live.mehiz.mpvkt.preferences.preference.PreferenceStore

class DecoderPreferences(preferenceStore: PreferenceStore) {
val tryHWDecoding = preferenceStore.getBoolean("try_hw_dec", true)
val gpuNext = preferenceStore.getBoolean("gpu_next", false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PlayerActivity : AppCompatActivity() {
applicationContext.filesDir.path,
applicationContext.cacheDir.path,
"v",
if(decoderPreferences.gpuNext.get()) "gpu-next" else "gpu"
)
MPVLib.setPropertyString(
"hwdec",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,62 @@ package live.mehiz.mpvkt.ui.preferences
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.navigator.LocalNavigator
import cafe.adriel.voyager.navigator.currentOrThrow
import live.mehiz.mpvkt.R
import live.mehiz.mpvkt.preferences.DecoderPreferences
import me.zhanghai.compose.preference.ProvidePreferenceLocals
import me.zhanghai.compose.preference.switchPreference
import org.koin.compose.koinInject

object DecoderPreferencesScreen: Screen {
object DecoderPreferencesScreen : Screen {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
override fun Content() {
val preferences = koinInject<DecoderPreferences>()
val navigator = LocalNavigator.currentOrThrow
Scaffold(
topBar = {
TopAppBar(
title = {
Text(stringResource(R.string.pref_decoder))
}
},
navigationIcon = {
IconButton(onClick = { navigator.pop() }) {
Icon(Icons.AutoMirrored.Default.ArrowBack, null)
}
},
)
}
},
) { padding ->
ProvidePreferenceLocals {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.padding(padding),
) {
switchPreference(
preferences.tryHWDecoding.key(),
defaultValue = preferences.tryHWDecoding.defaultValue(),
title = { Text(stringResource(R.string.pref_decoder_try_hw_dec_title)) }
title = { Text(stringResource(R.string.pref_decoder_try_hw_dec_title)) },
)
switchPreference(
preferences.gpuNext.key(),
defaultValue = preferences.gpuNext.defaultValue(),
title = { Text(stringResource(R.string.pref_decoder_gpu_next_title)) },
summary = { Text(stringResource(R.string.pref_decoder_gpu_next_subtitle)) },
)
}
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

<string name="pref_decoder">Decoder</string>
<string name="pref_decoder_try_hw_dec_title">Try hardware decoding</string>
<string name="pref_decoder_gpu_next_title">Use gpu-next</string>
<string name="pref_decoder_gpu_next_subtitle">A new rendering backend.</string>

<string name="player_sheets_add_ext_sub">Add external subtitles</string>
<string name="player_sheets_add_ext_audio">Add external audio tracks</string>
Expand Down

0 comments on commit df75611

Please sign in to comment.