Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
- `Other` - for technical stuff.

## [Unreleased]
### Fixed
- Fix player crash when opening player ([@Secozzi](https://github.com/Secozzi)) ([#170](https://github.com/quickdesh/Animiru/pull/170))

## [v0.19.7.8] - 2026-07-07
### Added
Expand Down
32 changes: 13 additions & 19 deletions app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,17 @@ class PlayerViewModel @JvmOverloads constructor(
private val autoSkip = playerPreferences.autoSkipIntro.get()
private val netflixStyle = playerPreferences.enableNetflixStyleIntroSkip.get()
private val defaultWaitingTime = playerPreferences.waitingTimeIntroSkip.get()
private val leftDoubleTapGesture = gesturePreferences.leftDoubleTapGesture.get()
private val centerDoubleTapGesture = gesturePreferences.centerDoubleTapGesture.get()
private val rightDoubleTapGesture = gesturePreferences.rightDoubleTapGesture.get()
private val doubleTapToSeekDuration = gesturePreferences.skipLengthPreference.get()
private val showSeekBar = gesturePreferences.showSeekBar.get()
private val pipEpisodeToasts = playerPreferences.pipEpisodeToasts.get()
private val showStatusBar = playerPreferences.showSystemStatusBar.get()
private val downloadAheadAmount = downloadPreferences.autoDownloadWhileWatching.get()
private val progress = playerPreferences.progressPreference.get()

private val fontExtensionRegex = Regex($$""".*\.[ot]tf$""")
private val maxVolume = audioManager.getMaxVolume()
private val screenAspectRatio: Double by lazy {
val metrics = context.resources.displayMetrics
Expand Down Expand Up @@ -240,6 +250,9 @@ class PlayerViewModel @JvmOverloads constructor(
val eventFlow = _eventFlow.asSharedFlow()

private var timerJob: Job? = null
private var getHosterVideoLinksJob: Job? = null
private var episodeToDownload: Download? = null
private var currentHosterList: List<Hoster>? = null

init {
viewModelScope.launchIO {
Expand Down Expand Up @@ -510,7 +523,6 @@ class PlayerViewModel @JvmOverloads constructor(
field = value
}

private val fontExtensionRegex = Regex($$""".*\.[ot]tf$""")
fun fetchFonts(includeSystemFonts: Boolean): List<String> {
val fontFiles = mutableListOf<String>()

Expand Down Expand Up @@ -579,8 +591,6 @@ class PlayerViewModel @JvmOverloads constructor(
val position: Long?,
)

private var currentHosterList: List<Hoster>? = null

class ExceptionWithStringResource(
message: String,
val stringResource: StringResource,
Expand Down Expand Up @@ -819,8 +829,6 @@ class PlayerViewModel @JvmOverloads constructor(

// === Load ===

private var getHosterVideoLinksJob: Job? = null

fun cancelHosterVideoLinksJob() {
getHosterVideoLinksJob?.cancel()
}
Expand Down Expand Up @@ -1657,8 +1665,6 @@ class PlayerViewModel @JvmOverloads constructor(
}
}

private val pipEpisodeToasts = playerPreferences.pipEpisodeToasts.get()

/**
* Load next or previous episode
*/
Expand Down Expand Up @@ -1757,7 +1763,6 @@ class PlayerViewModel @JvmOverloads constructor(
updatePlaybackData { it.copy(paused = false) }
}

private val showStatusBar = playerPreferences.showSystemStatusBar.get()
fun showControls() {
val currentUi = uiData.value
if (currentUi.sheetShown != Sheets.None ||
Expand Down Expand Up @@ -2071,12 +2076,6 @@ class PlayerViewModel @JvmOverloads constructor(

// === Seeking ===

private val leftDoubleTapGesture = gesturePreferences.leftDoubleTapGesture.get()
private val centerDoubleTapGesture = gesturePreferences.centerDoubleTapGesture.get()
private val rightDoubleTapGesture = gesturePreferences.rightDoubleTapGesture.get()
private val doubleTapToSeekDuration = gesturePreferences.skipLengthPreference.get()
private val showSeekBar = gesturePreferences.showSeekBar.get()

fun updateGestureSeekAmount(value: Pair<Int, Int>?) {
updatePlaybackData { it.copy(gestureSeekAmount = value) }
}
Expand Down Expand Up @@ -2241,8 +2240,6 @@ class PlayerViewModel @JvmOverloads constructor(
super.onCleared()
}

private val progress = playerPreferences.progressPreference.get()

/**
* Called every time a second is reached in the player. Used to mark the flag of episode being
* seen, update tracking services, enqueue downloaded episode deletion and download next episode.
Expand Down Expand Up @@ -2411,9 +2408,6 @@ class PlayerViewModel @JvmOverloads constructor(
}
}

private var episodeToDownload: Download? = null
private val downloadAheadAmount = downloadPreferences.autoDownloadWhileWatching.get()

private fun downloadNextEpisodes() {
if (downloadAheadAmount == 0) return
val anime = stateData.value.currentAnime ?: return
Expand Down
Loading