Yokan / rebuild
Course 1 8624561

PlayerAdvancedSettingsViewModel.kt

composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/ui/screens/settings/player/PlayerAdvancedSettingsViewModel.kt

implementation32 lines
1package eu.friedcutlet.yokan.ui.screens.settings.player23import androidx.lifecycle.ViewModel4import androidx.lifecycle.viewModelScope5import eu.friedcutlet.yokan.services.files.LocalFileService6import eu.friedcutlet.yokan.services.media.player.DefaultMpvConf7import eu.friedcutlet.yokan.services.media.player.DefaultMpvInputConf8import kotlinx.coroutines.CoroutineDispatcher9import kotlinx.coroutines.Dispatchers10import kotlinx.coroutines.flow.MutableStateFlow11import kotlinx.coroutines.flow.StateFlow12import kotlinx.coroutines.flow.asStateFlow13import kotlinx.coroutines.launch14import kotlinx.coroutines.withContext1516internal class PlayerAdvancedSettingsViewModel(17    private val files: LocalFileService,18    private val workDispatcher: CoroutineDispatcher = Dispatchers.Default,19) : ViewModel() {20    private val _redownloadStatus = MutableStateFlow<String?>(null)21    val redownloadStatus: StateFlow<String?> = _redownloadStatus.asStateFlow()2223    fun redownloadMpvConfig() {24        viewModelScope.launch {25            withContext(workDispatcher) {26                files.writeBytes("${files.cacheRoot}/mpv/mpv.conf", DefaultMpvConf.encodeToByteArray())27                files.writeBytes("${files.cacheRoot}/mpv/input.conf", DefaultMpvInputConf.encodeToByteArray())28            }29            _redownloadStatus.value = "Wrote default mpv.conf and input.conf to ${files.cacheRoot}/mpv/"30        }31    }32}33

Search chapters, reference and source filenames.