mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
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 
This commit is contained in:
parent
3f5ce703d2
commit
ab8bbf2bd7
12 changed files with 751 additions and 9 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue