android implementation

This commit is contained in:
Alex Kim
2026-01-10 05:27:11 +11:00
parent 2ead569fb7
commit 4f1567bfb3
253 changed files with 1723 additions and 68 deletions

View File

@@ -115,6 +115,18 @@ final class MPVLayerRenderer {
checkError(mpv_set_option_string(handle, "hwdec", "videotoolbox"))
checkError(mpv_set_option_string(handle, "hwdec-codecs", "all"))
checkError(mpv_set_option_string(handle, "hwdec-software-fallback", "no"))
// Seeking optimization - faster seeking at the cost of less precision
// Use keyframe seeking by default (much faster for network streams)
checkError(mpv_set_option_string(handle, "hr-seek", "no"))
// Drop frames during seeking for faster response
checkError(mpv_set_option_string(handle, "hr-seek-framedrop", "yes"))
// Demuxer cache settings for better network streaming
checkError(mpv_set_option_string(handle, "cache", "yes"))
checkError(mpv_set_option_string(handle, "demuxer-max-bytes", "150MiB"))
checkError(mpv_set_option_string(handle, "demuxer-max-back-bytes", "75MiB"))
checkError(mpv_set_option_string(handle, "demuxer-readahead-secs", "20"))
// Subtitle and audio settings
checkError(mpv_set_option_string(mpv, "subs-match-os-language", "yes"))
@@ -369,8 +381,18 @@ final class MPVLayerRenderer {
}
}
case MPV_EVENT_SEEK:
// Seek started - show loading indicator
if !isLoading {
isLoading = true
DispatchQueue.main.async { [weak self] in
guard let self else { return }
self.delegate?.renderer(self, didChangeLoading: true)
}
}
case MPV_EVENT_PLAYBACK_RESTART:
// Video playback has started/restarted
// Video playback has started/restarted (including after seek)
if isLoading {
isLoading = false
DispatchQueue.main.async { [weak self] in

View File

@@ -109,6 +109,9 @@ final class PiPController: NSObject {
}
func updatePlaybackState() {
// Only invalidate when PiP is active to avoid "no context menu visible" warnings
guard isPictureInPictureActive else { return }
if Thread.isMainThread {
pipController?.invalidatePlaybackState()
} else {
@@ -127,8 +130,10 @@ final class PiPController: NSObject {
CMTimebaseSetTime(tb, time: time)
}
// Always invalidate to refresh the PiP UI
updatePlaybackState()
// Only invalidate when PiP is active to avoid unnecessary updates
if isPictureInPictureActive {
updatePlaybackState()
}
}
/// Updates the current playback time from seconds