MPV: Adjust subtitle delay/offset (#470)

**This is for MPV playback backend only!** Since this only works in MPV
for now, the option is not shown if using ExoPlayer.

Adds a setting (the gear icon during playback) to adjust the subtitle
delay.

A negative delay shows subtitles sooner. A positive delay shows them
later. For example, if a subtitle is supposed to show between
1000ms-2000ms, a negative 250ms delay will show it at 750ms-1750ms
instead.

The delay is persisted between plays of the same media & subtitle track.

Ref: #12 


![subtitle_delay](https://github.com/user-attachments/assets/824e3a28-650a-4619-9535-b67addaabf1e)
This commit is contained in:
damontecres 2025-12-15 10:06:36 -05:00 committed by GitHub
parent 3f5ce703d2
commit ab8bbf2bd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 751 additions and 9 deletions

View file

@ -45,6 +45,7 @@ import com.github.damontecres.wholphin.util.mpv.MPVLib.MpvEvent.MPV_EVENT_PLAYBA
import com.github.damontecres.wholphin.util.mpv.MPVLib.MpvEvent.MPV_EVENT_VIDEO_RECONFIG
import timber.log.Timber
import kotlin.concurrent.atomics.ExperimentalAtomicApi
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
/**
@ -799,7 +800,7 @@ class MpvPlayer(
// no-op
}
var subtitleDelay: Double
var subtitleDelaySeconds: Double
get() {
if (isReleased) return 0.0
return MPVLib.getPropertyDouble("sub-delay") ?: 0.0
@ -808,6 +809,16 @@ class MpvPlayer(
if (isReleased) return
MPVLib.setPropertyDouble("sub-delay", value)
}
var subtitleDelay: Duration
get() {
if (isReleased) return Duration.ZERO
return subtitleDelaySeconds.seconds
}
set(value) {
if (isReleased) return
subtitleDelaySeconds = value.inWholeMilliseconds / 1000.0
}
}
fun MPVLib.setPropertyColor(