mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-22 12:48:15 +03:00
feat(player): Set mpv's media-title property (#1672)
This commit is contained in:
parent
5c0d507f85
commit
c51100d0b5
2 changed files with 22 additions and 0 deletions
|
@ -112,6 +112,8 @@ import java.io.IOException
|
|||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.roundToInt
|
||||
import `is`.xyz.mpv.MPVView.Chapter as VideoChapter
|
||||
|
||||
|
@ -1735,6 +1737,7 @@ class PlayerActivity : BaseActivity() {
|
|||
// at void is.xyz.mpv.MPVLib.event(int) (MPVLib.java:86)
|
||||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
internal suspend fun fileLoaded() {
|
||||
setMpvMediaTitle()
|
||||
val localLangName = LocaleHelper.getSimpleLocaleDisplayName()
|
||||
clearTracks()
|
||||
player.loadTracks()
|
||||
|
@ -1827,6 +1830,24 @@ class PlayerActivity : BaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setMpvMediaTitle() {
|
||||
val anime = viewModel.currentAnime ?: return
|
||||
val episode = viewModel.currentEpisode ?: return
|
||||
|
||||
val epNumber = episode.episode_number.let { number ->
|
||||
if (ceil(number) == floor(number)) number.toInt() else number
|
||||
}.toString().padStart(2, '0')
|
||||
|
||||
val title = stringResource(
|
||||
MR.strings.mpv_media_title,
|
||||
anime.title,
|
||||
epNumber,
|
||||
episode.name,
|
||||
)
|
||||
|
||||
MPVLib.setPropertyString("force-media-title", title)
|
||||
}
|
||||
|
||||
private var aniskipStamps: List<Stamp> = emptyList()
|
||||
|
||||
private fun updateChapters(stamps: List<Stamp>? = null, duration: Int? = null) {
|
||||
|
|
|
@ -903,6 +903,7 @@
|
|||
<string name="go_to_next_chapter">Next chapter</string>
|
||||
<string name="go_to_previous_chapter">Previous chapter</string>
|
||||
<string name="go_to_after_opening">Skipped opening</string>
|
||||
<string name="mpv_media_title">%1$s - E%2$s - %3$s</string>
|
||||
<string name="pref_player_smooth_seek">Enable precise seeking</string>
|
||||
<string name="pref_player_smooth_seek_summary">When enabled, seeking will not focus on keyframes, leading to slower but precise seeking</string>
|
||||
<string name="pref_player_fullscreen">Show content in display cutout</string>
|
||||
|
|
Loading…
Reference in a new issue