Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eae40938e0 | ||
|
|
9c7cb7439f | ||
|
|
3bf7ff3d48 | ||
|
|
138c8f9fd8 | ||
|
|
3a5cab956d | ||
|
|
796db94896 | ||
|
|
d1dacae581 | ||
|
|
a62a01b9c3 | ||
|
|
ea9e1a3dc6 | ||
|
|
54ceee18a6 | ||
|
|
d0f2122944 | ||
|
|
1d739c74ec | ||
|
|
5dfc5af4c5 | ||
|
|
8a5f1ddea9 | ||
|
|
bbfe7cf783 | ||
|
|
b78bc3e869 | ||
|
|
2405cd179b | ||
|
|
fa9c5afeb8 | ||
|
|
0e84ce9166 | ||
|
|
9f81671603 | ||
|
|
15e1f0b9e2 | ||
|
|
014f9456f6 | ||
|
|
1bb4adfcf1 | ||
|
|
08399e5d37 | ||
|
|
48c9dcae1b | ||
|
|
078f6b29d5 | ||
|
|
60d1431443 | ||
|
|
17182e334f | ||
|
|
5986ac6c79 | ||
|
|
80dc5ffdc5 | ||
|
|
c02f84dba0 | ||
|
|
8acb777f65 |
@@ -1,4 +1,4 @@
|
||||
name: Update Homebrew Cask
|
||||
name: Update Packages
|
||||
|
||||
on:
|
||||
release:
|
||||
@@ -6,7 +6,7 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update-cask:
|
||||
update-homebrew:
|
||||
runs-on: macos-latest
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -43,3 +43,12 @@ jobs:
|
||||
else
|
||||
echo "No cask changes to commit."
|
||||
fi
|
||||
|
||||
update-winget:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: vedantmgoyal9/winget-releaser@v2
|
||||
with:
|
||||
identifier: edde746.Plezy
|
||||
installers-regex: 'plezy-windows-installer\.exe$'
|
||||
token: ${{ secrets.WINGET_TOKEN }}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
cask "plezy" do
|
||||
version "1.21.3"
|
||||
sha256 "81c643d9d67ed71ffa90d5ac36da6ef23fd0f71d3ae69f690cbe7710d511d74e"
|
||||
version "1.22.0"
|
||||
sha256 "94524bb6b7c4779f5416cef7d3a876e081f7ad6e737e828f790e52920b7086f4"
|
||||
|
||||
url "https://github.com/edde746/plezy/releases/download/#{version}/plezy-macos.dmg"
|
||||
name "Plezy"
|
||||
|
||||
@@ -87,8 +87,8 @@ dependencies {
|
||||
// FFmpeg audio decoder for unsupported codecs (ALAC, DTS, TrueHD, etc.)
|
||||
implementation("org.jellyfin.media3:media3-ffmpeg-decoder:1.9.0+1")
|
||||
|
||||
// libass-android for ASS/SSA subtitle rendering
|
||||
implementation("io.github.peerless2012:ass-media:0.4.0-beta01")
|
||||
// libass-android for ASS/SSA subtitle rendering (fork with font buffering fix)
|
||||
implementation(files("libs/ass-media.aar"))
|
||||
// ass-kt core library (needed for AssRender.setFontScale)
|
||||
implementation("io.github.peerless2012:ass-kt:0.4.0-beta01")
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -11,6 +11,8 @@ import android.content.res.Configuration
|
||||
import android.util.Rational
|
||||
import android.view.KeyEvent
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.content.FileProvider
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.android.RenderMode
|
||||
@@ -19,6 +21,7 @@ import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import com.edde746.plezy.exoplayer.ExoPlayerPlugin
|
||||
import com.edde746.plezy.mpv.MpvPlayerPlugin
|
||||
import com.edde746.plezy.shared.ThemeHelper
|
||||
import com.edde746.plezy.watchnext.WatchNextPlugin
|
||||
import java.io.File
|
||||
|
||||
@@ -28,7 +31,11 @@ class MainActivity : FlutterActivity() {
|
||||
private val EXTERNAL_PLAYER_CHANNEL = "app.plezy/external_player"
|
||||
private val THEME_CHANNEL = "app.plezy/theme"
|
||||
private var watchNextPlugin: WatchNextPlugin? = null
|
||||
private var cachedFlutterView: android.view.View? = null
|
||||
|
||||
// Auto PiP state
|
||||
private var autoPipReady = false
|
||||
private var autoPipWidth: Int = 16
|
||||
private var autoPipHeight: Int = 9
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// Apply persisted theme color to the window background before anything
|
||||
@@ -36,17 +43,7 @@ class MainActivity : FlutterActivity() {
|
||||
// screen and Flutter's first frame for non-default themes (e.g. OLED).
|
||||
val prefs = getSharedPreferences("plezy_prefs", Context.MODE_PRIVATE)
|
||||
val savedTheme = prefs.getString("splash_theme", null)
|
||||
if (savedTheme != null) {
|
||||
val color = when (savedTheme) {
|
||||
"oled" -> android.graphics.Color.BLACK
|
||||
"dark" -> android.graphics.Color.parseColor("#0E0F12")
|
||||
"light" -> android.graphics.Color.parseColor("#F7F7F8")
|
||||
else -> null
|
||||
}
|
||||
if (color != null) {
|
||||
window.decorView.setBackgroundColor(color)
|
||||
}
|
||||
}
|
||||
ThemeHelper.themeColor(savedTheme)?.let { window.decorView.setBackgroundColor(it) }
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -62,41 +59,41 @@ class MainActivity : FlutterActivity() {
|
||||
window.decorView.defaultFocusHighlightEnabled = false
|
||||
}
|
||||
|
||||
// Wrap the content view in a layout that intercepts DPAD key events
|
||||
// before the IME input stage, which can consume DPAD direction events
|
||||
// from virtual remotes before they reach Flutter's key handler.
|
||||
val content = findViewById<ViewGroup>(android.R.id.content)
|
||||
val wrapper = object : FrameLayout(this) {
|
||||
override fun dispatchKeyEventPreIme(event: KeyEvent): Boolean {
|
||||
when (event.keyCode) {
|
||||
KeyEvent.KEYCODE_DPAD_UP,
|
||||
KeyEvent.KEYCODE_DPAD_DOWN,
|
||||
KeyEvent.KEYCODE_DPAD_LEFT,
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT,
|
||||
KeyEvent.KEYCODE_DPAD_CENTER -> {
|
||||
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
if (!imm.isAcceptingText) {
|
||||
super.dispatchKeyEvent(event)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.dispatchKeyEventPreIme(event)
|
||||
}
|
||||
}
|
||||
while (content.childCount > 0) {
|
||||
val child = content.getChildAt(0)
|
||||
content.removeViewAt(0)
|
||||
wrapper.addView(child)
|
||||
}
|
||||
content.addView(wrapper, ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT))
|
||||
|
||||
// Handle Watch Next deep link from initial launch
|
||||
handleWatchNextIntent(intent)
|
||||
}
|
||||
|
||||
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||
// Ensure FlutterView has focus for DPAD events so they reach Flutter's
|
||||
// key event system. Without this, Android's native focus navigation can
|
||||
// consume DPAD direction events (especially from the Google TV virtual
|
||||
// remote) before they reach Flutter.
|
||||
when (event.keyCode) {
|
||||
KeyEvent.KEYCODE_DPAD_UP,
|
||||
KeyEvent.KEYCODE_DPAD_DOWN,
|
||||
KeyEvent.KEYCODE_DPAD_LEFT,
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT,
|
||||
KeyEvent.KEYCODE_DPAD_CENTER -> {
|
||||
val fv = cachedFlutterView ?: findFlutterView(window.decorView)?.also { cachedFlutterView = it }
|
||||
if (fv != null && !fv.hasFocus()) {
|
||||
fv.requestFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.dispatchKeyEvent(event)
|
||||
}
|
||||
|
||||
private fun findFlutterView(view: android.view.View): android.view.View? {
|
||||
if (view.javaClass.name.contains("FlutterView")) return view
|
||||
if (view is ViewGroup) {
|
||||
for (i in 0 until view.childCount) {
|
||||
val found = findFlutterView(view.getChildAt(i))
|
||||
if (found != null) return found
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
// Handle Watch Next deep link when app is already running
|
||||
@@ -186,15 +183,7 @@ class MainActivity : FlutterActivity() {
|
||||
// Persist for next cold start & update window background now
|
||||
getSharedPreferences("plezy_prefs", Context.MODE_PRIVATE)
|
||||
.edit().putString("splash_theme", mode).apply()
|
||||
val color = when (mode) {
|
||||
"oled" -> android.graphics.Color.BLACK
|
||||
"dark" -> android.graphics.Color.parseColor("#0E0F12")
|
||||
"light" -> android.graphics.Color.parseColor("#F7F7F8")
|
||||
else -> null
|
||||
}
|
||||
if (color != null) {
|
||||
window.decorView.setBackgroundColor(color)
|
||||
}
|
||||
ThemeHelper.themeColor(mode)?.let { window.decorView.setBackgroundColor(it) }
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
val themeId = when (mode) {
|
||||
@@ -227,15 +216,7 @@ class MainActivity : FlutterActivity() {
|
||||
return@setMethodCallHandler
|
||||
}
|
||||
|
||||
// Check if PiP permission is granted via AppOpsManager
|
||||
val appOpsManager = getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
|
||||
val pipAllowed = appOpsManager.checkOpNoThrow(
|
||||
AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
|
||||
applicationInfo.uid,
|
||||
packageName
|
||||
) == AppOpsManager.MODE_ALLOWED
|
||||
|
||||
if (!pipAllowed) {
|
||||
if (!isPipPermissionGranted()) {
|
||||
result.success(mapOf("success" to false, "errorCode" to "permission_disabled"))
|
||||
return@setMethodCallHandler
|
||||
}
|
||||
@@ -243,31 +224,10 @@ class MainActivity : FlutterActivity() {
|
||||
try {
|
||||
val width = call.argument<Int>("width") ?: 16
|
||||
val height = call.argument<Int>("height") ?: 9
|
||||
|
||||
// Android PiP requires aspect ratio between 0.418410 (5:12) and 2.39 (12:5)
|
||||
val ratio = width.toFloat() / height.toFloat()
|
||||
val clampedWidth: Int
|
||||
val clampedHeight: Int
|
||||
|
||||
when {
|
||||
ratio < 0.42f -> {
|
||||
// Too tall - clamp to minimum ratio (5:12)
|
||||
clampedWidth = 5
|
||||
clampedHeight = 12
|
||||
}
|
||||
ratio > 2.39f -> {
|
||||
// Too wide - clamp to maximum ratio (12:5)
|
||||
clampedWidth = 12
|
||||
clampedHeight = 5
|
||||
}
|
||||
else -> {
|
||||
clampedWidth = width
|
||||
clampedHeight = height
|
||||
}
|
||||
}
|
||||
val clamped = clampAspectRatio(width, height)
|
||||
|
||||
val params = PictureInPictureParams.Builder()
|
||||
.setAspectRatio(Rational(clampedWidth, clampedHeight))
|
||||
.setAspectRatio(Rational(clamped.first, clamped.second))
|
||||
.build()
|
||||
val success = enterPictureInPictureMode(params)
|
||||
if (success) {
|
||||
@@ -280,7 +240,25 @@ class MainActivity : FlutterActivity() {
|
||||
} catch (e: Exception) {
|
||||
result.success(mapOf("success" to false, "errorCode" to "unknown", "errorMessage" to (e.message ?: "Unknown error")))
|
||||
}
|
||||
} else -> result.notImplemented()
|
||||
}
|
||||
"setAutoPipReady" -> {
|
||||
autoPipReady = call.argument<Boolean>("ready") ?: false
|
||||
autoPipWidth = call.argument<Int>("width") ?: 16
|
||||
autoPipHeight = call.argument<Int>("height") ?: 9
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
try {
|
||||
val clamped = clampAspectRatio(autoPipWidth, autoPipHeight)
|
||||
val params = PictureInPictureParams.Builder()
|
||||
.setAspectRatio(Rational(clamped.first, clamped.second))
|
||||
.setAutoEnterEnabled(autoPipReady)
|
||||
.build()
|
||||
setPictureInPictureParams(params)
|
||||
} catch (_: Exception) {}
|
||||
}
|
||||
result.success(true)
|
||||
}
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,4 +272,42 @@ class MainActivity : FlutterActivity() {
|
||||
(plugin as? ExoPlayerPlugin)?.onPipModeChanged(isInPictureInPictureMode)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
super.onUserLeaveHint()
|
||||
// Auto PiP for API 26-30 (API 31+ uses setAutoEnterEnabled)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.S &&
|
||||
autoPipReady && isPipPermissionGranted()) {
|
||||
try {
|
||||
// Notify Flutter to prepare video filter before PiP
|
||||
flutterEngine?.dartExecutor?.binaryMessenger?.let { messenger ->
|
||||
MethodChannel(messenger, PIP_CHANNEL).invokeMethod("onAutoPipEntering", null)
|
||||
}
|
||||
val clamped = clampAspectRatio(autoPipWidth, autoPipHeight)
|
||||
val params = PictureInPictureParams.Builder()
|
||||
.setAspectRatio(Rational(clamped.first, clamped.second))
|
||||
.build()
|
||||
enterPictureInPictureMode(params)
|
||||
} catch (_: Exception) {}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isPipPermissionGranted(): Boolean {
|
||||
val appOpsManager = getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager
|
||||
return appOpsManager.checkOpNoThrow(
|
||||
AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
|
||||
applicationInfo.uid,
|
||||
packageName
|
||||
) == AppOpsManager.MODE_ALLOWED
|
||||
}
|
||||
|
||||
private fun clampAspectRatio(width: Int, height: Int): Pair<Int, Int> {
|
||||
val ratio = width.toFloat() / height.toFloat()
|
||||
return when {
|
||||
ratio < 0.42f -> Pair(5, 12)
|
||||
ratio > 2.39f -> Pair(12, 5)
|
||||
else -> Pair(width, height)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,26 +5,19 @@ import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.PixelFormat
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.media.AudioAttributes
|
||||
import android.media.AudioFocusRequest
|
||||
import android.media.AudioManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.Gravity
|
||||
import android.view.Surface
|
||||
import android.view.SurfaceView
|
||||
import android.view.TextureView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import android.view.WindowManager
|
||||
import android.widget.FrameLayout
|
||||
import androidx.annotation.OptIn
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.MimeTypes
|
||||
@@ -39,6 +32,7 @@ import androidx.media3.common.util.UnstableApi
|
||||
import androidx.media3.datasource.DefaultDataSource
|
||||
import androidx.media3.exoplayer.DefaultLoadControl
|
||||
import androidx.media3.exoplayer.DefaultRenderersFactory
|
||||
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector
|
||||
import androidx.media3.exoplayer.ExoPlayer
|
||||
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
|
||||
import androidx.media3.exoplayer.source.ProgressiveMediaSource
|
||||
@@ -47,14 +41,15 @@ import androidx.media3.extractor.DefaultExtractorsFactory
|
||||
import androidx.media3.extractor.mkv.MatroskaExtractor
|
||||
import androidx.media3.ui.CaptionStyleCompat
|
||||
import androidx.media3.ui.SubtitleView
|
||||
import com.edde746.plezy.shared.AudioFocusManager
|
||||
import com.edde746.plezy.shared.FlutterOverlayHelper
|
||||
import com.edde746.plezy.shared.FrameRateManager
|
||||
import io.github.peerless2012.ass.media.AssHandler
|
||||
import io.github.peerless2012.ass.media.extractor.AssMatroskaExtractor
|
||||
import io.github.peerless2012.ass.media.factory.AssRenderersFactory
|
||||
import io.github.peerless2012.ass.media.parser.AssSubtitleParserFactory
|
||||
import io.github.peerless2012.ass.media.type.AssRenderType
|
||||
import io.github.peerless2012.ass.media.widget.AssSubtitleView
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
interface ExoPlayerDelegate {
|
||||
fun onPropertyChange(name: String, value: Any?)
|
||||
@@ -78,7 +73,9 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ExoPlayerCore"
|
||||
private const val SHORT_VIDEO_LENGTH_MS = 300000L // 5 minutes
|
||||
|
||||
private const val WATCHDOG_CHECK_INTERVAL_MS = 1000L
|
||||
private const val WATCHDOG_TIMEOUT_MS = 8000L
|
||||
}
|
||||
|
||||
private var surfaceView: SurfaceView? = null
|
||||
@@ -86,24 +83,27 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
private var subtitleView: SubtitleView? = null
|
||||
private var assHandler: AssHandler? = null
|
||||
private var overlayLayoutListener: ViewTreeObserver.OnGlobalLayoutListener? = null
|
||||
private var lastVideoSize: VideoSize? = null
|
||||
private var exoPlayer: ExoPlayer? = null
|
||||
private var trackSelector: DefaultTrackSelector? = null
|
||||
private var tunnelingUserEnabled: Boolean = true
|
||||
private var tunnelingDisabledForCodec: Boolean = false
|
||||
private var pendingStartPositionMs: Long = 0L
|
||||
|
||||
// Frame watchdog: detects black screen (audio plays but 0 video frames rendered)
|
||||
private var frameWatchdogRunnable: Runnable? = null
|
||||
private var frameWatchdogStartTime: Long = 0L
|
||||
var delegate: ExoPlayerDelegate? = null
|
||||
var debugLoggingEnabled: Boolean = false
|
||||
var isInitialized: Boolean = false
|
||||
private set
|
||||
|
||||
// Frame rate matching
|
||||
private var currentVideoFps: Float = 0f
|
||||
private var displayListener: DisplayManager.DisplayListener? = null
|
||||
private var frameRateManager: FrameRateManager? = null
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
// Audio focus
|
||||
private var audioManager: AudioManager? = null
|
||||
private var audioFocusRequest: AudioFocusRequest? = null
|
||||
private var hasAudioFocus: Boolean = false
|
||||
private var wasPlayingBeforeFocusLoss: Boolean = false
|
||||
private var audioFocusManager: AudioFocusManager? = null
|
||||
|
||||
// Track state for event emission
|
||||
private var lastPosition: Long = 0
|
||||
@@ -116,33 +116,37 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
private var currentMediaUri: String? = null
|
||||
private var currentHeaders: Map<String, String>? = null
|
||||
|
||||
private val audioFocusChangeListener = AudioManager.OnAudioFocusChangeListener { focusChange ->
|
||||
when (focusChange) {
|
||||
AudioManager.AUDIOFOCUS_GAIN -> {
|
||||
Log.d(TAG, "Audio focus gained")
|
||||
hasAudioFocus = true
|
||||
if (wasPlayingBeforeFocusLoss && isInitialized) {
|
||||
exoPlayer?.play()
|
||||
wasPlayingBeforeFocusLoss = false
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS -> {
|
||||
Log.d(TAG, "Audio focus lost permanently")
|
||||
hasAudioFocus = false
|
||||
if (isInitialized) {
|
||||
wasPlayingBeforeFocusLoss = exoPlayer?.isPlaying == true
|
||||
exoPlayer?.pause()
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT,
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
|
||||
Log.d(TAG, "Audio focus lost transiently")
|
||||
hasAudioFocus = false
|
||||
if (isInitialized) {
|
||||
wasPlayingBeforeFocusLoss = exoPlayer?.isPlaying == true
|
||||
exoPlayer?.pause()
|
||||
private fun emitLog(level: String, prefix: String, message: String) {
|
||||
when (level) {
|
||||
"error" -> Log.e(TAG, "[$prefix] $message")
|
||||
"warn" -> Log.w(TAG, "[$prefix] $message")
|
||||
"info" -> Log.i(TAG, "[$prefix] $message")
|
||||
else -> Log.d(TAG, "[$prefix] $message")
|
||||
}
|
||||
if (debugLoggingEnabled) {
|
||||
delegate?.onEvent("log-message", mapOf(
|
||||
"prefix" to prefix, "level" to level, "text" to message
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
private fun redactUri(uri: String): String {
|
||||
return try {
|
||||
val parsed = Uri.parse(uri)
|
||||
val params = parsed.queryParameterNames
|
||||
if (params.isEmpty()) return uri
|
||||
val builder = parsed.buildUpon().clearQuery()
|
||||
for (name in params) {
|
||||
val lower = name.lowercase()
|
||||
if (lower.contains("token") || lower.contains("key") || lower.contains("auth")) {
|
||||
builder.appendQueryParameter(name, "[REDACTED]")
|
||||
} else {
|
||||
builder.appendQueryParameter(name, parsed.getQueryParameter(name))
|
||||
}
|
||||
}
|
||||
builder.build().toString()
|
||||
} catch (_: Exception) {
|
||||
uri
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,44 +154,9 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
|
||||
contentView.post {
|
||||
if (!isInitialized) return@post
|
||||
var flutterContainer: ViewGroup? = null
|
||||
|
||||
for (i in 0 until contentView.childCount) {
|
||||
val child = contentView.getChildAt(i)
|
||||
if (child is ViewGroup && child.javaClass.name.contains("FlutterView")) {
|
||||
flutterContainer = child
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (flutterContainer == null) {
|
||||
for (i in contentView.childCount - 1 downTo 0) {
|
||||
val child = contentView.getChildAt(i)
|
||||
if (child is ViewGroup && child != surfaceContainer && child.childCount > 0) {
|
||||
flutterContainer = child
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flutterContainer?.let { container ->
|
||||
contentView.bringChildToFront(container)
|
||||
for (j in 0 until container.childCount) {
|
||||
val flutterChild = container.getChildAt(j)
|
||||
if (flutterChild is SurfaceView) {
|
||||
// Don't use setZOrderOnTop - let Flutter render in normal view order
|
||||
// This allows SubtitleView (added via addContentView) to render above
|
||||
flutterChild.setZOrderOnTop(false)
|
||||
flutterChild.setZOrderMediaOverlay(true)
|
||||
flutterChild.holder.setFormat(PixelFormat.TRANSLUCENT)
|
||||
break
|
||||
} else if (flutterChild is TextureView) {
|
||||
flutterChild.isOpaque = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val container = FlutterOverlayHelper.findFlutterContainer(contentView, surfaceContainer)
|
||||
?: return@post
|
||||
FlutterOverlayHelper.configureFlutterZOrder(contentView, container, zOrderOnTop = false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,14 +176,34 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
}
|
||||
}
|
||||
|
||||
fun initialize(bufferSizeBytes: Int? = null): Boolean {
|
||||
fun initialize(bufferSizeBytes: Int? = null, tunnelingEnabled: Boolean = true): Boolean {
|
||||
if (isInitialized) {
|
||||
Log.d(TAG, "Already initialized")
|
||||
return true
|
||||
}
|
||||
|
||||
tunnelingUserEnabled = tunnelingEnabled
|
||||
|
||||
try {
|
||||
audioManager = activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
audioFocusManager = AudioFocusManager(
|
||||
context = activity,
|
||||
handler = handler,
|
||||
onPause = { if (isInitialized) exoPlayer?.pause() },
|
||||
onResume = { if (isInitialized) exoPlayer?.play() },
|
||||
isPaused = { exoPlayer?.isPlaying != true },
|
||||
log = { emitLog("debug", "audio", it) }
|
||||
)
|
||||
frameRateManager = FrameRateManager(
|
||||
activity = activity,
|
||||
handler = handler,
|
||||
onDisplayChanged = {
|
||||
if (exoPlayer?.isPlaying == false && audioFocusManager?.wasPlayingBeforeFocusLoss == true) {
|
||||
Log.d(TAG, "Display changed, resuming playback")
|
||||
exoPlayer?.play()
|
||||
}
|
||||
},
|
||||
log = { emitLog("info", "framerate", it) }
|
||||
)
|
||||
|
||||
// Create FrameLayout container for video (enables centering for aspect ratio)
|
||||
surfaceContainer = FrameLayout(activity).apply {
|
||||
@@ -258,30 +247,20 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
contentView.addView(surfaceContainer, 0)
|
||||
|
||||
// Find FlutterView and configure z-order
|
||||
// Video SurfaceView is at the bottom (setZOrderOnTop=false, setZOrderMediaOverlay=false)
|
||||
// Flutter SurfaceView uses setZOrderMediaOverlay to render above video and subtitles
|
||||
for (i in 0 until contentView.childCount) {
|
||||
val child = contentView.getChildAt(i)
|
||||
if (child is ViewGroup && child.javaClass.name.contains("FlutterView")) {
|
||||
contentView.bringChildToFront(child)
|
||||
for (j in 0 until child.childCount) {
|
||||
val flutterChild = child.getChildAt(j)
|
||||
if (flutterChild is SurfaceView) {
|
||||
// Use setZOrderMediaOverlay instead of setZOrderOnTop
|
||||
// This puts Flutter above video but below normal views
|
||||
flutterChild.setZOrderOnTop(false)
|
||||
flutterChild.setZOrderMediaOverlay(true)
|
||||
flutterChild.holder.setFormat(PixelFormat.TRANSLUCENT)
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
// Video SurfaceView is at the bottom, Flutter uses setZOrderMediaOverlay to render above
|
||||
FlutterOverlayHelper.findFlutterContainer(contentView, surfaceContainer)?.let { container ->
|
||||
FlutterOverlayHelper.configureFlutterZOrder(contentView, container, zOrderOnTop = false)
|
||||
}
|
||||
|
||||
ensureFlutterOverlayOnTop()
|
||||
overlayLayoutListener = ViewTreeObserver.OnGlobalLayoutListener {
|
||||
ensureFlutterOverlayOnTop()
|
||||
// Recalculate surface size on layout change (orientation/PiP transitions)
|
||||
lastVideoSize?.let { vs ->
|
||||
if (vs.width > 0 && vs.height > 0) {
|
||||
updateSurfaceViewSize(vs.width, vs.height, vs.pixelWidthHeightRatio)
|
||||
}
|
||||
}
|
||||
}
|
||||
contentView.viewTreeObserver.addOnGlobalLayoutListener(overlayLayoutListener)
|
||||
|
||||
@@ -291,7 +270,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
trackSelector = DefaultTrackSelector(activity).apply {
|
||||
setParameters(
|
||||
buildUponParameters()
|
||||
.setTunnelingEnabled(true)
|
||||
.setTunnelingEnabled(tunnelingUserEnabled)
|
||||
.setTrackTypeDisabled(C.TRACK_TYPE_TEXT, false)
|
||||
.setPreferredTextLanguage("en")
|
||||
)
|
||||
@@ -305,10 +284,19 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
|
||||
// Use DefaultRenderersFactory with FFmpeg fallback for unsupported audio codecs
|
||||
val renderersFactory = DefaultRenderersFactory(activity).apply {
|
||||
// Enable decoder fallback - if MediaCodec fails, try FFmpeg
|
||||
setEnableDecoderFallback(true)
|
||||
// Use FFmpeg decoders as fallback (not preferred over native)
|
||||
setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON)
|
||||
// Force FFmpeg for FLAC — hardware FLAC decoders (e.g. Samsung c2.sec.flac.decoder)
|
||||
// have buggy 32KB input buffer limits causing InsufficientCapacityException.
|
||||
setMediaCodecSelector { mimeType, requiresSecureDecoder, requiresTunnelingDecoder ->
|
||||
if (mimeType == MimeTypes.AUDIO_FLAC) {
|
||||
emptyList()
|
||||
} else {
|
||||
MediaCodecSelector.DEFAULT.getDecoderInfos(
|
||||
mimeType, requiresSecureDecoder, requiresTunnelingDecoder
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create factories for buildWithAssSupport (like AndroidTV-FireTV)
|
||||
@@ -369,7 +357,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
setBufferDurationsMs(30_000, 60_000, 2_500, 5_000)
|
||||
}
|
||||
}.build()
|
||||
Log.d(TAG, "Buffer: ${targetBufferBytes / 1024 / 1024}MB limit, available=${availableMB}MB")
|
||||
emitLog("info", "init", "Buffer: ${targetBufferBytes / 1024 / 1024}MB limit, available=${availableMB}MB, tunneling=${tunnelingUserEnabled}")
|
||||
|
||||
exoPlayer = ExoPlayer.Builder(activity)
|
||||
.setTrackSelector(trackSelector!!)
|
||||
@@ -417,16 +405,16 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
|
||||
private val surfaceCallback = object : android.view.SurfaceHolder.Callback {
|
||||
override fun surfaceCreated(holder: android.view.SurfaceHolder) {
|
||||
Log.d(TAG, "Surface created")
|
||||
emitLog("debug", "surface", "Created")
|
||||
ensureFlutterOverlayOnTop()
|
||||
}
|
||||
|
||||
override fun surfaceChanged(holder: android.view.SurfaceHolder, format: Int, width: Int, height: Int) {
|
||||
Log.d(TAG, "Surface changed: ${width}x${height}")
|
||||
emitLog("debug", "surface", "Changed: ${width}x${height}")
|
||||
}
|
||||
|
||||
override fun surfaceDestroyed(holder: android.view.SurfaceHolder) {
|
||||
Log.d(TAG, "Surface destroyed")
|
||||
emitLog("debug", "surface", "Destroyed")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +481,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
Player.STATE_ENDED -> "ended"
|
||||
else -> "unknown"
|
||||
}
|
||||
Log.d(TAG, "onPlaybackStateChanged: $stateStr")
|
||||
emitLog("debug", "state", stateStr)
|
||||
|
||||
when (state) {
|
||||
Player.STATE_BUFFERING -> {
|
||||
@@ -505,7 +493,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
if (pendingStartPositionMs > 0L) {
|
||||
val currentPos = exoPlayer?.currentPosition ?: 0L
|
||||
if (currentPos < 1000L) {
|
||||
Log.w(TAG, "Position lost during init (at ${currentPos}ms, expected ${pendingStartPositionMs}ms) — restoring")
|
||||
emitLog("warn", "state", "Position lost (at ${currentPos}ms, expected ${pendingStartPositionMs}ms) — restoring")
|
||||
exoPlayer?.seekTo(pendingStartPositionMs)
|
||||
}
|
||||
pendingStartPositionMs = 0L
|
||||
@@ -513,8 +501,12 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
delegate?.onPropertyChange("paused-for-cache", false)
|
||||
delegate?.onEvent("playback-restart", null)
|
||||
emitTrackList()
|
||||
|
||||
// Start frame watchdog to detect black screen (HDR tunneling issue)
|
||||
startFrameWatchdog()
|
||||
}
|
||||
Player.STATE_ENDED -> {
|
||||
stopFrameWatchdog()
|
||||
delegate?.onPropertyChange("eof-reached", true)
|
||||
delegate?.onEvent("end-file", mapOf("reason" to "eof"))
|
||||
}
|
||||
@@ -523,12 +515,28 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
|
||||
override fun onTracksChanged(tracks: Tracks) {
|
||||
Log.d(TAG, "onTracksChanged")
|
||||
// Log selected video and audio track details
|
||||
val videoGroup = tracks.groups.firstOrNull { it.type == C.TRACK_TYPE_VIDEO && it.isSelected }
|
||||
val audioGroup = tracks.groups.firstOrNull { it.type == C.TRACK_TYPE_AUDIO && it.isSelected }
|
||||
if (videoGroup != null) {
|
||||
val vf = videoGroup.mediaTrackGroup.getFormat(0)
|
||||
val hdr = vf.colorInfo?.let { ci ->
|
||||
val transfer = ci.colorTransfer
|
||||
if (transfer != null && transfer != 0) " HDR(transfer=$transfer)" else ""
|
||||
} ?: ""
|
||||
emitLog("info", "tracks", "Video: ${vf.codecs} ${vf.width}x${vf.height}$hdr")
|
||||
}
|
||||
if (audioGroup != null) {
|
||||
val af = audioGroup.mediaTrackGroup.getFormat(0)
|
||||
emitLog("info", "tracks", "Audio: ${af.codecs} ${af.channelCount}ch ${af.sampleRate}Hz")
|
||||
}
|
||||
evaluateAudioCodecForTunneling()
|
||||
emitTrackList()
|
||||
}
|
||||
|
||||
override fun onPlayerError(error: PlaybackException) {
|
||||
Log.e(TAG, "Player error: ${error.message} (code: ${error.errorCode})", error)
|
||||
emitLog("error", "player", "Error code=${error.errorCode}: ${error.message}, cause=${error.cause?.javaClass?.simpleName}")
|
||||
stopFrameWatchdog()
|
||||
|
||||
if (currentMediaUri != null) {
|
||||
Log.w(TAG, "ExoPlayer error (code ${error.errorCode}) - attempting fallback to MPV")
|
||||
@@ -556,6 +564,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
|
||||
override fun onVideoSizeChanged(videoSize: VideoSize) {
|
||||
Log.d(TAG, "Video size changed: ${videoSize.width}x${videoSize.height}, ratio: ${videoSize.pixelWidthHeightRatio}")
|
||||
lastVideoSize = videoSize
|
||||
updateSurfaceViewSize(videoSize.width, videoSize.height, videoSize.pixelWidthHeightRatio)
|
||||
}
|
||||
|
||||
@@ -711,6 +720,9 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
// Tunneling control — disabled when audio codec has no hardware decoder (requires FFmpeg)
|
||||
|
||||
private fun hasHardwareAudioDecoder(mimeType: String): Boolean {
|
||||
// FLAC hardware decoders are excluded via MediaCodecSelector (Samsung c2.sec.flac.decoder
|
||||
// has buggy 32KB input buffer limits), so report no hardware decoder for tunneling purposes.
|
||||
if (mimeType == MimeTypes.AUDIO_FLAC) return false
|
||||
try {
|
||||
val codecList = android.media.MediaCodecList(android.media.MediaCodecList.REGULAR_CODECS)
|
||||
for (info in codecList.codecInfos) {
|
||||
@@ -739,10 +751,10 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
val selector = trackSelector ?: return
|
||||
val player = exoPlayer ?: return
|
||||
val currentSpeed = player.playbackParameters.speed
|
||||
val shouldTunnel = (currentSpeed == 1f) && !tunnelingDisabledForCodec
|
||||
val shouldTunnel = tunnelingUserEnabled && (currentSpeed == 1f) && !tunnelingDisabledForCodec
|
||||
val currentTunneling = selector.parameters.tunnelingEnabled
|
||||
if (shouldTunnel == currentTunneling) return // No change needed
|
||||
Log.d(TAG, "updateTunnelingState: tunneling $currentTunneling -> $shouldTunnel")
|
||||
emitLog("info", "tunneling", "tunneling $currentTunneling -> $shouldTunnel (user=$tunnelingUserEnabled, speed=$currentSpeed, codecDisabled=$tunnelingDisabledForCodec)")
|
||||
selector.setParameters(
|
||||
selector.buildUponParameters()
|
||||
.setTunnelingEnabled(shouldTunnel)
|
||||
@@ -766,11 +778,61 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
val newDisabled = !hasHardwareAudioDecoder(mimeType)
|
||||
if (newDisabled != tunnelingDisabledForCodec) {
|
||||
tunnelingDisabledForCodec = newDisabled
|
||||
Log.i(TAG, "Audio codec ${format.codecs} ($mimeType): tunneling ${if (newDisabled) "DISABLED" else "enabled"}")
|
||||
emitLog("info", "tunneling", "Audio codec ${format.codecs} ($mimeType): tunneling ${if (newDisabled) "DISABLED (no hw decoder)" else "enabled"}")
|
||||
updateTunnelingState()
|
||||
}
|
||||
}
|
||||
|
||||
// Frame watchdog: detects when ExoPlayer plays audio but renders 0 video frames
|
||||
// (common with HDR tunneling on unsupported devices — black screen, no error)
|
||||
|
||||
private fun startFrameWatchdog() {
|
||||
stopFrameWatchdog()
|
||||
emitLog("debug", "watchdog", "Started (timeout=${WATCHDOG_TIMEOUT_MS}ms)")
|
||||
frameWatchdogStartTime = System.currentTimeMillis()
|
||||
frameWatchdogRunnable = object : Runnable {
|
||||
override fun run() {
|
||||
val player = exoPlayer ?: return
|
||||
val renderedFrames = player.videoDecoderCounters?.renderedOutputBufferCount ?: 0
|
||||
|
||||
if (renderedFrames > 0) {
|
||||
emitLog("debug", "watchdog", "$renderedFrames frames rendered, cleared")
|
||||
stopFrameWatchdog()
|
||||
return
|
||||
}
|
||||
|
||||
val elapsed = System.currentTimeMillis() - frameWatchdogStartTime
|
||||
|
||||
// Check if we have a video track selected
|
||||
val hasVideoTrack = player.currentTracks.groups.any {
|
||||
it.type == C.TRACK_TYPE_VIDEO && it.isSelected
|
||||
}
|
||||
|
||||
if (elapsed >= WATCHDOG_TIMEOUT_MS && player.isPlaying && hasVideoTrack) {
|
||||
emitLog("warn", "watchdog", "0 frames rendered after ${elapsed}ms — triggering fallback")
|
||||
stopFrameWatchdog()
|
||||
// Trigger fallback via the same delegate path as player errors
|
||||
val uri = currentMediaUri ?: return
|
||||
delegate?.onFormatUnsupported(
|
||||
uri = uri,
|
||||
headers = currentHeaders,
|
||||
positionMs = player.currentPosition,
|
||||
errorMessage = "Black screen detected: 0 video frames rendered after ${elapsed}ms"
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
handler.postDelayed(this, WATCHDOG_CHECK_INTERVAL_MS)
|
||||
}
|
||||
}
|
||||
handler.postDelayed(frameWatchdogRunnable!!, WATCHDOG_CHECK_INTERVAL_MS)
|
||||
}
|
||||
|
||||
private fun stopFrameWatchdog() {
|
||||
frameWatchdogRunnable?.let { handler.removeCallbacks(it) }
|
||||
frameWatchdogRunnable = null
|
||||
}
|
||||
|
||||
// Public API
|
||||
|
||||
fun open(uri: String, headers: Map<String, String>?, startPositionMs: Long, autoPlay: Boolean, isLive: Boolean = false) {
|
||||
@@ -807,7 +869,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
playWhenReady = autoPlay
|
||||
}
|
||||
|
||||
Log.d(TAG, "Opened live: $uri, startPosition: ${startPositionMs}ms, autoPlay: $autoPlay")
|
||||
emitLog("info", "media", "Opened live: ${redactUri(uri)}, startPosition: ${startPositionMs}ms, autoPlay: $autoPlay")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -830,7 +892,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
playWhenReady = autoPlay
|
||||
}
|
||||
|
||||
Log.d(TAG, "Opened: $uri, startPosition: ${startPositionMs}ms, autoPlay: $autoPlay")
|
||||
emitLog("info", "media", "Opened: ${redactUri(uri)}, startPosition: ${startPositionMs}ms, autoPlay: $autoPlay, tunneling=$tunnelingUserEnabled")
|
||||
}
|
||||
|
||||
fun play() {
|
||||
@@ -842,6 +904,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
stopFrameWatchdog()
|
||||
exoPlayer?.stop()
|
||||
setVisible(false)
|
||||
}
|
||||
@@ -886,7 +949,7 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
}
|
||||
|
||||
val currentSpeed = player.playbackParameters.speed
|
||||
val shouldTunnel = (currentSpeed == 1f) && !tunnelingDisabledForCodec
|
||||
val shouldTunnel = tunnelingUserEnabled && (currentSpeed == 1f) && !tunnelingDisabledForCodec
|
||||
|
||||
selector.parameters = selector.buildUponParameters()
|
||||
.setOverrideForType(TrackSelectionOverride(group.mediaTrackGroup, 0))
|
||||
@@ -1083,213 +1146,18 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
|
||||
// Audio Focus
|
||||
|
||||
fun requestAudioFocus(): Boolean {
|
||||
val am = audioManager ?: return false
|
||||
fun requestAudioFocus(): Boolean = audioFocusManager?.requestAudioFocus() ?: false
|
||||
|
||||
Log.d(TAG, "Requesting audio focus")
|
||||
|
||||
val result = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val focusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
|
||||
.setAudioAttributes(
|
||||
AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_MEDIA)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MOVIE)
|
||||
.build()
|
||||
)
|
||||
.setOnAudioFocusChangeListener(audioFocusChangeListener, handler)
|
||||
.setWillPauseWhenDucked(true)
|
||||
.build()
|
||||
|
||||
audioFocusRequest = focusRequest
|
||||
am.requestAudioFocus(focusRequest)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
am.requestAudioFocus(
|
||||
audioFocusChangeListener,
|
||||
AudioManager.STREAM_MUSIC,
|
||||
AudioManager.AUDIOFOCUS_GAIN
|
||||
)
|
||||
}
|
||||
|
||||
hasAudioFocus = (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED)
|
||||
Log.d(TAG, "Audio focus request result: $result, granted: $hasAudioFocus")
|
||||
return hasAudioFocus
|
||||
}
|
||||
|
||||
fun abandonAudioFocus() {
|
||||
val am = audioManager ?: return
|
||||
|
||||
Log.d(TAG, "Abandoning audio focus")
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
audioFocusRequest?.let { am.abandonAudioFocusRequest(it) }
|
||||
audioFocusRequest = null
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
am.abandonAudioFocus(audioFocusChangeListener)
|
||||
}
|
||||
|
||||
hasAudioFocus = false
|
||||
wasPlayingBeforeFocusLoss = false
|
||||
}
|
||||
fun abandonAudioFocus() { audioFocusManager?.abandonAudioFocus() }
|
||||
|
||||
// Frame Rate Matching
|
||||
|
||||
private fun getDisplayManager(): DisplayManager {
|
||||
return activity.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||
}
|
||||
|
||||
fun setVideoFrameRate(fps: Float, videoDurationMs: Long) {
|
||||
currentVideoFps = fps
|
||||
if (fps <= 0f) {
|
||||
Log.d(TAG, "setVideoFrameRate: Invalid fps ($fps), skipping")
|
||||
return
|
||||
}
|
||||
|
||||
val surface = surfaceView?.holder?.surface
|
||||
if (surface == null) {
|
||||
Log.d(TAG, "setVideoFrameRate: Surface not available")
|
||||
return
|
||||
}
|
||||
|
||||
Log.d(TAG, "setVideoFrameRate: fps=$fps, duration=${videoDurationMs}ms, API=${Build.VERSION.SDK_INT}")
|
||||
|
||||
when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> setFrameRateS(fps, surface, videoDurationMs)
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> setFrameRateR(fps, surface)
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> setFrameRateM(fps)
|
||||
}
|
||||
frameRateManager?.setVideoFrameRate(fps, videoDurationMs, surfaceView?.holder?.surface)
|
||||
}
|
||||
|
||||
fun clearVideoFrameRate() {
|
||||
Log.d(TAG, "clearVideoFrameRate")
|
||||
currentVideoFps = 0f
|
||||
displayListener?.let {
|
||||
getDisplayManager().unregisterDisplayListener(it)
|
||||
displayListener = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerDisplayListener() {
|
||||
displayListener?.let {
|
||||
getDisplayManager().unregisterDisplayListener(it)
|
||||
}
|
||||
|
||||
displayListener = object : DisplayManager.DisplayListener {
|
||||
override fun onDisplayAdded(displayId: Int) = Unit
|
||||
override fun onDisplayRemoved(displayId: Int) = Unit
|
||||
override fun onDisplayChanged(displayId: Int) {
|
||||
handler.postDelayed({
|
||||
if (exoPlayer?.isPlaying == false && wasPlayingBeforeFocusLoss) {
|
||||
Log.d(TAG, "Display changed, resuming playback")
|
||||
exoPlayer?.play()
|
||||
}
|
||||
}, 2000L)
|
||||
getDisplayManager().unregisterDisplayListener(this)
|
||||
displayListener = null
|
||||
}
|
||||
}
|
||||
getDisplayManager().registerDisplayListener(displayListener, handler)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun setFrameRateR(fps: Float, surface: Surface) {
|
||||
Log.d(TAG, "setFrameRateR: Setting frame rate to $fps")
|
||||
surface.setFrameRate(fps, Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE)
|
||||
registerDisplayListener()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.S)
|
||||
private fun setFrameRateS(fps: Float, surface: Surface, videoDurationMs: Long) {
|
||||
Log.d(TAG, "setFrameRateS: fps=$fps, duration=${videoDurationMs}ms")
|
||||
|
||||
if (videoDurationMs < SHORT_VIDEO_LENGTH_MS) {
|
||||
Log.d(TAG, "Short video, using seamless-only switching")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
var seamless = false
|
||||
activity.display?.mode?.alternativeRefreshRates?.let { refreshRates ->
|
||||
for (rate in refreshRates) {
|
||||
if (fps.toString().startsWith(rate.toString()) ||
|
||||
rate.toString().startsWith(fps.toString()) ||
|
||||
rate % fps == 0f) {
|
||||
seamless = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (seamless) {
|
||||
Log.d(TAG, "Seamless switch available, using CHANGE_FRAME_RATE_ALWAYS")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ALWAYS
|
||||
)
|
||||
registerDisplayListener()
|
||||
} else {
|
||||
val userPreference = getDisplayManager().matchContentFrameRateUserPreference
|
||||
if (userPreference == DisplayManager.MATCH_CONTENT_FRAMERATE_ALWAYS) {
|
||||
Log.d(TAG, "User preference allows non-seamless switch")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ALWAYS
|
||||
)
|
||||
registerDisplayListener()
|
||||
} else {
|
||||
Log.d(TAG, "Non-seamless switch not allowed, using seamless-only")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun setFrameRateM(fps: Float) {
|
||||
Log.d(TAG, "setFrameRateM: fps=$fps")
|
||||
val wm = activity.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
@Suppress("DEPRECATION")
|
||||
val display = wm.defaultDisplay ?: return
|
||||
|
||||
display.supportedModes?.let { supportedModes ->
|
||||
val currentMode = display.mode
|
||||
var modeToUse = currentMode
|
||||
|
||||
for (mode in supportedModes) {
|
||||
if (mode.physicalHeight != currentMode.physicalHeight ||
|
||||
mode.physicalWidth != currentMode.physicalWidth) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (BigDecimal(fps.toString()).setScale(1, RoundingMode.FLOOR) ==
|
||||
BigDecimal(mode.refreshRate.toString()).setScale(1, RoundingMode.FLOOR)) {
|
||||
modeToUse = mode
|
||||
break
|
||||
} else if (mode.refreshRate % fps == 0f) {
|
||||
modeToUse = mode
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (modeToUse != currentMode) {
|
||||
Log.d(TAG, "Switching to mode ${modeToUse.modeId} (${modeToUse.refreshRate}Hz)")
|
||||
activity.window?.attributes?.let { attrs ->
|
||||
attrs.preferredDisplayModeId = modeToUse.modeId
|
||||
activity.window?.attributes = attrs
|
||||
}
|
||||
registerDisplayListener()
|
||||
}
|
||||
}
|
||||
frameRateManager?.clearVideoFrameRate()
|
||||
}
|
||||
|
||||
// Stats
|
||||
@@ -1366,10 +1234,12 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
fun dispose() {
|
||||
Log.d(TAG, "Disposing")
|
||||
|
||||
stopFrameWatchdog()
|
||||
stopPositionUpdates()
|
||||
clearVideoFrameRate()
|
||||
abandonAudioFocus()
|
||||
audioManager = null
|
||||
frameRateManager?.clearVideoFrameRate()
|
||||
frameRateManager = null
|
||||
audioFocusManager?.release()
|
||||
audioFocusManager = null
|
||||
|
||||
tunnelingDisabledForCodec = false
|
||||
pendingStartPositionMs = 0L
|
||||
@@ -1380,23 +1250,21 @@ class ExoPlayerCore(private val activity: Activity) : Player.Listener {
|
||||
trackSelector = null
|
||||
assHandler = null
|
||||
|
||||
surfaceView?.holder?.removeCallback(surfaceCallback)
|
||||
val cb = surfaceCallback
|
||||
val sv = surfaceView
|
||||
overlayLayoutListener?.let { listener ->
|
||||
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
|
||||
contentView.viewTreeObserver.removeOnGlobalLayoutListener(listener)
|
||||
}
|
||||
overlayLayoutListener = null
|
||||
|
||||
// Remove SurfaceView from container synchronously — triggers
|
||||
// onDetachedFromWindow which properly unregisters PositionUpdateListener
|
||||
// and releases SurfaceControl before the render thread can access it.
|
||||
// Defer all view removal to avoid AOSP bug where
|
||||
// dispatchWindowVisibilityChanged iterates stale children array
|
||||
// when removeView() runs during an active performTraversals pass.
|
||||
val container = surfaceContainer
|
||||
surfaceView?.let { container?.removeView(it) }
|
||||
subtitleView?.let { container?.removeView(it) }
|
||||
|
||||
// Defer empty container removal (plain FrameLayout, no SurfaceControl)
|
||||
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
|
||||
contentView.post {
|
||||
sv?.holder?.removeCallback(cb)
|
||||
container?.let { contentView.removeView(it) }
|
||||
}
|
||||
surfaceContainer = null
|
||||
|
||||
@@ -34,6 +34,8 @@ class ExoPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
|
||||
private var activityBinding: ActivityPluginBinding? = null
|
||||
private val nameToId = mutableMapOf<String, Int>()
|
||||
private var configuredBufferSizeBytes: Int? = null
|
||||
private var configuredTunnelingEnabled: Boolean = true
|
||||
private var debugLoggingEnabled: Boolean = false
|
||||
|
||||
// FlutterPlugin
|
||||
|
||||
@@ -130,6 +132,12 @@ class ExoPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
|
||||
}
|
||||
"setSubtitleStyle" -> handleSetSubtitleStyle(call, result)
|
||||
"observeProperty" -> handleObserveProperty(call, result)
|
||||
"setLogLevel" -> {
|
||||
val level = call.argument<String>("level") ?: "warn"
|
||||
debugLoggingEnabled = (level == "v" || level == "debug" || level == "trace")
|
||||
playerCore?.debugLoggingEnabled = debugLoggingEnabled
|
||||
result.success(null)
|
||||
}
|
||||
else -> result.notImplemented()
|
||||
}
|
||||
}
|
||||
@@ -148,14 +156,20 @@ class ExoPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
|
||||
}
|
||||
|
||||
val bufferSizeBytes = call.argument<Int>("bufferSizeBytes")
|
||||
val tunnelingEnabled = call.argument<Boolean>("tunnelingEnabled") ?: true
|
||||
configuredBufferSizeBytes = bufferSizeBytes
|
||||
configuredTunnelingEnabled = tunnelingEnabled
|
||||
|
||||
currentActivity.runOnUiThread {
|
||||
try {
|
||||
playerCore = ExoPlayerCore(currentActivity).apply {
|
||||
delegate = this@ExoPlayerPlugin
|
||||
this.debugLoggingEnabled = this@ExoPlayerPlugin.debugLoggingEnabled
|
||||
}
|
||||
val success = playerCore?.initialize(bufferSizeBytes = bufferSizeBytes) ?: false
|
||||
val success = playerCore?.initialize(
|
||||
bufferSizeBytes = bufferSizeBytes,
|
||||
tunnelingEnabled = tunnelingEnabled,
|
||||
) ?: false
|
||||
|
||||
// Start hidden
|
||||
playerCore?.setVisible(false)
|
||||
@@ -478,7 +492,9 @@ class ExoPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
|
||||
private fun getMpvStats(): Map<String, Any?> {
|
||||
val mpv = mpvCore ?: return mapOf("playerType" to "mpv")
|
||||
|
||||
return mapOf(
|
||||
val hasVideo = mpv.getProperty("video-params/w") != null
|
||||
|
||||
val stats = mutableMapOf<String, Any?>(
|
||||
"playerType" to "mpv",
|
||||
// Video metrics
|
||||
"video-codec" to mpv.getProperty("video-codec"),
|
||||
@@ -495,27 +511,32 @@ class ExoPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
|
||||
"audio-bitrate" to mpv.getProperty("audio-bitrate"),
|
||||
// Performance metrics
|
||||
"total-avsync-change" to mpv.getProperty("total-avsync-change"),
|
||||
"cache-used" to mpv.getProperty("cache-used"),
|
||||
"cache-speed" to mpv.getProperty("cache-speed"),
|
||||
"display-fps" to mpv.getProperty("display-fps"),
|
||||
"frame-drop-count" to mpv.getProperty("frame-drop-count"),
|
||||
"decoder-frame-drop-count" to mpv.getProperty("decoder-frame-drop-count"),
|
||||
"demuxer-cache-duration" to mpv.getProperty("demuxer-cache-duration"),
|
||||
// Color/Format properties
|
||||
"video-params/pixelformat" to mpv.getProperty("video-params/pixelformat"),
|
||||
"video-params/hw-pixelformat" to mpv.getProperty("video-params/hw-pixelformat"),
|
||||
"video-params/colormatrix" to mpv.getProperty("video-params/colormatrix"),
|
||||
"video-params/primaries" to mpv.getProperty("video-params/primaries"),
|
||||
"video-params/gamma" to mpv.getProperty("video-params/gamma"),
|
||||
// HDR metadata
|
||||
"video-params/max-luma" to mpv.getProperty("video-params/max-luma"),
|
||||
"video-params/min-luma" to mpv.getProperty("video-params/min-luma"),
|
||||
"video-params/max-cll" to mpv.getProperty("video-params/max-cll"),
|
||||
"video-params/max-fall" to mpv.getProperty("video-params/max-fall"),
|
||||
// Other
|
||||
"video-params/aspect-name" to mpv.getProperty("video-params/aspect-name"),
|
||||
"video-params/rotate" to mpv.getProperty("video-params/rotate")
|
||||
)
|
||||
|
||||
// Only query properties that require an active video track
|
||||
if (hasVideo) {
|
||||
stats["display-fps"] = mpv.getProperty("display-fps")
|
||||
// Color/Format properties
|
||||
stats["video-params/pixelformat"] = mpv.getProperty("video-params/pixelformat")
|
||||
stats["video-params/hw-pixelformat"] = mpv.getProperty("video-params/hw-pixelformat")
|
||||
stats["video-params/colormatrix"] = mpv.getProperty("video-params/colormatrix")
|
||||
stats["video-params/primaries"] = mpv.getProperty("video-params/primaries")
|
||||
stats["video-params/gamma"] = mpv.getProperty("video-params/gamma")
|
||||
// HDR metadata
|
||||
stats["video-params/max-luma"] = mpv.getProperty("video-params/max-luma")
|
||||
stats["video-params/min-luma"] = mpv.getProperty("video-params/min-luma")
|
||||
stats["video-params/max-cll"] = mpv.getProperty("video-params/max-cll")
|
||||
stats["video-params/max-fall"] = mpv.getProperty("video-params/max-fall")
|
||||
// Other
|
||||
stats["video-params/aspect-name"] = mpv.getProperty("video-params/aspect-name")
|
||||
stats["video-params/rotate"] = mpv.getProperty("video-params/rotate")
|
||||
}
|
||||
|
||||
return stats
|
||||
}
|
||||
|
||||
// PiP Mode handling
|
||||
@@ -580,6 +601,12 @@ class ExoPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
|
||||
fallbackInProgress = true
|
||||
|
||||
Log.i(TAG, "ExoPlayer error, switching to MPV fallback at ${positionMs}ms: $errorMessage")
|
||||
if (debugLoggingEnabled) {
|
||||
onEvent("log-message", mapOf(
|
||||
"prefix" to "fallback", "level" to "warn",
|
||||
"text" to "Switching to MPV at ${positionMs}ms: $errorMessage"
|
||||
))
|
||||
}
|
||||
|
||||
currentActivity.runOnUiThread {
|
||||
try {
|
||||
@@ -605,7 +632,7 @@ class ExoPlayerPlugin : FlutterPlugin, MethodChannel.MethodCallHandler,
|
||||
fallbackInProgress = false
|
||||
|
||||
// Configure basic MPV properties for Plex playback
|
||||
mpvCore?.setProperty("hwdec", "auto")
|
||||
mpvCore?.setProperty("hwdec", "mediacodec,mediacodec-copy")
|
||||
mpvCore?.setProperty("vo", "gpu")
|
||||
mpvCore?.setProperty("ao", "audiotrack")
|
||||
|
||||
|
||||
@@ -3,11 +3,6 @@ package com.edde746.plezy.mpv
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.PixelFormat
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.media.AudioAttributes
|
||||
import android.media.AudioFocusRequest
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
@@ -18,13 +13,11 @@ import android.view.SurfaceView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import android.view.TextureView
|
||||
import android.view.WindowManager
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.edde746.plezy.shared.AudioFocusManager
|
||||
import com.edde746.plezy.shared.FlutterOverlayHelper
|
||||
import com.edde746.plezy.shared.FrameRateManager
|
||||
import dev.jdtech.mpv.MPVLib
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
interface MpvPlayerDelegate {
|
||||
@@ -39,7 +32,6 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MpvPlayerCore"
|
||||
private const val SHORT_VIDEO_LENGTH_MS = 300000L // 5 minutes
|
||||
|
||||
// Guards MPVLib.create/destroy which share global native state
|
||||
private val mpvLock = Object()
|
||||
@@ -49,10 +41,10 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
private var surfaceContainer: android.widget.FrameLayout? = null
|
||||
private var overlayLayoutListener: ViewTreeObserver.OnGlobalLayoutListener? =
|
||||
null
|
||||
private var voInUse: String = "gpu"
|
||||
@Volatile private var nativeReady: Boolean = false
|
||||
@Volatile private var disposing: Boolean = false
|
||||
private var pendingSurface: Surface? = null
|
||||
private var lastSurfaceSize: String? = null
|
||||
var delegate: MpvPlayerDelegate? = null
|
||||
var isInitialized: Boolean = false
|
||||
private set
|
||||
@@ -61,126 +53,27 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
private val commandExecutor = Executors.newSingleThreadExecutor()
|
||||
|
||||
// Frame rate matching
|
||||
private var currentVideoFps: Float = 0f
|
||||
private var displayListener: DisplayManager.DisplayListener? = null
|
||||
private var frameRateManager: FrameRateManager? = null
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
// Audio focus
|
||||
private var audioManager: AudioManager? = null
|
||||
private var audioFocusRequest: AudioFocusRequest? = null
|
||||
private var hasAudioFocus: Boolean = false
|
||||
private var wasPlayingBeforeFocusLoss: Boolean = false
|
||||
private var audioFocusManager: AudioFocusManager? = null
|
||||
|
||||
private val audioFocusChangeListener = AudioManager.OnAudioFocusChangeListener { focusChange ->
|
||||
when (focusChange) {
|
||||
AudioManager.AUDIOFOCUS_GAIN -> {
|
||||
Log.d(TAG, "Audio focus gained")
|
||||
hasAudioFocus = true
|
||||
// Resume playback if we were playing before focus loss
|
||||
if (wasPlayingBeforeFocusLoss && isInitialized) {
|
||||
try {
|
||||
MPVLib.setPropertyBoolean("pause", false)
|
||||
wasPlayingBeforeFocusLoss = false
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to resume playback after focus gain", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS -> {
|
||||
Log.d(TAG, "Audio focus lost permanently")
|
||||
hasAudioFocus = false
|
||||
// Pause playback on permanent focus loss
|
||||
if (isInitialized) {
|
||||
try {
|
||||
val isPaused = MPVLib.getPropertyBoolean("pause")
|
||||
wasPlayingBeforeFocusLoss = !isPaused
|
||||
if (!isPaused) {
|
||||
MPVLib.setPropertyBoolean("pause", true)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to pause on focus loss", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
|
||||
Log.d(TAG, "Audio focus lost transiently")
|
||||
hasAudioFocus = false
|
||||
// Pause playback, remember to resume
|
||||
if (isInitialized) {
|
||||
try {
|
||||
val isPaused = MPVLib.getPropertyBoolean("pause")
|
||||
wasPlayingBeforeFocusLoss = !isPaused
|
||||
if (!isPaused) {
|
||||
MPVLib.setPropertyBoolean("pause", true)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to pause on transient focus loss", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
|
||||
Log.d(TAG, "Audio focus lost transiently (can duck)")
|
||||
// For video content, we pause instead of ducking
|
||||
// since dialogue is typically important
|
||||
hasAudioFocus = false
|
||||
if (isInitialized) {
|
||||
try {
|
||||
val isPaused = MPVLib.getPropertyBoolean("pause")
|
||||
wasPlayingBeforeFocusLoss = !isPaused
|
||||
if (!isPaused) {
|
||||
MPVLib.setPropertyBoolean("pause", true)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to pause on duck focus loss", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private var flutterOverlayApplied = false
|
||||
|
||||
private fun ensureFlutterOverlayOnTop() {
|
||||
if (flutterOverlayApplied) return
|
||||
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
|
||||
contentView.post {
|
||||
if (!isInitialized) return@post
|
||||
var flutterContainer: ViewGroup? = null
|
||||
|
||||
// First pass: look for FlutterView by name (debug builds)
|
||||
for (i in 0 until contentView.childCount) {
|
||||
val child = contentView.getChildAt(i)
|
||||
if (child is ViewGroup && child.javaClass.name.contains("FlutterView")) {
|
||||
flutterContainer = child
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for release (FlutterView may be obfuscated): pick the last ViewGroup
|
||||
// that is not our mpv container and has children.
|
||||
if (flutterContainer == null) {
|
||||
for (i in contentView.childCount - 1 downTo 0) {
|
||||
val child = contentView.getChildAt(i)
|
||||
if (child is ViewGroup && child != surfaceContainer && child.childCount > 0) {
|
||||
flutterContainer = child
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flutterContainer?.let { container ->
|
||||
contentView.bringChildToFront(container)
|
||||
for (j in 0 until container.childCount) {
|
||||
val flutterChild = container.getChildAt(j)
|
||||
if (flutterChild is SurfaceView) {
|
||||
flutterChild.setZOrderOnTop(true)
|
||||
flutterChild.setZOrderMediaOverlay(true)
|
||||
flutterChild.holder.setFormat(PixelFormat.TRANSLUCENT)
|
||||
break
|
||||
} else if (flutterChild is TextureView) {
|
||||
// TextureView uses alpha composition; ensure it stays above.
|
||||
flutterChild.isOpaque = false
|
||||
break
|
||||
}
|
||||
}
|
||||
val container = FlutterOverlayHelper.findFlutterContainer(contentView, surfaceContainer)
|
||||
?: return@post
|
||||
if (contentView.getChildAt(contentView.childCount - 1) == container) {
|
||||
flutterOverlayApplied = true
|
||||
return@post
|
||||
}
|
||||
FlutterOverlayHelper.configureFlutterZOrder(contentView, container, zOrderOnTop = true)
|
||||
flutterOverlayApplied = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,8 +88,41 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
disposing = false
|
||||
pendingSurface = null
|
||||
|
||||
// Initialize AudioManager for audio focus handling
|
||||
audioManager = activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
// Initialize audio focus handling
|
||||
audioFocusManager = AudioFocusManager(
|
||||
context = activity,
|
||||
handler = handler,
|
||||
onPause = {
|
||||
if (isInitialized) {
|
||||
try { MPVLib.setPropertyBoolean("pause", true) }
|
||||
catch (e: Exception) { Log.w(TAG, "Failed to pause on focus loss", e) }
|
||||
}
|
||||
},
|
||||
onResume = {
|
||||
if (isInitialized) {
|
||||
try { MPVLib.setPropertyBoolean("pause", false) }
|
||||
catch (e: Exception) { Log.w(TAG, "Failed to resume after focus gain", e) }
|
||||
}
|
||||
},
|
||||
isPaused = {
|
||||
try { MPVLib.getPropertyBoolean("pause") }
|
||||
catch (e: Exception) { true }
|
||||
}
|
||||
)
|
||||
frameRateManager = FrameRateManager(
|
||||
activity = activity,
|
||||
handler = handler,
|
||||
onDisplayChanged = {
|
||||
try {
|
||||
if (MPVLib.getPropertyBoolean("pause")) {
|
||||
Log.d(TAG, "Display changed, resuming playback")
|
||||
MPVLib.setPropertyBoolean("pause", false)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to resume after display change", e)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// Create FrameLayout container for video (matches ExoPlayer pattern)
|
||||
// Setting visibility on container instead of SurfaceView directly allows
|
||||
@@ -215,9 +141,6 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
android.widget.FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
android.widget.FrameLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
// Keep video composited in the normal view hierarchy (avoid hardware overlay promotion)
|
||||
// so Flutter controls reliably draw above it in release builds.
|
||||
alpha = 0.999f
|
||||
holder.addCallback(this@MpvPlayerCore)
|
||||
|
||||
// Critical: Ensure SurfaceView renders BEHIND Flutter's view
|
||||
@@ -232,29 +155,18 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
|
||||
contentView.addView(surfaceContainer, 0)
|
||||
|
||||
// Find FlutterView and its internal FlutterSurfaceView, set it on top
|
||||
for (i in 0 until contentView.childCount) {
|
||||
val child = contentView.getChildAt(i)
|
||||
if (child is ViewGroup && child.javaClass.name.contains("FlutterView")) {
|
||||
contentView.bringChildToFront(child)
|
||||
// Look inside FlutterView for FlutterSurfaceView
|
||||
for (j in 0 until child.childCount) {
|
||||
val flutterChild = child.getChildAt(j)
|
||||
if (flutterChild is SurfaceView) {
|
||||
// Put Flutter in media overlay layer (above our video which is in normal layer)
|
||||
flutterChild.setZOrderOnTop(true)
|
||||
flutterChild.setZOrderMediaOverlay(true)
|
||||
flutterChild.holder.setFormat(PixelFormat.TRANSLUCENT)
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
// Find FlutterView and set it on top of our video surface
|
||||
FlutterOverlayHelper.findFlutterContainer(contentView, surfaceContainer)?.let { container ->
|
||||
FlutterOverlayHelper.configureFlutterZOrder(contentView, container, zOrderOnTop = true)
|
||||
flutterOverlayApplied = true
|
||||
}
|
||||
// Repeat after layout settles to catch late-added Flutter surfaces (release builds)
|
||||
ensureFlutterOverlayOnTop()
|
||||
overlayLayoutListener = ViewTreeObserver.OnGlobalLayoutListener {
|
||||
ensureFlutterOverlayOnTop()
|
||||
// Re-apply surface size on layout change (orientation transitions)
|
||||
val sv = surfaceView
|
||||
if (sv != null) applySurfaceSize(sv.width, sv.height)
|
||||
}
|
||||
contentView.viewTreeObserver.addOnGlobalLayoutListener(overlayLayoutListener)
|
||||
|
||||
@@ -326,72 +238,18 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
MPVLib.setOptionString("opengl-es", "yes")
|
||||
// hwdec is set from Flutter via setProperty based on user preference
|
||||
|
||||
// Prevent crashes/artifacts from hardware film grain synthesis (mpv #14651)
|
||||
MPVLib.setOptionString("vd-lavc-film-grain", "cpu")
|
||||
|
||||
// Audio configuration
|
||||
MPVLib.setOptionString("ao", "audiotrack")
|
||||
}
|
||||
|
||||
// Audio Focus
|
||||
|
||||
/**
|
||||
* Request audio focus before starting playback.
|
||||
* This will cause other media apps to pause.
|
||||
* @return true if audio focus was granted
|
||||
*/
|
||||
fun requestAudioFocus(): Boolean {
|
||||
val am = audioManager ?: return false
|
||||
fun requestAudioFocus(): Boolean = audioFocusManager?.requestAudioFocus() ?: false
|
||||
|
||||
Log.d(TAG, "Requesting audio focus")
|
||||
|
||||
val result = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// Android 8.0+ uses AudioFocusRequest
|
||||
val focusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
|
||||
.setAudioAttributes(
|
||||
AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_MEDIA)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MOVIE)
|
||||
.build()
|
||||
)
|
||||
.setOnAudioFocusChangeListener(audioFocusChangeListener, handler)
|
||||
.setWillPauseWhenDucked(true)
|
||||
.build()
|
||||
|
||||
audioFocusRequest = focusRequest
|
||||
am.requestAudioFocus(focusRequest)
|
||||
} else {
|
||||
// Legacy API for older Android versions
|
||||
@Suppress("DEPRECATION")
|
||||
am.requestAudioFocus(
|
||||
audioFocusChangeListener,
|
||||
AudioManager.STREAM_MUSIC,
|
||||
AudioManager.AUDIOFOCUS_GAIN
|
||||
)
|
||||
}
|
||||
|
||||
hasAudioFocus = (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED)
|
||||
Log.d(TAG, "Audio focus request result: $result, granted: $hasAudioFocus")
|
||||
return hasAudioFocus
|
||||
}
|
||||
|
||||
/**
|
||||
* Abandon audio focus when playback stops.
|
||||
* This allows other apps to resume their audio.
|
||||
*/
|
||||
fun abandonAudioFocus() {
|
||||
val am = audioManager ?: return
|
||||
|
||||
Log.d(TAG, "Abandoning audio focus")
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
audioFocusRequest?.let { am.abandonAudioFocusRequest(it) }
|
||||
audioFocusRequest = null
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
am.abandonAudioFocus(audioFocusChangeListener)
|
||||
}
|
||||
|
||||
hasAudioFocus = false
|
||||
wasPlayingBeforeFocusLoss = false
|
||||
}
|
||||
fun abandonAudioFocus() { audioFocusManager?.abandonAudioFocus() }
|
||||
|
||||
// SurfaceHolder.Callback
|
||||
|
||||
@@ -408,17 +266,13 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
|
||||
attachSurfaceInternal(surface)
|
||||
// Reassert overlay order whenever the surface is recreated
|
||||
flutterOverlayApplied = false
|
||||
ensureFlutterOverlayOnTop()
|
||||
}
|
||||
|
||||
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
|
||||
Log.d(TAG, "Surface changed: ${width}x${height}")
|
||||
if (!nativeReady || disposing) return
|
||||
try {
|
||||
MPVLib.setPropertyString("android-surface-size", "${width}x${height}")
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to apply surface size to MPV", e)
|
||||
}
|
||||
applySurfaceSize(width, height)
|
||||
}
|
||||
|
||||
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
||||
@@ -434,13 +288,26 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
MPVLib.attachSurface(surface)
|
||||
MPVLib.setOptionString("force-window", "yes")
|
||||
// Restore video output after surface is available
|
||||
MPVLib.setPropertyString("vo", voInUse)
|
||||
MPVLib.setPropertyString("vo", "gpu")
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to attach MPV surface", e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun applySurfaceSize(width: Int, height: Int) {
|
||||
if (!nativeReady || disposing || width <= 0 || height <= 0) return
|
||||
val size = "${width}x${height}"
|
||||
if (size == lastSurfaceSize) return
|
||||
lastSurfaceSize = size
|
||||
try {
|
||||
MPVLib.setPropertyString("android-surface-size", size)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to apply surface size to MPV", e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun detachSurfaceInternal() {
|
||||
lastSurfaceSize = null
|
||||
if (!nativeReady) return
|
||||
// Disable video output before detaching (like mpv-android)
|
||||
try {
|
||||
@@ -594,191 +461,12 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
|
||||
// Frame Rate Matching
|
||||
|
||||
private fun getDisplayManager(): DisplayManager {
|
||||
return activity.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the video frame rate for display refresh rate matching.
|
||||
* Based on VLC Android's FrameRateManager implementation.
|
||||
*/
|
||||
fun setVideoFrameRate(fps: Float, videoDurationMs: Long) {
|
||||
currentVideoFps = fps
|
||||
if (fps <= 0f) {
|
||||
Log.d(TAG, "setVideoFrameRate: Invalid fps ($fps), skipping")
|
||||
return
|
||||
}
|
||||
|
||||
val surface = surfaceView?.holder?.surface
|
||||
if (surface == null) {
|
||||
Log.d(TAG, "setVideoFrameRate: Surface not available")
|
||||
return
|
||||
}
|
||||
|
||||
Log.d(TAG, "setVideoFrameRate: fps=$fps, duration=${videoDurationMs}ms, API=${Build.VERSION.SDK_INT}")
|
||||
|
||||
when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> setFrameRateS(fps, surface, videoDurationMs)
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> setFrameRateR(fps, surface)
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> setFrameRateM(fps)
|
||||
}
|
||||
frameRateManager?.setVideoFrameRate(fps, videoDurationMs, surfaceView?.holder?.surface)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear frame rate setting and cleanup display listener.
|
||||
*/
|
||||
fun clearVideoFrameRate() {
|
||||
Log.d(TAG, "clearVideoFrameRate")
|
||||
currentVideoFps = 0f
|
||||
displayListener?.let {
|
||||
getDisplayManager().unregisterDisplayListener(it)
|
||||
displayListener = null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and register display listener for mode switch completion.
|
||||
* Resumes playback after display mode change (needed for HDMI/projectors).
|
||||
*/
|
||||
private fun registerDisplayListener() {
|
||||
displayListener?.let {
|
||||
getDisplayManager().unregisterDisplayListener(it)
|
||||
}
|
||||
|
||||
displayListener = object : DisplayManager.DisplayListener {
|
||||
override fun onDisplayAdded(displayId: Int) = Unit
|
||||
override fun onDisplayRemoved(displayId: Int) = Unit
|
||||
override fun onDisplayChanged(displayId: Int) {
|
||||
// Mode switch may pause playback (HDMI), wait and resume
|
||||
handler.postDelayed({
|
||||
try {
|
||||
val isPaused = MPVLib.getPropertyBoolean("pause")
|
||||
if (isPaused) {
|
||||
Log.d(TAG, "Display changed, resuming playback")
|
||||
MPVLib.setPropertyBoolean("pause", false)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to resume playback after display change", e)
|
||||
}
|
||||
}, 2000L) // Wait 2 seconds for mode switch to complete
|
||||
getDisplayManager().unregisterDisplayListener(this)
|
||||
displayListener = null
|
||||
}
|
||||
}
|
||||
getDisplayManager().registerDisplayListener(displayListener, handler)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun setFrameRateR(fps: Float, surface: Surface) {
|
||||
Log.d(TAG, "setFrameRateR: Setting frame rate to $fps")
|
||||
surface.setFrameRate(fps, Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE)
|
||||
registerDisplayListener()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.S)
|
||||
private fun setFrameRateS(fps: Float, surface: Surface, videoDurationMs: Long) {
|
||||
Log.d(TAG, "setFrameRateS: fps=$fps, duration=${videoDurationMs}ms")
|
||||
|
||||
// For short videos (<5min), only switch if seamless
|
||||
if (videoDurationMs < SHORT_VIDEO_LENGTH_MS) {
|
||||
Log.d(TAG, "Short video, using seamless-only switching")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// For longer videos, check if switch will be seamless
|
||||
var seamless = false
|
||||
activity.display?.mode?.alternativeRefreshRates?.let { refreshRates ->
|
||||
for (rate in refreshRates) {
|
||||
// Check if rates match or are integer multiples
|
||||
if (fps.toString().startsWith(rate.toString()) ||
|
||||
rate.toString().startsWith(fps.toString()) ||
|
||||
rate % fps == 0f) {
|
||||
seamless = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (seamless) {
|
||||
Log.d(TAG, "Seamless switch available, using CHANGE_FRAME_RATE_ALWAYS")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ALWAYS
|
||||
)
|
||||
registerDisplayListener()
|
||||
} else {
|
||||
// Non-seamless: only switch if user enabled it at OS level
|
||||
val userPreference = getDisplayManager().matchContentFrameRateUserPreference
|
||||
if (userPreference == DisplayManager.MATCH_CONTENT_FRAMERATE_ALWAYS) {
|
||||
Log.d(TAG, "User preference allows non-seamless switch")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ALWAYS
|
||||
)
|
||||
registerDisplayListener()
|
||||
} else {
|
||||
Log.d(TAG, "Non-seamless switch not allowed by user preference, using seamless-only")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun setFrameRateM(fps: Float) {
|
||||
Log.d(TAG, "setFrameRateM: fps=$fps")
|
||||
val wm = activity.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
val display = wm.defaultDisplay ?: return
|
||||
|
||||
display.supportedModes?.let { supportedModes ->
|
||||
val currentMode = display.mode
|
||||
var modeToUse = currentMode
|
||||
|
||||
for (mode in supportedModes) {
|
||||
// Skip modes with different resolution
|
||||
if (mode.physicalHeight != currentMode.physicalHeight ||
|
||||
mode.physicalWidth != currentMode.physicalWidth) {
|
||||
continue
|
||||
}
|
||||
|
||||
Log.d(TAG, "Supported mode: ${mode.modeId} - ${mode.refreshRate}Hz")
|
||||
|
||||
// Check for exact match
|
||||
if (BigDecimal(fps.toString()).setScale(1, RoundingMode.FLOOR) ==
|
||||
BigDecimal(mode.refreshRate.toString()).setScale(1, RoundingMode.FLOOR)) {
|
||||
modeToUse = mode
|
||||
Log.d(TAG, "Found exact match: ${mode.refreshRate}Hz")
|
||||
break
|
||||
}
|
||||
// Check for integer multiple (e.g., 48Hz for 24fps)
|
||||
else if (mode.refreshRate % fps == 0f) {
|
||||
modeToUse = mode
|
||||
Log.d(TAG, "Found integer multiple: ${mode.refreshRate}Hz")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (modeToUse != currentMode) {
|
||||
Log.d(TAG, "Switching to mode ${modeToUse.modeId} (${modeToUse.refreshRate}Hz)")
|
||||
activity.window?.attributes?.let { attrs ->
|
||||
attrs.preferredDisplayModeId = modeToUse.modeId
|
||||
activity.window?.attributes = attrs
|
||||
}
|
||||
registerDisplayListener()
|
||||
} else {
|
||||
Log.d(TAG, "No better mode found, staying at ${currentMode.refreshRate}Hz")
|
||||
}
|
||||
}
|
||||
frameRateManager?.clearVideoFrameRate()
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
@@ -791,12 +479,11 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
// Shutdown command executor
|
||||
commandExecutor.shutdown()
|
||||
|
||||
// Clean up frame rate listener
|
||||
clearVideoFrameRate()
|
||||
|
||||
// Release audio focus
|
||||
abandonAudioFocus()
|
||||
audioManager = null
|
||||
// Clean up frame rate and audio focus
|
||||
frameRateManager?.clearVideoFrameRate()
|
||||
frameRateManager = null
|
||||
audioFocusManager?.release()
|
||||
audioFocusManager = null
|
||||
|
||||
if (nativeReady) {
|
||||
try {
|
||||
@@ -814,15 +501,14 @@ class MpvPlayerCore(private val activity: Activity) :
|
||||
}
|
||||
overlayLayoutListener = null
|
||||
|
||||
// Remove SurfaceView synchronously (keep callback so surfaceDestroyed
|
||||
// fires → MPVLib.detachSurface()), then remove callback after.
|
||||
// Defer all view removal to avoid AOSP bug where
|
||||
// dispatchWindowVisibilityChanged iterates stale children array
|
||||
// when removeView() runs during an active performTraversals pass.
|
||||
val sv = surfaceView
|
||||
val container = surfaceContainer
|
||||
surfaceView?.let { container?.removeView(it) }
|
||||
surfaceView?.holder?.removeCallback(this)
|
||||
|
||||
// Defer empty container removal (plain FrameLayout, no SurfaceControl)
|
||||
val contentView = activity.findViewById<ViewGroup>(android.R.id.content)
|
||||
contentView.post {
|
||||
sv?.holder?.removeCallback(this)
|
||||
container?.let { contentView.removeView(it) }
|
||||
}
|
||||
surfaceContainer = null
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.edde746.plezy.shared
|
||||
|
||||
import android.content.Context
|
||||
import android.media.AudioAttributes
|
||||
import android.media.AudioFocusRequest
|
||||
import android.media.AudioManager
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
|
||||
class AudioFocusManager(
|
||||
context: Context,
|
||||
private val handler: Handler,
|
||||
private val onPause: () -> Unit,
|
||||
private val onResume: () -> Unit,
|
||||
private val isPaused: () -> Boolean,
|
||||
private val log: (String) -> Unit = { Log.d(TAG, it) }
|
||||
) {
|
||||
companion object {
|
||||
private const val TAG = "AudioFocusManager"
|
||||
}
|
||||
|
||||
private val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
private var audioFocusRequest: AudioFocusRequest? = null
|
||||
private var hasAudioFocus: Boolean = false
|
||||
var wasPlayingBeforeFocusLoss: Boolean = false
|
||||
private set
|
||||
|
||||
private val audioFocusChangeListener = AudioManager.OnAudioFocusChangeListener { focusChange ->
|
||||
when (focusChange) {
|
||||
AudioManager.AUDIOFOCUS_GAIN -> {
|
||||
log("Focus gained")
|
||||
hasAudioFocus = true
|
||||
if (wasPlayingBeforeFocusLoss) {
|
||||
onResume()
|
||||
wasPlayingBeforeFocusLoss = false
|
||||
}
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS -> {
|
||||
log("Focus lost permanently")
|
||||
hasAudioFocus = false
|
||||
wasPlayingBeforeFocusLoss = !isPaused()
|
||||
onPause()
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT -> {
|
||||
log("Focus lost transiently")
|
||||
hasAudioFocus = false
|
||||
wasPlayingBeforeFocusLoss = !isPaused()
|
||||
onPause()
|
||||
}
|
||||
AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK -> {
|
||||
log("Focus lost transiently (can duck)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun requestAudioFocus(): Boolean {
|
||||
Log.d(TAG, "Requesting audio focus")
|
||||
|
||||
val result = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val focusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
|
||||
.setAudioAttributes(
|
||||
AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_MEDIA)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MOVIE)
|
||||
.build()
|
||||
)
|
||||
.setOnAudioFocusChangeListener(audioFocusChangeListener, handler)
|
||||
.build()
|
||||
|
||||
audioFocusRequest = focusRequest
|
||||
audioManager.requestAudioFocus(focusRequest)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
audioManager.requestAudioFocus(
|
||||
audioFocusChangeListener,
|
||||
AudioManager.STREAM_MUSIC,
|
||||
AudioManager.AUDIOFOCUS_GAIN
|
||||
)
|
||||
}
|
||||
|
||||
hasAudioFocus = (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED)
|
||||
Log.d(TAG, "Audio focus request result: $result, granted: $hasAudioFocus")
|
||||
return hasAudioFocus
|
||||
}
|
||||
|
||||
fun abandonAudioFocus() {
|
||||
Log.d(TAG, "Abandoning audio focus")
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
audioFocusRequest?.let { audioManager.abandonAudioFocusRequest(it) }
|
||||
audioFocusRequest = null
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
audioManager.abandonAudioFocus(audioFocusChangeListener)
|
||||
}
|
||||
|
||||
hasAudioFocus = false
|
||||
wasPlayingBeforeFocusLoss = false
|
||||
}
|
||||
|
||||
fun release() {
|
||||
abandonAudioFocus()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.edde746.plezy.shared
|
||||
|
||||
import android.graphics.PixelFormat
|
||||
import android.view.SurfaceView
|
||||
import android.view.TextureView
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
object FlutterOverlayHelper {
|
||||
|
||||
/**
|
||||
* Find the FlutterView container in the content view hierarchy.
|
||||
* First tries to match by class name (works in debug builds),
|
||||
* then falls back to picking the last ViewGroup with children
|
||||
* (needed for release builds where FlutterView may be obfuscated).
|
||||
*/
|
||||
fun findFlutterContainer(contentView: ViewGroup, excludeView: View? = null): ViewGroup? {
|
||||
// First pass: look for FlutterView by name (debug builds)
|
||||
for (i in 0 until contentView.childCount) {
|
||||
val child = contentView.getChildAt(i)
|
||||
if (child is ViewGroup && child.javaClass.name.contains("FlutterView")) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for release (FlutterView may be obfuscated): pick the last ViewGroup
|
||||
// that is not our video container and has children.
|
||||
for (i in contentView.childCount - 1 downTo 0) {
|
||||
val child = contentView.getChildAt(i)
|
||||
if (child is ViewGroup && child != excludeView && child.childCount > 0) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure z-ordering so the Flutter UI renders above the video surface.
|
||||
*
|
||||
* @param zOrderOnTop true for MPV (Flutter needs to be fully on top),
|
||||
* false for ExoPlayer (subtitle layer sits between video and Flutter)
|
||||
*/
|
||||
fun configureFlutterZOrder(contentView: ViewGroup, container: ViewGroup, zOrderOnTop: Boolean) {
|
||||
contentView.bringChildToFront(container)
|
||||
for (j in 0 until container.childCount) {
|
||||
val flutterChild = container.getChildAt(j)
|
||||
if (flutterChild is SurfaceView) {
|
||||
flutterChild.setZOrderOnTop(zOrderOnTop)
|
||||
flutterChild.setZOrderMediaOverlay(true)
|
||||
flutterChild.holder.setFormat(PixelFormat.TRANSLUCENT)
|
||||
break
|
||||
} else if (flutterChild is TextureView) {
|
||||
flutterChild.isOpaque = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.edde746.plezy.shared
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
import android.view.Surface
|
||||
import android.view.WindowManager
|
||||
import androidx.annotation.RequiresApi
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
class FrameRateManager(
|
||||
private val activity: Activity,
|
||||
private val handler: Handler,
|
||||
private val onDisplayChanged: () -> Unit,
|
||||
private val log: (String) -> Unit = { Log.d(TAG, it) }
|
||||
) {
|
||||
companion object {
|
||||
private const val TAG = "FrameRateManager"
|
||||
private const val SHORT_VIDEO_LENGTH_MS = 300000L // 5 minutes
|
||||
}
|
||||
|
||||
private var currentVideoFps: Float = 0f
|
||||
private var displayListener: DisplayManager.DisplayListener? = null
|
||||
|
||||
private fun getDisplayManager(): DisplayManager {
|
||||
return activity.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
|
||||
}
|
||||
|
||||
fun setVideoFrameRate(fps: Float, videoDurationMs: Long, surface: Surface?) {
|
||||
currentVideoFps = fps
|
||||
if (fps <= 0f) {
|
||||
Log.d(TAG, "setVideoFrameRate: Invalid fps ($fps), skipping")
|
||||
return
|
||||
}
|
||||
|
||||
if (surface == null) {
|
||||
Log.d(TAG, "setVideoFrameRate: Surface not available")
|
||||
return
|
||||
}
|
||||
|
||||
log("fps=$fps, duration=${videoDurationMs}ms, API=${Build.VERSION.SDK_INT}")
|
||||
|
||||
when {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> setFrameRateS(fps, surface, videoDurationMs)
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> setFrameRateR(fps, surface)
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> setFrameRateM(fps)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearVideoFrameRate() {
|
||||
Log.d(TAG, "clearVideoFrameRate")
|
||||
currentVideoFps = 0f
|
||||
displayListener?.let {
|
||||
getDisplayManager().unregisterDisplayListener(it)
|
||||
displayListener = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun registerDisplayListener() {
|
||||
displayListener?.let {
|
||||
getDisplayManager().unregisterDisplayListener(it)
|
||||
}
|
||||
|
||||
displayListener = object : DisplayManager.DisplayListener {
|
||||
override fun onDisplayAdded(displayId: Int) = Unit
|
||||
override fun onDisplayRemoved(displayId: Int) = Unit
|
||||
override fun onDisplayChanged(displayId: Int) {
|
||||
handler.postDelayed({
|
||||
onDisplayChanged()
|
||||
}, 2000L)
|
||||
getDisplayManager().unregisterDisplayListener(this)
|
||||
displayListener = null
|
||||
}
|
||||
}
|
||||
getDisplayManager().registerDisplayListener(displayListener, handler)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
private fun setFrameRateR(fps: Float, surface: Surface) {
|
||||
Log.d(TAG, "setFrameRateR: Setting frame rate to $fps")
|
||||
surface.setFrameRate(fps, Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE)
|
||||
registerDisplayListener()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.S)
|
||||
private fun setFrameRateS(fps: Float, surface: Surface, videoDurationMs: Long) {
|
||||
Log.d(TAG, "setFrameRateS: fps=$fps, duration=${videoDurationMs}ms")
|
||||
|
||||
if (videoDurationMs < SHORT_VIDEO_LENGTH_MS) {
|
||||
Log.d(TAG, "Short video, using seamless-only switching")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
var seamless = false
|
||||
activity.display?.mode?.alternativeRefreshRates?.let { refreshRates ->
|
||||
for (rate in refreshRates) {
|
||||
if (fps.toString().startsWith(rate.toString()) ||
|
||||
rate.toString().startsWith(fps.toString()) ||
|
||||
rate % fps == 0f) {
|
||||
seamless = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (seamless) {
|
||||
log("Seamless switch available for ${fps}fps")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ALWAYS
|
||||
)
|
||||
registerDisplayListener()
|
||||
} else {
|
||||
val userPreference = getDisplayManager().matchContentFrameRateUserPreference
|
||||
if (userPreference == DisplayManager.MATCH_CONTENT_FRAMERATE_ALWAYS) {
|
||||
Log.d(TAG, "User preference allows non-seamless switch")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ALWAYS
|
||||
)
|
||||
registerDisplayListener()
|
||||
} else {
|
||||
Log.d(TAG, "Non-seamless switch not allowed, using seamless-only")
|
||||
surface.setFrameRate(
|
||||
fps,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_FIXED_SOURCE,
|
||||
Surface.CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
private fun setFrameRateM(fps: Float) {
|
||||
Log.d(TAG, "setFrameRateM: fps=$fps")
|
||||
val wm = activity.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
@Suppress("DEPRECATION")
|
||||
val display = wm.defaultDisplay ?: return
|
||||
|
||||
display.supportedModes?.let { supportedModes ->
|
||||
val currentMode = display.mode
|
||||
var modeToUse = currentMode
|
||||
|
||||
for (mode in supportedModes) {
|
||||
if (mode.physicalHeight != currentMode.physicalHeight ||
|
||||
mode.physicalWidth != currentMode.physicalWidth) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (BigDecimal(fps.toString()).setScale(1, RoundingMode.FLOOR) ==
|
||||
BigDecimal(mode.refreshRate.toString()).setScale(1, RoundingMode.FLOOR)) {
|
||||
modeToUse = mode
|
||||
break
|
||||
} else if (mode.refreshRate % fps == 0f) {
|
||||
modeToUse = mode
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (modeToUse != currentMode) {
|
||||
Log.d(TAG, "Switching to mode ${modeToUse.modeId} (${modeToUse.refreshRate}Hz)")
|
||||
activity.window?.attributes?.let { attrs ->
|
||||
attrs.preferredDisplayModeId = modeToUse.modeId
|
||||
activity.window?.attributes = attrs
|
||||
}
|
||||
registerDisplayListener()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.edde746.plezy.shared
|
||||
|
||||
import android.graphics.Color
|
||||
|
||||
object ThemeHelper {
|
||||
fun themeColor(mode: String?): Int? = when (mode) {
|
||||
"oled" -> Color.BLACK
|
||||
"dark" -> Color.parseColor("#0E0F12")
|
||||
"light" -> Color.parseColor("#F7F7F8")
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -31,13 +31,12 @@ platform :android do
|
||||
aab: "../build/app/outputs/bundle/release/app-release.aab"
|
||||
)
|
||||
|
||||
# Build split-per-ABI APKs for Amazon Appstore (doesn't accept AABs)
|
||||
sh("cd #{ENV['PWD']}/.. && flutter build apk --release --split-per-abi --obfuscate --split-debug-info=#{debug_info_dir}/apk")
|
||||
# Build universal APK for Amazon Appstore (doesn't accept AABs, doesn't auto-target by ABI)
|
||||
sh("cd #{ENV['PWD']}/.. && flutter build apk --release --target-platform android-arm,android-arm64 --obfuscate --split-debug-info=#{debug_info_dir}/apk")
|
||||
|
||||
upload_to_amazon_appstore(
|
||||
apk_paths: [
|
||||
"../build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk",
|
||||
"../build/app/outputs/flutter-apk/app-arm64-v8a-release.apk"
|
||||
"../build/app/outputs/flutter-apk/app-release.apk"
|
||||
],
|
||||
overwrite_upload: true,
|
||||
overwrite_upload_mode: 'reuse',
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Zeige auf Discord, was du gerade schaust",
|
||||
"autoPip": "Automatisches Bild-in-Bild",
|
||||
"autoPipDescription": "Automatisch Bild-in-Bild aktivieren, wenn die App während der Wiedergabe verlassen wird",
|
||||
"matchContentFrameRate": "Inhalts-Bildrate anpassen",
|
||||
"matchContentFrameRateDescription": "Bildwiederholfrequenz des Displays an den Videoinhalt anpassen, reduziert Ruckeln und spart Akku",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "Profil beim Öffnen abfragen",
|
||||
"requireProfileSelectionOnOpenDescription": "Profilauswahl bei jedem Öffnen der App anzeigen",
|
||||
"confirmExitOnBack": "Vor dem Beenden bestätigen",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "Audioausgabe",
|
||||
"performanceOverlay": "Leistungsanzeige",
|
||||
"audioPassthrough": "Audio-Durchleitung"
|
||||
"audioPassthrough": "Audio-Durchleitung",
|
||||
"audioNormalization": "Audio-Normalisierung"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "Externer Player",
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Show what you're watching on Discord",
|
||||
"autoPip": "Auto Picture-in-Picture",
|
||||
"autoPipDescription": "Automatically enter picture-in-picture when leaving the app during playback",
|
||||
"matchContentFrameRate": "Match Content Frame Rate",
|
||||
"matchContentFrameRateDescription": "Adjust display refresh rate to match video content, reducing judder and saving battery",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "Ask for profile on app open",
|
||||
"requireProfileSelectionOnOpenDescription": "Show profile selection every time the app is opened",
|
||||
"confirmExitOnBack": "Confirm before exiting",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "Audio Output",
|
||||
"performanceOverlay": "Performance Overlay",
|
||||
"audioPassthrough": "Audio Passthrough"
|
||||
"audioPassthrough": "Audio Passthrough",
|
||||
"audioNormalization": "Audio Normalization"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "External Player",
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Presencia de Discord",
|
||||
"discordRichPresenceDescription": "Mostrar lo que estás viendo en Discord",
|
||||
"autoPip": "Imagen en imagen automática",
|
||||
"autoPipDescription": "Activar automáticamente imagen en imagen al salir de la app durante la reproducción",
|
||||
"matchContentFrameRate": "Ajustar frecuencia de actualización",
|
||||
"matchContentFrameRateDescription": "Ajustar la frecuencia de actualización de la pantalla para que coincida con el video, reduciendo tirones y ahorrando batería",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "Pedir perfil al abrir la app",
|
||||
"requireProfileSelectionOnOpenDescription": "Mostrar selección de perfil cada vez que se abre la aplicación",
|
||||
"confirmExitOnBack": "Confirmar antes de salir",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "Salida de audio",
|
||||
"performanceOverlay": "Indicador de rendimiento",
|
||||
"audioPassthrough": "Audio Passthrough"
|
||||
"audioPassthrough": "Audio Passthrough",
|
||||
"audioNormalization": "Normalización de audio"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "Reproductor externo",
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Montrez ce que vous regardez sur Discord",
|
||||
"autoPip": "Image dans l'image automatique",
|
||||
"autoPipDescription": "Activer automatiquement l'image dans l'image en quittant l'application pendant la lecture",
|
||||
"matchContentFrameRate": "Fréquence d'images du contenu correspondant",
|
||||
"matchContentFrameRateDescription": "Ajustez la fréquence de rafraîchissement de l'écran en fonction du contenu vidéo, ce qui réduit les saccades et économise la batterie",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "Demander le profil à l'ouverture",
|
||||
"requireProfileSelectionOnOpenDescription": "Afficher la sélection de profil à chaque ouverture de l'application",
|
||||
"confirmExitOnBack": "Confirmer avant de quitter",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "Sortie audio",
|
||||
"performanceOverlay": "Superposition de performance",
|
||||
"audioPassthrough": "Audio Pass-Through"
|
||||
"audioPassthrough": "Audio Pass-Through",
|
||||
"audioNormalization": "Normalisation audio"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "Lecteur externe",
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Mostra su Discord cosa stai guardando",
|
||||
"autoPip": "Picture-in-Picture automatico",
|
||||
"autoPipDescription": "Attiva automaticamente il picture-in-picture quando si esce dall'app durante la riproduzione",
|
||||
"matchContentFrameRate": "Adatta frequenza fotogrammi",
|
||||
"matchContentFrameRateDescription": "Regola la frequenza di aggiornamento del display in base al contenuto video, riducendo i tremolii e risparmiando batteria",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "Chiedi profilo all'apertura",
|
||||
"requireProfileSelectionOnOpenDescription": "Mostra la selezione del profilo ogni volta che l'app viene aperta",
|
||||
"confirmExitOnBack": "Conferma prima di uscire",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "Uscita audio",
|
||||
"performanceOverlay": "Overlay prestazioni",
|
||||
"audioPassthrough": "Audio Passthrough"
|
||||
"audioPassthrough": "Audio Passthrough",
|
||||
"audioNormalization": "Normalizzazione audio"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "Lettore esterno",
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Discord에서 시청 중인 콘텐츠 표시",
|
||||
"autoPip": "자동 PIP 모드",
|
||||
"autoPipDescription": "재생 중 앱을 나갈 때 자동으로 PIP 모드로 전환",
|
||||
"matchContentFrameRate": "콘텐츠 프레임 레이트 맞춤",
|
||||
"matchContentFrameRateDescription": "비디오 콘텐츠에 맞게 디스플레이 주사율을 조정하여 떨림을 줄이고 배터리를 절약합니다",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "앱 실행 시 프로필 선택",
|
||||
"requireProfileSelectionOnOpenDescription": "앱을 열 때마다 프로필 선택 화면을 표시합니다",
|
||||
"confirmExitOnBack": "종료 전 확인",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "오디오 출력",
|
||||
"performanceOverlay": "성능 오버레이",
|
||||
"audioPassthrough": "오디오 패스스루"
|
||||
"audioPassthrough": "오디오 패스스루",
|
||||
"audioNormalization": "오디오 정규화"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "외부 플레이어",
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Toon op Discord wat je aan het kijken bent",
|
||||
"autoPip": "Automatische beeld-in-beeld",
|
||||
"autoPipDescription": "Automatisch beeld-in-beeld activeren bij het verlaten van de app tijdens afspelen",
|
||||
"matchContentFrameRate": "Inhoudsframesnelheid afstemmen",
|
||||
"matchContentFrameRateDescription": "Pas de schermverversingssnelheid aan op de video-inhoud, vermindert haperingen en bespaart batterij",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "Vraag om profiel bij openen",
|
||||
"requireProfileSelectionOnOpenDescription": "Toon profielselectie telkens wanneer de app wordt geopend",
|
||||
"confirmExitOnBack": "Bevestigen voor afsluiten",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "Audio-uitvoer",
|
||||
"performanceOverlay": "Prestatie-overlay",
|
||||
"audioPassthrough": "Audio-doorvoer"
|
||||
"audioPassthrough": "Audio-doorvoer",
|
||||
"audioNormalization": "Audionormalisatie"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "Externe speler",
|
||||
|
||||
@@ -316,8 +316,12 @@ class _TranslationsSettingsDe implements TranslationsSettingsEn {
|
||||
@override String maxVolumePercent({required Object percent}) => '${percent}%';
|
||||
@override String get discordRichPresence => 'Discord Rich Presence';
|
||||
@override String get discordRichPresenceDescription => 'Zeige auf Discord, was du gerade schaust';
|
||||
@override String get autoPip => 'Automatisches Bild-in-Bild';
|
||||
@override String get autoPipDescription => 'Automatisch Bild-in-Bild aktivieren, wenn die App während der Wiedergabe verlassen wird';
|
||||
@override String get matchContentFrameRate => 'Inhalts-Bildrate anpassen';
|
||||
@override String get matchContentFrameRateDescription => 'Bildwiederholfrequenz des Displays an den Videoinhalt anpassen, reduziert Ruckeln und spart Akku';
|
||||
@override String get tunneledPlayback => 'Tunneled Playback';
|
||||
@override String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
@override String get requireProfileSelectionOnOpen => 'Profil beim Öffnen abfragen';
|
||||
@override String get requireProfileSelectionOnOpenDescription => 'Profilauswahl bei jedem Öffnen der App anzeigen';
|
||||
@override String get confirmExitOnBack => 'Vor dem Beenden bestätigen';
|
||||
@@ -1027,6 +1031,7 @@ class _TranslationsVideoSettingsDe implements TranslationsVideoSettingsEn {
|
||||
@override String get audioOutput => 'Audioausgabe';
|
||||
@override String get performanceOverlay => 'Leistungsanzeige';
|
||||
@override String get audioPassthrough => 'Audio-Durchleitung';
|
||||
@override String get audioNormalization => 'Audio-Normalisierung';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -1484,6 +1489,8 @@ extension on TranslationsDe {
|
||||
'settings.discordRichPresenceDescription' => 'Zeige auf Discord, was du gerade schaust',
|
||||
'settings.matchContentFrameRate' => 'Inhalts-Bildrate anpassen',
|
||||
'settings.matchContentFrameRateDescription' => 'Bildwiederholfrequenz des Displays an den Videoinhalt anpassen, reduziert Ruckeln und spart Akku',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => 'Profil beim Öffnen abfragen',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => 'Profilauswahl bei jedem Öffnen der App anzeigen',
|
||||
'settings.confirmExitOnBack' => 'Vor dem Beenden bestätigen',
|
||||
@@ -2021,6 +2028,7 @@ extension on TranslationsDe {
|
||||
'videoSettings.audioOutput' => 'Audioausgabe',
|
||||
'videoSettings.performanceOverlay' => 'Leistungsanzeige',
|
||||
'videoSettings.audioPassthrough' => 'Audio-Durchleitung',
|
||||
'videoSettings.audioNormalization' => 'Audio-Normalisierung',
|
||||
'externalPlayer.title' => 'Externer Player',
|
||||
'externalPlayer.useExternalPlayer' => 'Externen Player verwenden',
|
||||
'externalPlayer.useExternalPlayerDescription' => 'Videos in einer externen App statt im integrierten Player öffnen',
|
||||
|
||||
@@ -694,12 +694,24 @@ class TranslationsSettingsEn {
|
||||
/// en: 'Show what you're watching on Discord'
|
||||
String get discordRichPresenceDescription => 'Show what you\'re watching on Discord';
|
||||
|
||||
/// en: 'Auto Picture-in-Picture'
|
||||
String get autoPip => 'Auto Picture-in-Picture';
|
||||
|
||||
/// en: 'Automatically enter picture-in-picture when leaving the app during playback'
|
||||
String get autoPipDescription => 'Automatically enter picture-in-picture when leaving the app during playback';
|
||||
|
||||
/// en: 'Match Content Frame Rate'
|
||||
String get matchContentFrameRate => 'Match Content Frame Rate';
|
||||
|
||||
/// en: 'Adjust display refresh rate to match video content, reducing judder and saving battery'
|
||||
String get matchContentFrameRateDescription => 'Adjust display refresh rate to match video content, reducing judder and saving battery';
|
||||
|
||||
/// en: 'Tunneled Playback'
|
||||
String get tunneledPlayback => 'Tunneled Playback';
|
||||
|
||||
/// en: 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content'
|
||||
String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
|
||||
/// en: 'Ask for profile on app open'
|
||||
String get requireProfileSelectionOnOpen => 'Ask for profile on app open';
|
||||
|
||||
@@ -2276,6 +2288,9 @@ class TranslationsVideoSettingsEn {
|
||||
|
||||
/// en: 'Audio Passthrough'
|
||||
String get audioPassthrough => 'Audio Passthrough';
|
||||
|
||||
/// en: 'Audio Normalization'
|
||||
String get audioNormalization => 'Audio Normalization';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -3086,8 +3101,12 @@ extension on Translations {
|
||||
'settings.maxVolumePercent' => ({required Object percent}) => '${percent}%',
|
||||
'settings.discordRichPresence' => 'Discord Rich Presence',
|
||||
'settings.discordRichPresenceDescription' => 'Show what you\'re watching on Discord',
|
||||
'settings.autoPip' => 'Auto Picture-in-Picture',
|
||||
'settings.autoPipDescription' => 'Automatically enter picture-in-picture when leaving the app during playback',
|
||||
'settings.matchContentFrameRate' => 'Match Content Frame Rate',
|
||||
'settings.matchContentFrameRateDescription' => 'Adjust display refresh rate to match video content, reducing judder and saving battery',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => 'Ask for profile on app open',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => 'Show profile selection every time the app is opened',
|
||||
'settings.confirmExitOnBack' => 'Confirm before exiting',
|
||||
@@ -3625,6 +3644,7 @@ extension on Translations {
|
||||
'videoSettings.audioOutput' => 'Audio Output',
|
||||
'videoSettings.performanceOverlay' => 'Performance Overlay',
|
||||
'videoSettings.audioPassthrough' => 'Audio Passthrough',
|
||||
'videoSettings.audioNormalization' => 'Audio Normalization',
|
||||
'externalPlayer.title' => 'External Player',
|
||||
'externalPlayer.useExternalPlayer' => 'Use External Player',
|
||||
'externalPlayer.useExternalPlayerDescription' => 'Open videos in an external app instead of the built-in player',
|
||||
|
||||
@@ -316,8 +316,12 @@ class _TranslationsSettingsEs implements TranslationsSettingsEn {
|
||||
@override String maxVolumePercent({required Object percent}) => '${percent}%';
|
||||
@override String get discordRichPresence => 'Presencia de Discord';
|
||||
@override String get discordRichPresenceDescription => 'Mostrar lo que estás viendo en Discord';
|
||||
@override String get autoPip => 'Imagen en imagen automática';
|
||||
@override String get autoPipDescription => 'Activar automáticamente imagen en imagen al salir de la app durante la reproducción';
|
||||
@override String get matchContentFrameRate => 'Ajustar frecuencia de actualización';
|
||||
@override String get matchContentFrameRateDescription => 'Ajustar la frecuencia de actualización de la pantalla para que coincida con el video, reduciendo tirones y ahorrando batería';
|
||||
@override String get tunneledPlayback => 'Tunneled Playback';
|
||||
@override String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
@override String get requireProfileSelectionOnOpen => 'Pedir perfil al abrir la app';
|
||||
@override String get requireProfileSelectionOnOpenDescription => 'Mostrar selección de perfil cada vez que se abre la aplicación';
|
||||
@override String get confirmExitOnBack => 'Confirmar antes de salir';
|
||||
@@ -1027,6 +1031,7 @@ class _TranslationsVideoSettingsEs implements TranslationsVideoSettingsEn {
|
||||
@override String get audioOutput => 'Salida de audio';
|
||||
@override String get performanceOverlay => 'Indicador de rendimiento';
|
||||
@override String get audioPassthrough => 'Audio Passthrough';
|
||||
@override String get audioNormalization => 'Normalización de audio';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -1484,6 +1489,8 @@ extension on TranslationsEs {
|
||||
'settings.discordRichPresenceDescription' => 'Mostrar lo que estás viendo en Discord',
|
||||
'settings.matchContentFrameRate' => 'Ajustar frecuencia de actualización',
|
||||
'settings.matchContentFrameRateDescription' => 'Ajustar la frecuencia de actualización de la pantalla para que coincida con el video, reduciendo tirones y ahorrando batería',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => 'Pedir perfil al abrir la app',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => 'Mostrar selección de perfil cada vez que se abre la aplicación',
|
||||
'settings.confirmExitOnBack' => 'Confirmar antes de salir',
|
||||
@@ -2021,6 +2028,7 @@ extension on TranslationsEs {
|
||||
'videoSettings.audioOutput' => 'Salida de audio',
|
||||
'videoSettings.performanceOverlay' => 'Indicador de rendimiento',
|
||||
'videoSettings.audioPassthrough' => 'Audio Passthrough',
|
||||
'videoSettings.audioNormalization' => 'Normalización de audio',
|
||||
'externalPlayer.title' => 'Reproductor externo',
|
||||
'externalPlayer.useExternalPlayer' => 'Usar reproductor externo',
|
||||
'externalPlayer.useExternalPlayerDescription' => 'Abrir vídeos en una app externa en lugar del reproductor integrado',
|
||||
|
||||
@@ -316,8 +316,12 @@ class _TranslationsSettingsFr implements TranslationsSettingsEn {
|
||||
@override String maxVolumePercent({required Object percent}) => '${percent}%';
|
||||
@override String get discordRichPresence => 'Discord Rich Presence';
|
||||
@override String get discordRichPresenceDescription => 'Montrez ce que vous regardez sur Discord';
|
||||
@override String get autoPip => 'Image dans l\'image automatique';
|
||||
@override String get autoPipDescription => 'Activer automatiquement l\'image dans l\'image en quittant l\'application pendant la lecture';
|
||||
@override String get matchContentFrameRate => 'Fréquence d\'images du contenu correspondant';
|
||||
@override String get matchContentFrameRateDescription => 'Ajustez la fréquence de rafraîchissement de l\'écran en fonction du contenu vidéo, ce qui réduit les saccades et économise la batterie';
|
||||
@override String get tunneledPlayback => 'Tunneled Playback';
|
||||
@override String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
@override String get requireProfileSelectionOnOpen => 'Demander le profil à l\'ouverture';
|
||||
@override String get requireProfileSelectionOnOpenDescription => 'Afficher la sélection de profil à chaque ouverture de l\'application';
|
||||
@override String get confirmExitOnBack => 'Confirmer avant de quitter';
|
||||
@@ -1027,6 +1031,7 @@ class _TranslationsVideoSettingsFr implements TranslationsVideoSettingsEn {
|
||||
@override String get audioOutput => 'Sortie audio';
|
||||
@override String get performanceOverlay => 'Superposition de performance';
|
||||
@override String get audioPassthrough => 'Audio Pass-Through';
|
||||
@override String get audioNormalization => 'Normalisation audio';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -1484,6 +1489,8 @@ extension on TranslationsFr {
|
||||
'settings.discordRichPresenceDescription' => 'Montrez ce que vous regardez sur Discord',
|
||||
'settings.matchContentFrameRate' => 'Fréquence d\'images du contenu correspondant',
|
||||
'settings.matchContentFrameRateDescription' => 'Ajustez la fréquence de rafraîchissement de l\'écran en fonction du contenu vidéo, ce qui réduit les saccades et économise la batterie',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => 'Demander le profil à l\'ouverture',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => 'Afficher la sélection de profil à chaque ouverture de l\'application',
|
||||
'settings.confirmExitOnBack' => 'Confirmer avant de quitter',
|
||||
@@ -2021,6 +2028,7 @@ extension on TranslationsFr {
|
||||
'videoSettings.audioOutput' => 'Sortie audio',
|
||||
'videoSettings.performanceOverlay' => 'Superposition de performance',
|
||||
'videoSettings.audioPassthrough' => 'Audio Pass-Through',
|
||||
'videoSettings.audioNormalization' => 'Normalisation audio',
|
||||
'externalPlayer.title' => 'Lecteur externe',
|
||||
'externalPlayer.useExternalPlayer' => 'Utiliser un lecteur externe',
|
||||
'externalPlayer.useExternalPlayerDescription' => 'Ouvrir les vidéos dans une application externe au lieu du lecteur intégré',
|
||||
|
||||
@@ -316,8 +316,12 @@ class _TranslationsSettingsIt implements TranslationsSettingsEn {
|
||||
@override String maxVolumePercent({required Object percent}) => '${percent}%';
|
||||
@override String get discordRichPresence => 'Discord Rich Presence';
|
||||
@override String get discordRichPresenceDescription => 'Mostra su Discord cosa stai guardando';
|
||||
@override String get autoPip => 'Picture-in-Picture automatico';
|
||||
@override String get autoPipDescription => 'Attiva automaticamente il picture-in-picture quando si esce dall\'app durante la riproduzione';
|
||||
@override String get matchContentFrameRate => 'Adatta frequenza fotogrammi';
|
||||
@override String get matchContentFrameRateDescription => 'Regola la frequenza di aggiornamento del display in base al contenuto video, riducendo i tremolii e risparmiando batteria';
|
||||
@override String get tunneledPlayback => 'Tunneled Playback';
|
||||
@override String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
@override String get requireProfileSelectionOnOpen => 'Chiedi profilo all\'apertura';
|
||||
@override String get requireProfileSelectionOnOpenDescription => 'Mostra la selezione del profilo ogni volta che l\'app viene aperta';
|
||||
@override String get confirmExitOnBack => 'Conferma prima di uscire';
|
||||
@@ -1027,6 +1031,7 @@ class _TranslationsVideoSettingsIt implements TranslationsVideoSettingsEn {
|
||||
@override String get audioOutput => 'Uscita audio';
|
||||
@override String get performanceOverlay => 'Overlay prestazioni';
|
||||
@override String get audioPassthrough => 'Audio Passthrough';
|
||||
@override String get audioNormalization => 'Normalizzazione audio';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -1484,6 +1489,8 @@ extension on TranslationsIt {
|
||||
'settings.discordRichPresenceDescription' => 'Mostra su Discord cosa stai guardando',
|
||||
'settings.matchContentFrameRate' => 'Adatta frequenza fotogrammi',
|
||||
'settings.matchContentFrameRateDescription' => 'Regola la frequenza di aggiornamento del display in base al contenuto video, riducendo i tremolii e risparmiando batteria',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => 'Chiedi profilo all\'apertura',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => 'Mostra la selezione del profilo ogni volta che l\'app viene aperta',
|
||||
'settings.confirmExitOnBack' => 'Conferma prima di uscire',
|
||||
@@ -2021,6 +2028,7 @@ extension on TranslationsIt {
|
||||
'videoSettings.audioOutput' => 'Uscita audio',
|
||||
'videoSettings.performanceOverlay' => 'Overlay prestazioni',
|
||||
'videoSettings.audioPassthrough' => 'Audio Passthrough',
|
||||
'videoSettings.audioNormalization' => 'Normalizzazione audio',
|
||||
'externalPlayer.title' => 'Lettore esterno',
|
||||
'externalPlayer.useExternalPlayer' => 'Usa lettore esterno',
|
||||
'externalPlayer.useExternalPlayerDescription' => 'Apri i video in un\'app esterna invece del lettore integrato',
|
||||
|
||||
@@ -316,8 +316,12 @@ class _TranslationsSettingsKo implements TranslationsSettingsEn {
|
||||
@override String maxVolumePercent({required Object percent}) => '${percent}%';
|
||||
@override String get discordRichPresence => 'Discord Rich Presence';
|
||||
@override String get discordRichPresenceDescription => 'Discord에서 시청 중인 콘텐츠 표시';
|
||||
@override String get autoPip => '자동 PIP 모드';
|
||||
@override String get autoPipDescription => '재생 중 앱을 나갈 때 자동으로 PIP 모드로 전환';
|
||||
@override String get matchContentFrameRate => '콘텐츠 프레임 레이트 맞춤';
|
||||
@override String get matchContentFrameRateDescription => '비디오 콘텐츠에 맞게 디스플레이 주사율을 조정하여 떨림을 줄이고 배터리를 절약합니다';
|
||||
@override String get tunneledPlayback => 'Tunneled Playback';
|
||||
@override String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
@override String get requireProfileSelectionOnOpen => '앱 실행 시 프로필 선택';
|
||||
@override String get requireProfileSelectionOnOpenDescription => '앱을 열 때마다 프로필 선택 화면을 표시합니다';
|
||||
@override String get confirmExitOnBack => '종료 전 확인';
|
||||
@@ -1027,6 +1031,7 @@ class _TranslationsVideoSettingsKo implements TranslationsVideoSettingsEn {
|
||||
@override String get audioOutput => '오디오 출력';
|
||||
@override String get performanceOverlay => '성능 오버레이';
|
||||
@override String get audioPassthrough => '오디오 패스스루';
|
||||
@override String get audioNormalization => '오디오 정규화';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -1484,6 +1489,8 @@ extension on TranslationsKo {
|
||||
'settings.discordRichPresenceDescription' => 'Discord에서 시청 중인 콘텐츠 표시',
|
||||
'settings.matchContentFrameRate' => '콘텐츠 프레임 레이트 맞춤',
|
||||
'settings.matchContentFrameRateDescription' => '비디오 콘텐츠에 맞게 디스플레이 주사율을 조정하여 떨림을 줄이고 배터리를 절약합니다',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => '앱 실행 시 프로필 선택',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => '앱을 열 때마다 프로필 선택 화면을 표시합니다',
|
||||
'settings.confirmExitOnBack' => '종료 전 확인',
|
||||
@@ -2021,6 +2028,7 @@ extension on TranslationsKo {
|
||||
'videoSettings.audioOutput' => '오디오 출력',
|
||||
'videoSettings.performanceOverlay' => '성능 오버레이',
|
||||
'videoSettings.audioPassthrough' => '오디오 패스스루',
|
||||
'videoSettings.audioNormalization' => '오디오 정규화',
|
||||
'externalPlayer.title' => '외부 플레이어',
|
||||
'externalPlayer.useExternalPlayer' => '외부 플레이어 사용',
|
||||
'externalPlayer.useExternalPlayerDescription' => '내장 플레이어 대신 외부 앱에서 동영상 열기',
|
||||
|
||||
@@ -316,8 +316,12 @@ class _TranslationsSettingsNl implements TranslationsSettingsEn {
|
||||
@override String maxVolumePercent({required Object percent}) => '${percent}%';
|
||||
@override String get discordRichPresence => 'Discord Rich Presence';
|
||||
@override String get discordRichPresenceDescription => 'Toon op Discord wat je aan het kijken bent';
|
||||
@override String get autoPip => 'Automatische beeld-in-beeld';
|
||||
@override String get autoPipDescription => 'Automatisch beeld-in-beeld activeren bij het verlaten van de app tijdens afspelen';
|
||||
@override String get matchContentFrameRate => 'Inhoudsframesnelheid afstemmen';
|
||||
@override String get matchContentFrameRateDescription => 'Pas de schermverversingssnelheid aan op de video-inhoud, vermindert haperingen en bespaart batterij';
|
||||
@override String get tunneledPlayback => 'Tunneled Playback';
|
||||
@override String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
@override String get requireProfileSelectionOnOpen => 'Vraag om profiel bij openen';
|
||||
@override String get requireProfileSelectionOnOpenDescription => 'Toon profielselectie telkens wanneer de app wordt geopend';
|
||||
@override String get confirmExitOnBack => 'Bevestigen voor afsluiten';
|
||||
@@ -1027,6 +1031,7 @@ class _TranslationsVideoSettingsNl implements TranslationsVideoSettingsEn {
|
||||
@override String get audioOutput => 'Audio-uitvoer';
|
||||
@override String get performanceOverlay => 'Prestatie-overlay';
|
||||
@override String get audioPassthrough => 'Audio-doorvoer';
|
||||
@override String get audioNormalization => 'Audionormalisatie';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -1484,6 +1489,8 @@ extension on TranslationsNl {
|
||||
'settings.discordRichPresenceDescription' => 'Toon op Discord wat je aan het kijken bent',
|
||||
'settings.matchContentFrameRate' => 'Inhoudsframesnelheid afstemmen',
|
||||
'settings.matchContentFrameRateDescription' => 'Pas de schermverversingssnelheid aan op de video-inhoud, vermindert haperingen en bespaart batterij',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => 'Vraag om profiel bij openen',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => 'Toon profielselectie telkens wanneer de app wordt geopend',
|
||||
'settings.confirmExitOnBack' => 'Bevestigen voor afsluiten',
|
||||
@@ -2021,6 +2028,7 @@ extension on TranslationsNl {
|
||||
'videoSettings.audioOutput' => 'Audio-uitvoer',
|
||||
'videoSettings.performanceOverlay' => 'Prestatie-overlay',
|
||||
'videoSettings.audioPassthrough' => 'Audio-doorvoer',
|
||||
'videoSettings.audioNormalization' => 'Audionormalisatie',
|
||||
'externalPlayer.title' => 'Externe speler',
|
||||
'externalPlayer.useExternalPlayer' => 'Externe speler gebruiken',
|
||||
'externalPlayer.useExternalPlayerDescription' => 'Open video\'s in een externe app in plaats van de ingebouwde speler',
|
||||
|
||||
@@ -316,8 +316,12 @@ class _TranslationsSettingsSv implements TranslationsSettingsEn {
|
||||
@override String maxVolumePercent({required Object percent}) => '${percent}%';
|
||||
@override String get discordRichPresence => 'Discord Rich Presence';
|
||||
@override String get discordRichPresenceDescription => 'Visa vad du tittar på i Discord';
|
||||
@override String get autoPip => 'Automatisk bild-i-bild';
|
||||
@override String get autoPipDescription => 'Aktivera bild-i-bild automatiskt när appen lämnas under uppspelning';
|
||||
@override String get matchContentFrameRate => 'Matcha innehållets bildfrekvens';
|
||||
@override String get matchContentFrameRateDescription => 'Justera skärmens uppdateringsfrekvens för att matcha videoinnehållet, minskar hackighet och sparar batteri';
|
||||
@override String get tunneledPlayback => 'Tunneled Playback';
|
||||
@override String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
@override String get requireProfileSelectionOnOpen => 'Fråga efter profil vid appstart';
|
||||
@override String get requireProfileSelectionOnOpenDescription => 'Visa profilval varje gång appen öppnas';
|
||||
@override String get confirmExitOnBack => 'Bekräfta innan avslut';
|
||||
@@ -1027,6 +1031,7 @@ class _TranslationsVideoSettingsSv implements TranslationsVideoSettingsEn {
|
||||
@override String get audioOutput => 'Ljudutgång';
|
||||
@override String get performanceOverlay => 'Prestandaöverlägg';
|
||||
@override String get audioPassthrough => 'Ljudgenomkoppling';
|
||||
@override String get audioNormalization => 'Ljudnormalisering';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -1484,6 +1489,8 @@ extension on TranslationsSv {
|
||||
'settings.discordRichPresenceDescription' => 'Visa vad du tittar på i Discord',
|
||||
'settings.matchContentFrameRate' => 'Matcha innehållets bildfrekvens',
|
||||
'settings.matchContentFrameRateDescription' => 'Justera skärmens uppdateringsfrekvens för att matcha videoinnehållet, minskar hackighet och sparar batteri',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => 'Fråga efter profil vid appstart',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => 'Visa profilval varje gång appen öppnas',
|
||||
'settings.confirmExitOnBack' => 'Bekräfta innan avslut',
|
||||
@@ -2021,6 +2028,7 @@ extension on TranslationsSv {
|
||||
'videoSettings.audioOutput' => 'Ljudutgång',
|
||||
'videoSettings.performanceOverlay' => 'Prestandaöverlägg',
|
||||
'videoSettings.audioPassthrough' => 'Ljudgenomkoppling',
|
||||
'videoSettings.audioNormalization' => 'Ljudnormalisering',
|
||||
'externalPlayer.title' => 'Extern spelare',
|
||||
'externalPlayer.useExternalPlayer' => 'Använd extern spelare',
|
||||
'externalPlayer.useExternalPlayerDescription' => 'Öppna videor i en extern app istället för den inbyggda spelaren',
|
||||
|
||||
@@ -316,8 +316,12 @@ class _TranslationsSettingsZh implements TranslationsSettingsEn {
|
||||
@override String maxVolumePercent({required Object percent}) => '${percent}%';
|
||||
@override String get discordRichPresence => 'Discord 动态状态';
|
||||
@override String get discordRichPresenceDescription => '在 Discord 上显示您正在观看的内容';
|
||||
@override String get autoPip => '自动画中画';
|
||||
@override String get autoPipDescription => '在播放期间离开应用时自动进入画中画模式';
|
||||
@override String get matchContentFrameRate => '匹配内容帧率';
|
||||
@override String get matchContentFrameRateDescription => '调整显示刷新率以匹配视频内容,减少画面抖动并节省电量';
|
||||
@override String get tunneledPlayback => 'Tunneled Playback';
|
||||
@override String get tunneledPlaybackDescription => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content';
|
||||
@override String get requireProfileSelectionOnOpen => '打开应用时询问配置文件';
|
||||
@override String get requireProfileSelectionOnOpenDescription => '每次打开应用时显示配置文件选择';
|
||||
@override String get confirmExitOnBack => '退出前确认';
|
||||
@@ -1027,6 +1031,7 @@ class _TranslationsVideoSettingsZh implements TranslationsVideoSettingsEn {
|
||||
@override String get audioOutput => '音频输出';
|
||||
@override String get performanceOverlay => '性能监控';
|
||||
@override String get audioPassthrough => '音频直通';
|
||||
@override String get audioNormalization => '音频标准化';
|
||||
}
|
||||
|
||||
// Path: externalPlayer
|
||||
@@ -1484,6 +1489,8 @@ extension on TranslationsZh {
|
||||
'settings.discordRichPresenceDescription' => '在 Discord 上显示您正在观看的内容',
|
||||
'settings.matchContentFrameRate' => '匹配内容帧率',
|
||||
'settings.matchContentFrameRateDescription' => '调整显示刷新率以匹配视频内容,减少画面抖动并节省电量',
|
||||
'settings.tunneledPlayback' => 'Tunneled Playback',
|
||||
'settings.tunneledPlaybackDescription' => 'Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content',
|
||||
'settings.requireProfileSelectionOnOpen' => '打开应用时询问配置文件',
|
||||
'settings.requireProfileSelectionOnOpenDescription' => '每次打开应用时显示配置文件选择',
|
||||
'settings.confirmExitOnBack' => '退出前确认',
|
||||
@@ -2021,6 +2028,7 @@ extension on TranslationsZh {
|
||||
'videoSettings.audioOutput' => '音频输出',
|
||||
'videoSettings.performanceOverlay' => '性能监控',
|
||||
'videoSettings.audioPassthrough' => '音频直通',
|
||||
'videoSettings.audioNormalization' => '音频标准化',
|
||||
'externalPlayer.title' => '外部播放器',
|
||||
'externalPlayer.useExternalPlayer' => '使用外部播放器',
|
||||
'externalPlayer.useExternalPlayerDescription' => '在外部应用中打开视频,而不是使用内置播放器',
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Discord Rich Presence",
|
||||
"discordRichPresenceDescription": "Visa vad du tittar på i Discord",
|
||||
"autoPip": "Automatisk bild-i-bild",
|
||||
"autoPipDescription": "Aktivera bild-i-bild automatiskt när appen lämnas under uppspelning",
|
||||
"matchContentFrameRate": "Matcha innehållets bildfrekvens",
|
||||
"matchContentFrameRateDescription": "Justera skärmens uppdateringsfrekvens för att matcha videoinnehållet, minskar hackighet och sparar batteri",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "Fråga efter profil vid appstart",
|
||||
"requireProfileSelectionOnOpenDescription": "Visa profilval varje gång appen öppnas",
|
||||
"confirmExitOnBack": "Bekräfta innan avslut",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "Ljudutgång",
|
||||
"performanceOverlay": "Prestandaöverlägg",
|
||||
"audioPassthrough": "Ljudgenomkoppling"
|
||||
"audioPassthrough": "Ljudgenomkoppling",
|
||||
"audioNormalization": "Ljudnormalisering"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "Extern spelare",
|
||||
|
||||
@@ -197,8 +197,12 @@
|
||||
"maxVolumePercent": "${percent}%",
|
||||
"discordRichPresence": "Discord 动态状态",
|
||||
"discordRichPresenceDescription": "在 Discord 上显示您正在观看的内容",
|
||||
"autoPip": "自动画中画",
|
||||
"autoPipDescription": "在播放期间离开应用时自动进入画中画模式",
|
||||
"matchContentFrameRate": "匹配内容帧率",
|
||||
"matchContentFrameRateDescription": "调整显示刷新率以匹配视频内容,减少画面抖动并节省电量",
|
||||
"tunneledPlayback": "Tunneled Playback",
|
||||
"tunneledPlaybackDescription": "Use hardware-accelerated video tunneling. Disable if you see a black screen with audio on HDR content",
|
||||
"requireProfileSelectionOnOpen": "打开应用时询问配置文件",
|
||||
"requireProfileSelectionOnOpenDescription": "每次打开应用时显示配置文件选择",
|
||||
"confirmExitOnBack": "退出前确认",
|
||||
@@ -807,7 +811,8 @@
|
||||
"hdr": "HDR",
|
||||
"audioOutput": "音频输出",
|
||||
"performanceOverlay": "性能监控",
|
||||
"audioPassthrough": "音频直通"
|
||||
"audioPassthrough": "音频直通",
|
||||
"audioNormalization": "音频标准化"
|
||||
},
|
||||
"externalPlayer": {
|
||||
"title": "外部播放器",
|
||||
|
||||
@@ -10,6 +10,7 @@ class PlayerAndroid extends PlayerBase {
|
||||
static const _eventChannel = EventChannel('com.plezy/exo_player/events');
|
||||
|
||||
int? _bufferSizeBytes;
|
||||
bool _tunnelingEnabled = true;
|
||||
|
||||
@override
|
||||
MethodChannel get methodChannel => _methodChannel;
|
||||
@@ -50,6 +51,7 @@ class PlayerAndroid extends PlayerBase {
|
||||
try {
|
||||
final result = await methodChannel.invokeMethod<bool>('initialize', {
|
||||
'bufferSizeBytes': _bufferSizeBytes,
|
||||
'tunnelingEnabled': _tunnelingEnabled,
|
||||
});
|
||||
initialized = result == true;
|
||||
if (!initialized) {
|
||||
@@ -188,6 +190,9 @@ class PlayerAndroid extends PlayerBase {
|
||||
case 'demuxer-max-bytes':
|
||||
_bufferSizeBytes = int.tryParse(value);
|
||||
break;
|
||||
case 'tunneled-playback':
|
||||
_tunnelingEnabled = value != 'no';
|
||||
break;
|
||||
// Other properties are no-ops for ExoPlayer
|
||||
}
|
||||
}
|
||||
@@ -363,4 +368,15 @@ class PlayerAndroid extends PlayerBase {
|
||||
|
||||
await methodChannel.invokeMethod('abandonAudioFocus');
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Log Level
|
||||
// ============================================
|
||||
|
||||
@override
|
||||
Future<void> setLogLevel(String level) async {
|
||||
checkDisposed();
|
||||
if (!initialized) return;
|
||||
await methodChannel.invokeMethod('setLogLevel', {'level': level});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1283,6 +1283,10 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
// Determine content type label for chip
|
||||
final contentTypeLabel = heroItem.isMovie ? t.discover.movie : t.discover.tvShow;
|
||||
|
||||
// Spoiler protection
|
||||
final hideSpoilers = context.watch<SettingsProvider>().hideSpoilers;
|
||||
final shouldHideSpoiler = hideSpoilers && heroItem.shouldHideSpoiler;
|
||||
|
||||
// Build semantic label for hero item
|
||||
final heroLabel = isEpisode ? "${heroItem.grandparentTitle}, ${heroItem.title}" : heroItem.title;
|
||||
|
||||
@@ -1492,7 +1496,7 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
if (!isLargeScreen) ...[const SizedBox(height: 20), _buildSmartPlayButton(heroItem)],
|
||||
|
||||
// Summary with episode info (Apple TV style)
|
||||
if (heroItem.summary != null) ...[
|
||||
if (heroItem.summary != null && !shouldHideSpoiler) ...[
|
||||
const SizedBox(height: 12),
|
||||
RichText(
|
||||
maxLines: 2,
|
||||
@@ -1523,6 +1527,21 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
],
|
||||
),
|
||||
),
|
||||
] else if (shouldHideSpoiler && isEpisode && heroItem.parentIndex != null && heroItem.index != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'S${heroItem.parentIndex}, E${heroItem.index}: ${heroItem.title}',
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: isLargeScreen ? TextAlign.left : TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: isLargeScreen
|
||||
? Colors.white.withValues(alpha: 0.7)
|
||||
: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7),
|
||||
fontSize: 14,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
// On large screens: show button after summary
|
||||
|
||||
@@ -392,6 +392,8 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
|
||||
filterParams['sort'] = _selectedSort!.getSortKey(descending: _isSortDescending);
|
||||
}
|
||||
|
||||
filterParams['includeCollections'] = '1';
|
||||
|
||||
return filterParams;
|
||||
}
|
||||
|
||||
@@ -798,6 +800,8 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
|
||||
final filterParams = Map<String, String>.from(_selectedFilters);
|
||||
final typeId = _getGroupingTypeId();
|
||||
|
||||
filterParams['includeCollections'] = '1';
|
||||
|
||||
try {
|
||||
final chars = await client.getFirstCharacters(
|
||||
widget.library.key,
|
||||
|
||||
@@ -10,6 +10,7 @@ import '../../mixins/refreshable.dart';
|
||||
import '../../mixins/tab_navigation_mixin.dart';
|
||||
import '../../providers/multi_server_provider.dart';
|
||||
import '../../utils/app_logger.dart';
|
||||
import '../../utils/desktop_window_padding.dart';
|
||||
import '../../utils/platform_detector.dart';
|
||||
import '../../widgets/app_icon.dart';
|
||||
import '../../widgets/focusable_tab_chip.dart';
|
||||
@@ -267,7 +268,7 @@ class _LiveTvScreenState extends State<LiveTvScreen>
|
||||
],
|
||||
)
|
||||
: Text(t.liveTv.title),
|
||||
actions: [
|
||||
actions: DesktopAppBarHelper.buildAdjustedActions([
|
||||
FocusableActionBar(
|
||||
key: _actionBarKey,
|
||||
onNavigateLeft: () => getTabChipFocusNode(tabCount - 1).requestFocus(),
|
||||
@@ -280,7 +281,7 @@ class _LiveTvScreenState extends State<LiveTvScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
]),
|
||||
),
|
||||
body: _buildLiveTvBody(theme, useSideNav),
|
||||
);
|
||||
|
||||
@@ -120,7 +120,7 @@ class _ProgramDetailsSheetContentState extends State<_ProgramDetailsSheetContent
|
||||
}
|
||||
|
||||
if (!program.isCurrentlyAiring && widget.onTuneChannel != null) {
|
||||
buttons.add(const SizedBox(width: 8));
|
||||
if (buttons.isNotEmpty) buttons.add(const SizedBox(width: 8));
|
||||
final idx = buttonIndex;
|
||||
buttons.add(
|
||||
FocusableButton(
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../focus/dpad_navigator.dart';
|
||||
import '../../../focus/input_mode_tracker.dart';
|
||||
import '../../../focus/key_event_utils.dart';
|
||||
import '../../../i18n/strings.g.dart';
|
||||
import '../../../models/livetv_channel.dart';
|
||||
@@ -68,6 +69,7 @@ class GuideTabState extends State<GuideTab> {
|
||||
|
||||
/// Focus into the guide content (called from tab bar navigation or initial load).
|
||||
void focusContent() {
|
||||
if (!InputModeTracker.isKeyboardMode(context)) return;
|
||||
// If still loading programs, defer until the Focus widget is in the tree.
|
||||
if (_isLoading) {
|
||||
_pendingFocus = true;
|
||||
@@ -999,16 +1001,16 @@ class GuideTabState extends State<GuideTab> {
|
||||
if (isFocused) {
|
||||
materialColor = theme.colorScheme.primary.withValues(alpha: 0.25);
|
||||
} else if (isCurrentlyAiring) {
|
||||
materialColor = theme.colorScheme.primaryContainer;
|
||||
materialColor = theme.colorScheme.onSurface;
|
||||
} else {
|
||||
materialColor = theme.colorScheme.surfaceContainerHigh;
|
||||
materialColor = theme.colorScheme.onSurface.withValues(alpha: 0.12);
|
||||
}
|
||||
|
||||
Color titleColor;
|
||||
if (isFocused) {
|
||||
titleColor = theme.colorScheme.primary;
|
||||
} else if (isCurrentlyAiring) {
|
||||
titleColor = theme.colorScheme.onPrimaryContainer;
|
||||
titleColor = theme.colorScheme.surface;
|
||||
} else {
|
||||
titleColor = theme.colorScheme.onSurface;
|
||||
}
|
||||
@@ -1017,7 +1019,7 @@ class GuideTabState extends State<GuideTab> {
|
||||
if (isFocused) {
|
||||
subtitleColor = theme.colorScheme.primary.withValues(alpha: 0.7);
|
||||
} else if (isCurrentlyAiring) {
|
||||
subtitleColor = theme.colorScheme.onPrimaryContainer.withValues(alpha: 0.7);
|
||||
subtitleColor = theme.colorScheme.surface.withValues(alpha: 0.7);
|
||||
} else {
|
||||
subtitleColor = theme.colorScheme.onSurfaceVariant;
|
||||
}
|
||||
@@ -1027,12 +1029,10 @@ class GuideTabState extends State<GuideTab> {
|
||||
child: Material(
|
||||
color: materialColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||
side: isFocused ? BorderSide(color: theme.colorScheme.primary, width: 2) : BorderSide.none,
|
||||
),
|
||||
child: InkWell(
|
||||
canRequestFocus: false,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||
onTap: () => _showProgramDetails(channel, program),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
|
||||
+87
-120
@@ -9,11 +9,7 @@ import '../i18n/strings.g.dart';
|
||||
import '../mixins/refreshable.dart';
|
||||
import '../models/plex_metadata.dart';
|
||||
import '../providers/multi_server_provider.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
import '../services/settings_service.dart' show ViewMode;
|
||||
import '../utils/app_logger.dart';
|
||||
import '../utils/grid_size_calculator.dart';
|
||||
import '../utils/sliver_adaptive_media_builder.dart';
|
||||
import '../utils/snackbar_helper.dart';
|
||||
import '../widgets/desktop_app_bar.dart';
|
||||
import '../widgets/focusable_media_card.dart';
|
||||
@@ -130,7 +126,7 @@ class _SearchScreenState extends State<SearchScreen> with Refreshable, FullRefre
|
||||
/// Focus the search input field
|
||||
@override
|
||||
void focusSearchInput() {
|
||||
FocusUtils.requestFocusAfterBuild(this, _searchFocusNode);
|
||||
_searchFocusNode.requestFocus();
|
||||
}
|
||||
|
||||
/// Set the search query externally (e.g. from companion remote)
|
||||
@@ -196,130 +192,101 @@ class _SearchScreenState extends State<SearchScreen> with Refreshable, FullRefre
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
/// Calculate column count based on available width.
|
||||
int _calculateColumnCount(double availableWidth, double maxCrossAxisExtent, double crossAxisSpacing) {
|
||||
return ((availableWidth + crossAxisSpacing) / (maxCrossAxisExtent + crossAxisSpacing)).ceil().clamp(1, 100);
|
||||
Widget _buildResultsList(BuildContext context) {
|
||||
final multiServer = context.watch<MultiServerProvider>();
|
||||
final showServerName = multiServer.totalServerCount > 1;
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final item = _searchResults[index];
|
||||
return FocusableMediaCard(
|
||||
key: Key(item.globalKey),
|
||||
item: item,
|
||||
forceListMode: true,
|
||||
focusNode: index == 0 ? _firstResultFocusNode : null,
|
||||
onListRefresh: () => updateItem(item.ratingKey),
|
||||
onNavigateLeft: _navigateToSidebar,
|
||||
onNavigateUp: index == 0 ? focusSearchInput : null,
|
||||
showServerName: showServerName,
|
||||
);
|
||||
}, childCount: _searchResults.length),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Use LayoutBuilder to get the actual available width (accounting for sidebar)
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final availableWidth = constraints.maxWidth;
|
||||
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
DesktopSliverAppBar(title: Text(t.common.search), floating: true),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
|
||||
child: Focus(
|
||||
onKeyEvent: _handleSearchInputKeyEvent,
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
focusNode: _searchFocusNode,
|
||||
decoration: InputDecoration(
|
||||
hintText: t.search.hint,
|
||||
prefixIcon: const AppIcon(Symbols.search_rounded, fill: 1),
|
||||
suffixIcon: _searchController.text.isNotEmpty
|
||||
? IconButton(
|
||||
icon: const AppIcon(Symbols.clear_rounded, fill: 1),
|
||||
onPressed: () {
|
||||
_searchController.clear();
|
||||
// State update handled by listener
|
||||
},
|
||||
)
|
||||
: null,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(100)),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(100)),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(100)),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
),
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
DesktopSliverAppBar(title: Text(t.common.search), floating: true),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
|
||||
child: Focus(
|
||||
onKeyEvent: _handleSearchInputKeyEvent,
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
focusNode: _searchFocusNode,
|
||||
decoration: InputDecoration(
|
||||
hintText: t.search.hint,
|
||||
prefixIcon: const AppIcon(Symbols.search_rounded, fill: 1),
|
||||
suffixIcon: _searchController.text.isNotEmpty
|
||||
? IconButton(
|
||||
icon: const AppIcon(Symbols.clear_rounded, fill: 1),
|
||||
onPressed: () {
|
||||
_searchController.clear();
|
||||
// State update handled by listener
|
||||
},
|
||||
)
|
||||
: null,
|
||||
filled: true,
|
||||
fillColor: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(100)),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(100)),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(100)),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_isSearching)
|
||||
const SliverFillRemaining(child: Center(child: CircularProgressIndicator()))
|
||||
else if (!_hasSearched)
|
||||
SliverFillRemaining(
|
||||
child: StateMessageWidget(
|
||||
message: t.search.searchYourMedia,
|
||||
subtitle: t.search.enterTitleActorOrKeyword,
|
||||
icon: Symbols.search_rounded,
|
||||
iconSize: 80,
|
||||
),
|
||||
)
|
||||
else if (_searchResults.isEmpty)
|
||||
SliverFillRemaining(
|
||||
child: StateMessageWidget(
|
||||
message: t.messages.noResultsFound,
|
||||
subtitle: t.search.tryDifferentTerm,
|
||||
icon: Symbols.search_off_rounded,
|
||||
iconSize: 80,
|
||||
),
|
||||
)
|
||||
else
|
||||
Consumer<SettingsProvider>(
|
||||
builder: (context, settingsProvider, child) {
|
||||
final maxCrossAxisExtent = GridSizeCalculator.getMaxCrossAxisExtent(
|
||||
context,
|
||||
settingsProvider.libraryDensity,
|
||||
);
|
||||
const gridPadding = EdgeInsets.all(16);
|
||||
const crossAxisSpacing = 8.0;
|
||||
final gridAvailableWidth = availableWidth - gridPadding.left - gridPadding.right;
|
||||
final columnCount = _calculateColumnCount(
|
||||
gridAvailableWidth,
|
||||
maxCrossAxisExtent,
|
||||
crossAxisSpacing,
|
||||
);
|
||||
final isList = settingsProvider.viewMode == ViewMode.list;
|
||||
|
||||
return buildAdaptiveMediaSliverBuilder<PlexMetadata>(
|
||||
context: context,
|
||||
items: _searchResults,
|
||||
itemBuilder: (context, item, index) {
|
||||
// In list view, all items are in the first column
|
||||
final isFirstColumn = isList || GridSizeCalculator.isFirstColumn(index, columnCount);
|
||||
final isFirstRow = isList ? index == 0 : GridSizeCalculator.isFirstRow(index, columnCount);
|
||||
return FocusableMediaCard(
|
||||
key: Key(item.ratingKey),
|
||||
item: item,
|
||||
focusNode: index == 0 ? _firstResultFocusNode : null,
|
||||
onListRefresh: () => updateItem(item.ratingKey),
|
||||
onNavigateLeft: isFirstColumn ? _navigateToSidebar : null,
|
||||
onNavigateUp: isFirstRow ? focusSearchInput : null,
|
||||
);
|
||||
},
|
||||
viewMode: settingsProvider.viewMode,
|
||||
density: settingsProvider.libraryDensity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
childAspectRatio: 2 / 3.3,
|
||||
crossAxisSpacing: 8,
|
||||
mainAxisSpacing: 8,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
if (_isSearching)
|
||||
const SliverFillRemaining(child: Center(child: CircularProgressIndicator()))
|
||||
else if (!_hasSearched)
|
||||
SliverFillRemaining(
|
||||
child: StateMessageWidget(
|
||||
message: t.search.searchYourMedia,
|
||||
subtitle: t.search.enterTitleActorOrKeyword,
|
||||
icon: Symbols.search_rounded,
|
||||
iconSize: 80,
|
||||
),
|
||||
)
|
||||
else if (_searchResults.isEmpty)
|
||||
SliverFillRemaining(
|
||||
child: StateMessageWidget(
|
||||
message: t.messages.noResultsFound,
|
||||
subtitle: t.search.tryDifferentTerm,
|
||||
icon: Symbols.search_off_rounded,
|
||||
iconSize: 80,
|
||||
),
|
||||
)
|
||||
else
|
||||
_buildResultsList(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,11 @@ import '../providers/download_provider.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
import '../utils/content_utils.dart';
|
||||
import '../services/download_storage_service.dart';
|
||||
import '../widgets/collapsible_text.dart';
|
||||
import '../widgets/plex_optimized_image.dart';
|
||||
import '../models/plex_metadata.dart';
|
||||
import '../utils/provider_extensions.dart';
|
||||
import '../utils/platform_detector.dart';
|
||||
import '../utils/video_player_navigation.dart';
|
||||
import '../utils/formatters.dart';
|
||||
import '../widgets/desktop_app_bar.dart';
|
||||
@@ -658,14 +660,24 @@ class _EpisodeCardState extends State<_EpisodeCard> {
|
||||
// Summary (hidden when spoiler protection is active)
|
||||
if (!shouldBlur && widget.episode.summary != null && widget.episode.summary!.isNotEmpty) ...[
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
widget.episode.summary!,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: tokens(context).textMuted, height: 1.3),
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
if (PlatformDetector.isTV())
|
||||
Text(
|
||||
widget.episode.summary!,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: tokens(context).textMuted, height: 1.3),
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)
|
||||
else
|
||||
CollapsibleText(
|
||||
text: widget.episode.summary!,
|
||||
maxLines: 3,
|
||||
small: true,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(color: tokens(context).textMuted, height: 1.3),
|
||||
),
|
||||
],
|
||||
|
||||
// Metadata row (duration, watched status)
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import '../../focus/focusable_action_bar.dart';
|
||||
import '../../focus/focusable_button.dart';
|
||||
import '../../focus/key_event_utils.dart';
|
||||
import '../../i18n/strings.g.dart';
|
||||
import '../../utils/app_logger.dart';
|
||||
import '../../utils/platform_detector.dart';
|
||||
import '../../utils/snackbar_helper.dart';
|
||||
import '../../widgets/desktop_app_bar.dart';
|
||||
|
||||
@@ -22,12 +26,41 @@ class LogsScreen extends StatefulWidget {
|
||||
|
||||
class _LogsScreenState extends State<LogsScreen> {
|
||||
List<LogEntry> _logs = [];
|
||||
String _deviceInfo = '';
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_logs = MemoryLogOutput.getLogs();
|
||||
_loadDeviceInfo();
|
||||
}
|
||||
|
||||
Future<void> _loadDeviceInfo() async {
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
final deviceInfo = DeviceInfoPlugin();
|
||||
final buffer = StringBuffer();
|
||||
buffer.writeln('${t.app.title} v${packageInfo.version} (${packageInfo.buildNumber})');
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
final info = await deviceInfo.androidInfo;
|
||||
buffer.writeln('Android ${info.version.release} (API ${info.version.sdkInt})');
|
||||
buffer.writeln('${info.manufacturer} ${info.model}');
|
||||
if (TvDetectionService.isTVSync()) buffer.writeln('TV mode: yes');
|
||||
} else if (Platform.isIOS) {
|
||||
final info = await deviceInfo.iosInfo;
|
||||
buffer.writeln('iOS ${info.systemVersion}');
|
||||
buffer.writeln(info.utsname.machine);
|
||||
} else if (Platform.isMacOS) {
|
||||
final info = await deviceInfo.macOsInfo;
|
||||
buffer.writeln('macOS ${info.osRelease}');
|
||||
buffer.writeln(info.model);
|
||||
} else if (Platform.isLinux) {
|
||||
final info = await deviceInfo.linuxInfo;
|
||||
buffer.writeln('Linux ${info.versionId ?? info.id}');
|
||||
}
|
||||
|
||||
if (mounted) setState(() => _deviceInfo = buffer.toString().trimRight());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -60,6 +93,10 @@ class _LogsScreenState extends State<LogsScreen> {
|
||||
|
||||
String _formatAllLogs() {
|
||||
final buffer = StringBuffer();
|
||||
if (_deviceInfo.isNotEmpty) {
|
||||
buffer.writeln(_deviceInfo);
|
||||
buffer.writeln('---');
|
||||
}
|
||||
bool isFirst = true;
|
||||
for (final log in _logs.reversed) {
|
||||
if (!isFirst) {
|
||||
@@ -175,6 +212,16 @@ class _LogsScreenState extends State<LogsScreen> {
|
||||
|
||||
List<TextSpan> _buildLogSpans() {
|
||||
final spans = <TextSpan>[];
|
||||
if (_deviceInfo.isNotEmpty) {
|
||||
spans.add(TextSpan(
|
||||
text: '$_deviceInfo\n',
|
||||
style: TextStyle(color: Colors.grey.withValues(alpha: 0.6)),
|
||||
));
|
||||
spans.add(TextSpan(
|
||||
text: '---\n',
|
||||
style: TextStyle(color: Colors.grey.withValues(alpha: 0.3)),
|
||||
));
|
||||
}
|
||||
for (var i = 0; i < _logs.length; i++) {
|
||||
if (i > 0) spans.add(const TextSpan(text: '\n'));
|
||||
final log = _logs[i];
|
||||
|
||||
@@ -77,7 +77,9 @@ class _SettingsScreenState extends State<SettingsScreen> with FocusableTab {
|
||||
static const _kPlayerBackend = 'player_backend';
|
||||
static const _kExternalPlayer = 'external_player';
|
||||
static const _kHardwareDecoding = 'hardware_decoding';
|
||||
static const _kAutoPip = 'auto_pip';
|
||||
static const _kMatchContentFrameRate = 'match_content_frame_rate';
|
||||
static const _kTunneledPlayback = 'tunneled_playback';
|
||||
static const _kBufferSize = 'buffer_size';
|
||||
static const _kSubtitleStyling = 'subtitle_styling';
|
||||
static const _kMpvConfig = 'mpv_config';
|
||||
@@ -120,7 +122,9 @@ class _SettingsScreenState extends State<SettingsScreen> with FocusableTab {
|
||||
bool _videoPlayerNavigationEnabled = false;
|
||||
int _maxVolume = 100;
|
||||
bool _enableDiscordRPC = false;
|
||||
bool _autoPip = true;
|
||||
bool _matchContentFrameRate = false;
|
||||
bool _tunneledPlayback = true;
|
||||
bool _useExoPlayer = true; // Android only: ExoPlayer vs MPV
|
||||
bool _requireProfileSelectionOnOpen = false;
|
||||
bool _useExternalPlayer = false;
|
||||
@@ -194,7 +198,9 @@ class _SettingsScreenState extends State<SettingsScreen> with FocusableTab {
|
||||
_videoPlayerNavigationEnabled = _settingsService.getVideoPlayerNavigationEnabled();
|
||||
_maxVolume = _settingsService.getMaxVolume();
|
||||
_enableDiscordRPC = _settingsService.getEnableDiscordRPC();
|
||||
_autoPip = _settingsService.getAutoPip();
|
||||
_matchContentFrameRate = _settingsService.getMatchContentFrameRate();
|
||||
_tunneledPlayback = _settingsService.getTunneledPlayback();
|
||||
_useExoPlayer = _settingsService.getUseExoPlayer();
|
||||
_requireProfileSelectionOnOpen = _settingsService.getRequireProfileSelectionOnOpen();
|
||||
_useExternalPlayer = _settingsService.getUseExternalPlayer();
|
||||
@@ -484,6 +490,20 @@ class _SettingsScreenState extends State<SettingsScreen> with FocusableTab {
|
||||
await _settingsService.setEnableHardwareDecoding(value);
|
||||
},
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
SwitchListTile(
|
||||
focusNode: _focusTracker.get(_kAutoPip),
|
||||
secondary: const AppIcon(Symbols.picture_in_picture_alt_rounded, fill: 1),
|
||||
title: Text(t.settings.autoPip),
|
||||
subtitle: Text(t.settings.autoPipDescription),
|
||||
value: _autoPip,
|
||||
onChanged: (value) async {
|
||||
setState(() {
|
||||
_autoPip = value;
|
||||
});
|
||||
await _settingsService.setAutoPip(value);
|
||||
},
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
SwitchListTile(
|
||||
focusNode: _focusTracker.get(_kMatchContentFrameRate),
|
||||
@@ -498,6 +518,20 @@ class _SettingsScreenState extends State<SettingsScreen> with FocusableTab {
|
||||
await _settingsService.setMatchContentFrameRate(value);
|
||||
},
|
||||
),
|
||||
if (Platform.isAndroid && _useExoPlayer)
|
||||
SwitchListTile(
|
||||
focusNode: _focusTracker.get(_kTunneledPlayback),
|
||||
secondary: const AppIcon(Symbols.tv_options_input_settings_rounded, fill: 1),
|
||||
title: Text(t.settings.tunneledPlayback),
|
||||
subtitle: Text(t.settings.tunneledPlaybackDescription),
|
||||
value: _tunneledPlayback,
|
||||
onChanged: (value) async {
|
||||
setState(() {
|
||||
_tunneledPlayback = value;
|
||||
});
|
||||
await _settingsService.setTunneledPlayback(value);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
focusNode: _focusTracker.get(_kBufferSize),
|
||||
leading: const AppIcon(Symbols.memory_rounded, fill: 1),
|
||||
|
||||
@@ -180,6 +180,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
|
||||
// App lifecycle state tracking
|
||||
bool _wasPlayingBeforeInactive = false;
|
||||
bool _autoPipEnabled = false;
|
||||
|
||||
// Services
|
||||
MediaControlsManager? _mediaControlsManager;
|
||||
@@ -315,7 +316,9 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
case AppLifecycleState.hidden:
|
||||
// App is being hidden (user is switching away)
|
||||
// Pause video since we don't support background playback (mobile only)
|
||||
// Skip if entering PiP mode - video should keep playing
|
||||
if (PlatformDetector.isMobile(context)) {
|
||||
if (Platform.isAndroid && PipService().isPipActive.value) break;
|
||||
if (player != null && _isPlayerInitialized) {
|
||||
_wasPlayingBeforeInactive = player!.state.playing;
|
||||
if (_wasPlayingBeforeInactive) {
|
||||
@@ -326,6 +329,8 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
}
|
||||
break;
|
||||
case AppLifecycleState.paused:
|
||||
// Skip if in PiP mode - video should keep playing
|
||||
if (Platform.isAndroid && PipService().isPipActive.value) break;
|
||||
// Clear media controls when app truly goes to background
|
||||
// (we don't support background playback)
|
||||
OsMediaControls.clear();
|
||||
@@ -394,6 +399,9 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
// Load buffer size from settings
|
||||
final settingsService = await SettingsService.getInstance();
|
||||
_videoPlayerNavigationEnabled = settingsService.getVideoPlayerNavigationEnabled();
|
||||
if (Platform.isAndroid) {
|
||||
_autoPipEnabled = settingsService.getAutoPip();
|
||||
}
|
||||
final bufferSizeMB = settingsService.getBufferSize();
|
||||
final enableHardwareDecoding = settingsService.getEnableHardwareDecoding();
|
||||
final debugLoggingEnabled = settingsService.getEnableDebugLogging();
|
||||
@@ -403,6 +411,10 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
player = Player(useExoPlayer: useExoPlayer);
|
||||
|
||||
await player!.setProperty('sub-ass', 'yes'); // Enable libass
|
||||
if (Platform.isAndroid && useExoPlayer) {
|
||||
final tunneledPlayback = settingsService.getTunneledPlayback();
|
||||
await player!.setProperty('tunneled-playback', tunneledPlayback ? 'yes' : 'no');
|
||||
}
|
||||
if (bufferSizeMB > 0) {
|
||||
final bufferSizeBytes = bufferSizeMB * 1024 * 1024;
|
||||
await player!.setProperty('demuxer-max-bytes', bufferSizeBytes.toString());
|
||||
@@ -458,6 +470,11 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
await player!.setProperty('sub-delay', offsetSeconds.toString());
|
||||
}
|
||||
|
||||
// Apply audio normalization (loudnorm filter)
|
||||
if (settingsService.getAudioNormalization()) {
|
||||
await player!.setProperty('af', 'loudnorm=I=-14:TP=-3:LRA=4');
|
||||
}
|
||||
|
||||
// Apply custom MPV config entries
|
||||
final customMpvConfig = settingsService.getEnabledMpvConfigEntries();
|
||||
for (final entry in customMpvConfig.entries) {
|
||||
@@ -1066,6 +1083,16 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
};
|
||||
_videoPIPManager!.isPipActive.addListener(_onPipStateChanged);
|
||||
|
||||
// Auto-PiP: set up callback for API 26-30 path and initial state
|
||||
if (Platform.isAndroid && _autoPipEnabled) {
|
||||
PipService.onAutoPipEntering = () {
|
||||
_videoFilterManager?.enterPipMode();
|
||||
};
|
||||
if (player!.state.playing) {
|
||||
_videoPIPManager!.updateAutoPipState(isPlaying: true);
|
||||
}
|
||||
}
|
||||
|
||||
// Shader Service (MPV only)
|
||||
_shaderService = ShaderService(player!);
|
||||
if (_shaderService!.isSupported) {
|
||||
@@ -1628,9 +1655,11 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
_sendLiveTimeline('stopped');
|
||||
_stopLiveTimelineUpdates();
|
||||
|
||||
// Remove PiP state listener, clear callback, and dispose video filter manager
|
||||
// Remove PiP state listener, clear callbacks, disable auto-PiP, and dispose video filter manager
|
||||
_videoPIPManager?.isPipActive.removeListener(_onPipStateChanged);
|
||||
_videoPIPManager?.onBeforeEnterPip = null;
|
||||
_videoPIPManager?.disableAutoPip();
|
||||
PipService.onAutoPipEntering = null;
|
||||
_videoFilterManager?.dispose();
|
||||
|
||||
// Release cached BIF thumbnail data
|
||||
@@ -1760,6 +1789,11 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
} else {
|
||||
DiscordRPCService.instance.pausePlayback();
|
||||
}
|
||||
|
||||
// Update auto-PiP readiness on Android
|
||||
if (Platform.isAndroid && _autoPipEnabled) {
|
||||
_videoPIPManager?.updateAutoPipState(isPlaying: isPlaying);
|
||||
}
|
||||
}
|
||||
|
||||
void _onVideoCompleted(bool completed) async {
|
||||
@@ -2927,7 +2961,7 @@ String _getHwdecValue(bool enabled) {
|
||||
if (Platform.isMacOS || Platform.isIOS) {
|
||||
return 'videotoolbox';
|
||||
} else if (Platform.isAndroid) {
|
||||
return 'auto-safe';
|
||||
return 'mediacodec,mediacodec-copy';
|
||||
} else {
|
||||
return 'auto'; // Windows, Linux
|
||||
}
|
||||
|
||||
@@ -17,12 +17,18 @@ class PipService {
|
||||
/// ValueNotifier for PiP state - widgets can listen to this
|
||||
final ValueNotifier<bool> isPipActive = ValueNotifier<bool>(false);
|
||||
|
||||
/// Callback invoked when native side is about to auto-enter PiP (API 26-30 path)
|
||||
static VoidCallback? onAutoPipEntering;
|
||||
|
||||
Future<dynamic> _handleMethodCall(MethodCall call) async {
|
||||
switch (call.method) {
|
||||
case 'onPipChanged':
|
||||
final isInPip = call.arguments as bool;
|
||||
isPipActive.value = isInPip;
|
||||
break;
|
||||
case 'onAutoPipEntering':
|
||||
onAutoPipEntering?.call();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +36,15 @@ class PipService {
|
||||
return await _channel.invokeMethod<bool>('isSupported') ?? false;
|
||||
}
|
||||
|
||||
/// Tell the native side whether auto-PiP is ready and the current video dimensions
|
||||
static Future<void> setAutoPipReady({required bool ready, int? width, int? height}) async {
|
||||
await _channel.invokeMethod('setAutoPipReady', {
|
||||
'ready': ready,
|
||||
'width': width,
|
||||
'height': height,
|
||||
});
|
||||
}
|
||||
|
||||
static Future<(bool success, String? error)> enter({int? width, int? height}) async {
|
||||
final result = await _channel.invokeMethod<Map>('enter', {'width': width, 'height': height});
|
||||
if (result == null) {
|
||||
|
||||
@@ -64,7 +64,9 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
static const String _keyMpvConfigPresets = 'mpv_config_presets';
|
||||
static const String _keyMaxVolume = 'max_volume';
|
||||
static const String _keyEnableDiscordRPC = 'enable_discord_rpc';
|
||||
static const String _keyAutoPip = 'auto_pip';
|
||||
static const String _keyMatchContentFrameRate = 'match_content_frame_rate';
|
||||
static const String _keyTunneledPlayback = 'tunneled_playback';
|
||||
static const String _keyDefaultPlaybackSpeed = 'default_playback_speed';
|
||||
static const String _keyAutoPlayNextEpisode = 'auto_play_next_episode';
|
||||
static const String _keyUseExoPlayer = 'use_exoplayer';
|
||||
@@ -79,6 +81,7 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
static const String _keyConfirmExitOnBack = 'confirm_exit_on_back';
|
||||
static const String _keyAmbientLighting = 'ambient_lighting';
|
||||
static const String _keyAudioPassthrough = 'audio_passthrough';
|
||||
static const String _keyAudioNormalization = 'audio_normalization';
|
||||
|
||||
SettingsService._();
|
||||
|
||||
@@ -983,6 +986,15 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
return prefs.getBool(_keyEnableDiscordRPC) ?? false; // Default disabled
|
||||
}
|
||||
|
||||
// Auto Picture-in-Picture (Android only)
|
||||
Future<void> setAutoPip(bool enabled) async {
|
||||
await prefs.setBool(_keyAutoPip, enabled);
|
||||
}
|
||||
|
||||
bool getAutoPip() {
|
||||
return prefs.getBool(_keyAutoPip) ?? true; // Default enabled
|
||||
}
|
||||
|
||||
// Match Content Frame Rate (Android only)
|
||||
Future<void> setMatchContentFrameRate(bool enabled) async {
|
||||
await prefs.setBool(_keyMatchContentFrameRate, enabled);
|
||||
@@ -992,6 +1004,15 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
return prefs.getBool(_keyMatchContentFrameRate) ?? false; // Default disabled
|
||||
}
|
||||
|
||||
// Tunneled Playback (Android ExoPlayer only)
|
||||
Future<void> setTunneledPlayback(bool enabled) async {
|
||||
await prefs.setBool(_keyTunneledPlayback, enabled);
|
||||
}
|
||||
|
||||
bool getTunneledPlayback() {
|
||||
return prefs.getBool(_keyTunneledPlayback) ?? true; // Default: enabled
|
||||
}
|
||||
|
||||
// Default Playback Speed (0.5 to 3.0)
|
||||
Future<void> setDefaultPlaybackSpeed(double speed) async {
|
||||
await prefs.setDouble(_keyDefaultPlaybackSpeed, speed.clamp(0.5, 3.0));
|
||||
@@ -1149,6 +1170,15 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
return prefs.getBool(_keyAudioPassthrough) ?? false;
|
||||
}
|
||||
|
||||
// Audio Normalization
|
||||
Future<void> setAudioNormalization(bool enabled) async {
|
||||
await prefs.setBool(_keyAudioNormalization, enabled);
|
||||
}
|
||||
|
||||
bool getAudioNormalization() {
|
||||
return prefs.getBool(_keyAudioNormalization) ?? false;
|
||||
}
|
||||
|
||||
// Reset all settings to defaults
|
||||
Future<void> resetAllSettings() async {
|
||||
await Future.wait([
|
||||
@@ -1191,7 +1221,9 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
prefs.remove(_keyMpvConfigEntries),
|
||||
prefs.remove(_keyMpvConfigPresets),
|
||||
prefs.remove(_keyEnableDiscordRPC),
|
||||
prefs.remove(_keyAutoPip),
|
||||
prefs.remove(_keyMatchContentFrameRate),
|
||||
prefs.remove(_keyTunneledPlayback),
|
||||
prefs.remove(_keyDefaultPlaybackSpeed),
|
||||
prefs.remove(_keyAutoPlayNextEpisode),
|
||||
prefs.remove(_keyUseExoPlayer),
|
||||
@@ -1206,6 +1238,7 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
prefs.remove(_keyConfirmExitOnBack),
|
||||
prefs.remove(_keyAmbientLighting),
|
||||
prefs.remove(_keyAudioPassthrough),
|
||||
prefs.remove(_keyAudioNormalization),
|
||||
prefs.remove(_keyBufferSizeMigratedToAuto),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class UpdateService {
|
||||
static bool get useNativeUpdater {
|
||||
if (!isUpdateCheckEnabled) return false;
|
||||
if (Platform.isMacOS) return !_isHomebrewInstall();
|
||||
if (Platform.isWindows) return _isInstalledApp();
|
||||
if (Platform.isWindows) return _isInstalledApp() && !_isWingetInstall();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,17 @@ class UpdateService {
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the Windows app was installed via winget.
|
||||
/// The Inno Setup installer writes a .winget marker file when invoked with /WINGET=1.
|
||||
static bool _isWingetInstall() {
|
||||
try {
|
||||
final exeDir = File(Platform.resolvedExecutable).parent.path;
|
||||
return File('$exeDir\\.winget').existsSync();
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the Windows app is an installed copy (not portable).
|
||||
/// The Inno Setup installer places unins000.exe next to the executable.
|
||||
static bool _isInstalledApp() {
|
||||
|
||||
@@ -22,20 +22,8 @@ class VideoPIPManager {
|
||||
/// Access PiP state from the service
|
||||
ValueNotifier<bool> get isPipActive => PipService().isPipActive;
|
||||
|
||||
/// Toggle native PiP
|
||||
/// Returns a tuple of (success, error message) for error handling
|
||||
Future<(bool success, String? error)> togglePIP() async {
|
||||
final supported = await PipService.isSupported();
|
||||
if (!supported) return (false, 'PiP not supported on this device');
|
||||
|
||||
// Reset video filter to contain mode BEFORE entering PiP
|
||||
// This prevents the zoomed/cropped view from being shown in PiP
|
||||
onBeforeEnterPip?.call();
|
||||
|
||||
// Wait a frame for the filter change to take effect
|
||||
await Future.delayed(const Duration(milliseconds: 50));
|
||||
|
||||
// Get display dimensions for correct aspect ratio (accounts for pixel aspect ratio)
|
||||
/// Get current video dimensions (display or storage or fallback to viewport)
|
||||
Future<(int? width, int? height)> _getVideoDimensions() async {
|
||||
int? width;
|
||||
int? height;
|
||||
|
||||
@@ -46,11 +34,8 @@ class VideoPIPManager {
|
||||
width = int.tryParse(dwidth);
|
||||
height = int.tryParse(dheight);
|
||||
}
|
||||
} catch (_) {
|
||||
// Fall through to storage dimensions
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
// Fallback to storage dimensions (less accurate for anamorphic content)
|
||||
if (width == null || height == null) {
|
||||
try {
|
||||
final videoWidth = await player.getProperty('width');
|
||||
@@ -59,15 +44,44 @@ class VideoPIPManager {
|
||||
width = int.tryParse(videoWidth);
|
||||
height = int.tryParse(videoHeight);
|
||||
}
|
||||
} catch (_) {
|
||||
// Fall through to viewport size
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
// Fall back to viewport size if video dimensions unavailable
|
||||
width ??= _playerSize?.width.toInt();
|
||||
height ??= _playerSize?.height.toInt();
|
||||
|
||||
return await PipService.enter(width: width, height: height);
|
||||
return (width, height);
|
||||
}
|
||||
|
||||
/// Toggle native PiP
|
||||
/// Returns a tuple of (success, error message) for error handling
|
||||
Future<(bool success, String? error)> togglePIP() async {
|
||||
final supported = await PipService.isSupported();
|
||||
if (!supported) return (false, 'PiP not supported on this device');
|
||||
|
||||
// Reset video filter to contain mode BEFORE entering PiP
|
||||
onBeforeEnterPip?.call();
|
||||
|
||||
// Wait a frame for the filter change to take effect
|
||||
await Future.delayed(const Duration(milliseconds: 50));
|
||||
|
||||
final dims = await _getVideoDimensions();
|
||||
return await PipService.enter(width: dims.$1, height: dims.$2);
|
||||
}
|
||||
|
||||
/// Update auto-PiP readiness on the native side
|
||||
Future<void> updateAutoPipState({required bool isPlaying}) async {
|
||||
if (!isPlaying) {
|
||||
await PipService.setAutoPipReady(ready: false);
|
||||
return;
|
||||
}
|
||||
|
||||
final dims = await _getVideoDimensions();
|
||||
await PipService.setAutoPipReady(ready: true, width: dims.$1, height: dims.$2);
|
||||
}
|
||||
|
||||
/// Disable auto-PiP (called on dispose or when leaving player)
|
||||
Future<void> disableAutoPip() async {
|
||||
await PipService.setAutoPipReady(ready: false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,11 +102,13 @@ extension PlexMetadataType on PlexMetadata {
|
||||
bool get isVideoContent => ContentTypes.videoTypes.contains(_lowerType);
|
||||
|
||||
/// Whether this episode should have spoiler protection applied.
|
||||
/// True when the item is an unwatched episode with no active progress.
|
||||
/// True when the item is an unwatched episode watched less than 50%.
|
||||
bool get shouldHideSpoiler {
|
||||
if (!isEpisode) return false;
|
||||
if (isWatched) return false;
|
||||
if (viewOffset != null && viewOffset! > 0) return false;
|
||||
if (viewOffset != null && viewOffset! > 0 && duration != null && duration! > 0) {
|
||||
return viewOffset! / duration! < 0.5;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../services/settings_service.dart';
|
||||
import 'grid_size_calculator.dart';
|
||||
import 'layout_constants.dart';
|
||||
|
||||
/// Builds an adaptive Sliver widget that switches between grid and list
|
||||
/// based on the current view mode setting.
|
||||
///
|
||||
/// This helper consolidates the list vs grid Sliver builders to keep
|
||||
/// padding and density logic in sync across different screens.
|
||||
Widget buildAdaptiveMediaSliverBuilder<T>({
|
||||
required BuildContext context,
|
||||
required List<T> items,
|
||||
required Widget Function(BuildContext context, T item, int index) itemBuilder,
|
||||
required ViewMode viewMode,
|
||||
required LibraryDensity density,
|
||||
EdgeInsets? padding,
|
||||
double? childAspectRatio,
|
||||
double? crossAxisSpacing,
|
||||
double? mainAxisSpacing,
|
||||
}) {
|
||||
final effectivePadding = padding ?? GridLayoutConstants.gridPadding;
|
||||
final effectiveAspectRatio = childAspectRatio ?? GridLayoutConstants.posterAspectRatio;
|
||||
final effectiveCrossAxisSpacing = crossAxisSpacing ?? GridLayoutConstants.crossAxisSpacing;
|
||||
final effectiveMainAxisSpacing = mainAxisSpacing ?? GridLayoutConstants.mainAxisSpacing;
|
||||
|
||||
return viewMode == ViewMode.list
|
||||
? SliverPadding(
|
||||
padding: effectivePadding,
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final item = items[index];
|
||||
return itemBuilder(context, item, index);
|
||||
}, childCount: items.length),
|
||||
),
|
||||
)
|
||||
: SliverPadding(
|
||||
padding: effectivePadding,
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: GridSizeCalculator.getMaxCrossAxisExtent(context, density),
|
||||
childAspectRatio: effectiveAspectRatio,
|
||||
crossAxisSpacing: effectiveCrossAxisSpacing,
|
||||
mainAxisSpacing: effectiveMainAxisSpacing,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final item = items[index];
|
||||
return itemBuilder(context, item, index);
|
||||
}, childCount: items.length),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -4,8 +4,9 @@ class CollapsibleText extends StatefulWidget {
|
||||
final String text;
|
||||
final int maxLines;
|
||||
final TextStyle? style;
|
||||
final bool small;
|
||||
|
||||
const CollapsibleText({super.key, required this.text, this.maxLines = 4, this.style});
|
||||
const CollapsibleText({super.key, required this.text, this.maxLines = 4, this.style, this.small = false});
|
||||
|
||||
@override
|
||||
State<CollapsibleText> createState() => _CollapsibleTextState();
|
||||
@@ -47,7 +48,7 @@ class _CollapsibleTextState extends State<CollapsibleText> {
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(text: displayText, style: style),
|
||||
if (!_expanded) WidgetSpan(alignment: PlaceholderAlignment.middle, child: _buildBadge(context)),
|
||||
if (!_expanded) WidgetSpan(alignment: widget.small ? PlaceholderAlignment.baseline : PlaceholderAlignment.middle, baseline: widget.small ? TextBaseline.alphabetic : null, child: _buildBadge(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -57,20 +58,21 @@ class _CollapsibleTextState extends State<CollapsibleText> {
|
||||
}
|
||||
|
||||
Widget _buildBadge(BuildContext context) {
|
||||
final isSmall = widget.small;
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(left: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
padding: EdgeInsets.symmetric(horizontal: isSmall ? 6 : 8, vertical: isSmall ? 0 : 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.12),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(isSmall ? 8 : 10)),
|
||||
),
|
||||
child: Text(
|
||||
'\u00B7\u00B7\u00B7',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontSize: isSmall ? 10 : 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
letterSpacing: 2,
|
||||
letterSpacing: isSmall ? 1.5 : 2,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -80,25 +80,36 @@ class FocusableListTile extends StatefulWidget {
|
||||
|
||||
class _FocusableListTileState extends State<FocusableListTile> {
|
||||
bool _suppressionConsumed = false;
|
||||
bool _isHoveredOrFocused = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tile = ListTile(
|
||||
title: widget.title,
|
||||
subtitle: widget.subtitle,
|
||||
leading: widget.leading,
|
||||
trailing: widget.trailing,
|
||||
onTap: widget.onTap,
|
||||
onLongPress: widget.onLongPress,
|
||||
dense: widget.dense,
|
||||
enabled: widget.enabled,
|
||||
selected: widget.selected,
|
||||
contentPadding: widget.contentPadding,
|
||||
focusNode: widget.suppressInitialSelect ? null : widget.focusNode,
|
||||
autofocus: widget.suppressInitialSelect ? false : widget.autofocus,
|
||||
hoverColor: widget.hoverColor,
|
||||
textColor: widget.textColor,
|
||||
iconColor: widget.iconColor,
|
||||
// When hovered/focused with a custom hoverColor, use onError-style foreground
|
||||
// to keep text readable against the colored background.
|
||||
final needsContrastSwap = _isHoveredOrFocused && widget.hoverColor != null && widget.textColor != null;
|
||||
final textColor = needsContrastSwap ? Theme.of(context).colorScheme.onError : widget.textColor;
|
||||
final iconColor = needsContrastSwap ? Theme.of(context).colorScheme.onError : widget.iconColor;
|
||||
|
||||
Widget tile = MouseRegion(
|
||||
onEnter: widget.hoverColor != null ? (_) => setState(() => _isHoveredOrFocused = true) : null,
|
||||
onExit: widget.hoverColor != null ? (_) => setState(() => _isHoveredOrFocused = false) : null,
|
||||
child: ListTile(
|
||||
title: widget.title,
|
||||
subtitle: widget.subtitle,
|
||||
leading: widget.leading,
|
||||
trailing: widget.trailing,
|
||||
onTap: widget.onTap,
|
||||
onLongPress: widget.onLongPress,
|
||||
dense: widget.dense,
|
||||
enabled: widget.enabled,
|
||||
selected: widget.selected,
|
||||
contentPadding: widget.contentPadding,
|
||||
focusNode: widget.suppressInitialSelect ? null : widget.focusNode,
|
||||
autofocus: widget.suppressInitialSelect ? false : widget.autofocus,
|
||||
hoverColor: widget.hoverColor,
|
||||
textColor: textColor,
|
||||
iconColor: iconColor,
|
||||
),
|
||||
);
|
||||
|
||||
if (!widget.suppressInitialSelect) {
|
||||
|
||||
@@ -18,6 +18,7 @@ class FocusableMediaCard extends StatefulWidget {
|
||||
final VoidCallback? onRemoveFromContinueWatching;
|
||||
final VoidCallback? onListRefresh;
|
||||
final bool forceGridMode;
|
||||
final bool forceListMode;
|
||||
final bool isInContinueWatching;
|
||||
final String? collectionId;
|
||||
|
||||
@@ -27,6 +28,9 @@ class FocusableMediaCard extends StatefulWidget {
|
||||
/// True when in a hub with mixed content (movies + episodes)
|
||||
final bool mixedHubContext;
|
||||
|
||||
/// Show server name in list view (multi-server)
|
||||
final bool showServerName;
|
||||
|
||||
/// Optional external focus node for programmatic focus control.
|
||||
/// If not provided, an internal focus node is created.
|
||||
final FocusNode? focusNode;
|
||||
@@ -60,10 +64,12 @@ class FocusableMediaCard extends StatefulWidget {
|
||||
this.onRemoveFromContinueWatching,
|
||||
this.onListRefresh,
|
||||
this.forceGridMode = false,
|
||||
this.forceListMode = false,
|
||||
this.isInContinueWatching = false,
|
||||
this.collectionId,
|
||||
this.isOffline = false,
|
||||
this.mixedHubContext = false,
|
||||
this.showServerName = false,
|
||||
this.focusNode,
|
||||
this.onNavigateUp,
|
||||
this.onNavigateLeft,
|
||||
@@ -103,10 +109,12 @@ class _FocusableMediaCardState extends State<FocusableMediaCard> {
|
||||
onRemoveFromContinueWatching: widget.onRemoveFromContinueWatching,
|
||||
onListRefresh: widget.onListRefresh,
|
||||
forceGridMode: widget.forceGridMode,
|
||||
forceListMode: widget.forceListMode,
|
||||
isInContinueWatching: widget.isInContinueWatching,
|
||||
collectionId: widget.collectionId,
|
||||
isOffline: widget.isOffline,
|
||||
mixedHubContext: widget.mixedHubContext,
|
||||
showServerName: widget.showServerName,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,10 +29,12 @@ class MediaCard extends StatefulWidget {
|
||||
final VoidCallback? onRemoveFromContinueWatching;
|
||||
final VoidCallback? onListRefresh; // Callback to refresh the entire parent list
|
||||
final bool forceGridMode;
|
||||
final bool forceListMode;
|
||||
final bool isInContinueWatching;
|
||||
final String? collectionId; // The collection ID if displaying within a collection
|
||||
final bool isOffline; // True for downloaded content without server access
|
||||
final bool mixedHubContext; // True when in a hub with mixed content (movies + episodes)
|
||||
final bool showServerName; // Show server name in list view (multi-server)
|
||||
|
||||
const MediaCard({
|
||||
super.key,
|
||||
@@ -43,10 +45,12 @@ class MediaCard extends StatefulWidget {
|
||||
this.onRemoveFromContinueWatching,
|
||||
this.onListRefresh,
|
||||
this.forceGridMode = false,
|
||||
this.forceListMode = false,
|
||||
this.isInContinueWatching = false,
|
||||
this.collectionId,
|
||||
this.isOffline = false,
|
||||
this.mixedHubContext = false,
|
||||
this.showServerName = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -166,7 +170,11 @@ class MediaCardState extends State<MediaCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final settingsProvider = context.watch<SettingsProvider>();
|
||||
final viewMode = widget.forceGridMode ? ViewMode.grid : settingsProvider.viewMode;
|
||||
final viewMode = widget.forceListMode
|
||||
? ViewMode.list
|
||||
: widget.forceGridMode
|
||||
? ViewMode.grid
|
||||
: settingsProvider.viewMode;
|
||||
|
||||
final semanticLabel = _buildSemanticLabel();
|
||||
final localPosterPath = _getLocalPosterPath(context);
|
||||
@@ -184,6 +192,7 @@ class MediaCardState extends State<MediaCard> {
|
||||
density: settingsProvider.libraryDensity,
|
||||
isOffline: widget.isOffline,
|
||||
localPosterPath: localPosterPath,
|
||||
showServerName: widget.showServerName,
|
||||
);
|
||||
|
||||
// MediaContextMenu as a non-widget helper — only wrap with its key for
|
||||
@@ -299,6 +308,7 @@ class _MediaCardList extends StatelessWidget {
|
||||
final LibraryDensity density;
|
||||
final bool isOffline;
|
||||
final String? localPosterPath;
|
||||
final bool showServerName;
|
||||
|
||||
const _MediaCardList({
|
||||
required this.item,
|
||||
@@ -311,6 +321,7 @@ class _MediaCardList extends StatelessWidget {
|
||||
required this.density,
|
||||
this.isOffline = false,
|
||||
this.localPosterPath,
|
||||
this.showServerName = false,
|
||||
});
|
||||
|
||||
double _basePosterWidth() {
|
||||
@@ -560,7 +571,10 @@ class _MediaCardList extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
// Summary (hidden when spoiler protection is active)
|
||||
if (!(item is PlexMetadata && context.watch<SettingsProvider>().hideSpoilers && (item as PlexMetadata).shouldHideSpoiler) && item.summary != null) ...[
|
||||
if (!(item is PlexMetadata &&
|
||||
context.watch<SettingsProvider>().hideSpoilers &&
|
||||
(item as PlexMetadata).shouldHideSpoiler) &&
|
||||
item.summary != null) ...[
|
||||
Text(
|
||||
item.summary!,
|
||||
maxLines: _summaryMaxLines,
|
||||
@@ -572,6 +586,32 @@ class _MediaCardList extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
],
|
||||
// Server name (multi-server mode)
|
||||
if (showServerName && item is PlexMetadata && (item as PlexMetadata).serverName != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
AppIcon(
|
||||
Symbols.dns_rounded,
|
||||
fill: 1,
|
||||
size: _metadataFontSize + 2,
|
||||
color: tokens(context).textMuted.withValues(alpha: 0.6),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
(item as PlexMetadata).serverName!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: tokens(context).textMuted.withValues(alpha: 0.6),
|
||||
fontSize: _metadataFontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -609,7 +649,10 @@ Widget _buildPosterImage(
|
||||
} else if (item is PlexMetadata) {
|
||||
final settingsProvider = context.watch<SettingsProvider>();
|
||||
final episodePosterMode = settingsProvider.episodePosterMode;
|
||||
final shouldBlur = settingsProvider.hideSpoilers && item.shouldHideSpoiler;
|
||||
final shouldBlur =
|
||||
settingsProvider.hideSpoilers &&
|
||||
item.shouldHideSpoiler &&
|
||||
episodePosterMode == EpisodePosterMode.episodeThumbnail;
|
||||
posterUrl = item.posterThumb(mode: episodePosterMode, mixedHubContext: mixedHubContext);
|
||||
|
||||
Widget image;
|
||||
@@ -637,10 +680,7 @@ Widget _buildPosterImage(
|
||||
|
||||
if (shouldBlur) {
|
||||
return ClipRect(
|
||||
child: ImageFiltered(
|
||||
imageFilter: ImageFilter.blur(sigmaX: 12, sigmaY: 12),
|
||||
child: image,
|
||||
),
|
||||
child: ImageFiltered(imageFilter: ImageFilter.blur(sigmaX: 12, sigmaY: 12), child: image),
|
||||
);
|
||||
}
|
||||
return image;
|
||||
|
||||
@@ -1381,74 +1381,89 @@ class _FocusablePopupMenuState extends State<_FocusablePopupMenu> {
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
const menuWidth = 220.0;
|
||||
|
||||
// Calculate menu position, keeping it on screen
|
||||
double left = widget.position.dx;
|
||||
double top = widget.position.dy;
|
||||
// Clamp menu position to stay within screen bounds
|
||||
const edgePadding = 8.0;
|
||||
final left = widget.position.dx.clamp(edgePadding, screenSize.width - menuWidth - edgePadding);
|
||||
|
||||
// Adjust if menu would go off right edge
|
||||
if (left + menuWidth > screenSize.width) {
|
||||
left = screenSize.width - menuWidth - 8;
|
||||
}
|
||||
|
||||
// Estimate menu height and adjust if would go off bottom
|
||||
final estimatedHeight = widget.actions.length * 48.0 + 16;
|
||||
if (top + estimatedHeight > screenSize.height) {
|
||||
top = screenSize.height - estimatedHeight - 8;
|
||||
final spaceBelow = screenSize.height - widget.position.dy - edgePadding;
|
||||
final spaceAbove = widget.position.dy - edgePadding;
|
||||
|
||||
// Place menu above the click point if it doesn't fit below and there's more room above
|
||||
final double top;
|
||||
final double maxHeight;
|
||||
if (estimatedHeight <= spaceBelow) {
|
||||
top = widget.position.dy;
|
||||
maxHeight = spaceBelow;
|
||||
} else if (spaceAbove > spaceBelow) {
|
||||
final menuHeight = estimatedHeight.clamp(0.0, spaceAbove);
|
||||
top = widget.position.dy - menuHeight;
|
||||
maxHeight = menuHeight;
|
||||
} else {
|
||||
top = widget.position.dy;
|
||||
maxHeight = spaceBelow;
|
||||
}
|
||||
|
||||
return Focus(
|
||||
canRequestFocus: false,
|
||||
skipTraversal: true,
|
||||
onKeyEvent: (node, event) {
|
||||
if (SelectKeyUpSuppressor.consumeIfSuppressed(event)) {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (BackKeyUpSuppressor.consumeIfSuppressed(event)) {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
// Barrier to close menu when clicking outside
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(color: Colors.transparent),
|
||||
return FocusScope(
|
||||
// When opened via mouse, don't autofocus any item — let hover handle highlights.
|
||||
// When opened via keyboard/dpad, autofocus is handled by _initialFocusNode.
|
||||
autofocus: false,
|
||||
child: Focus(
|
||||
canRequestFocus: false,
|
||||
skipTraversal: true,
|
||||
onKeyEvent: (node, event) {
|
||||
if (SelectKeyUpSuppressor.consumeIfSuppressed(event)) {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (BackKeyUpSuppressor.consumeIfSuppressed(event)) {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
// Barrier to close menu when clicking outside
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Container(color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Menu
|
||||
Positioned(
|
||||
left: left,
|
||||
top: top,
|
||||
child: Material(
|
||||
elevation: 8,
|
||||
borderRadius: BorderRadius.circular(tokens(context).radiusSm),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: menuWidth, maxWidth: menuWidth),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: widget.actions.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final action = entry.value;
|
||||
return FocusableListTile(
|
||||
focusNode: index == 0 ? _initialFocusNode : null,
|
||||
leading: AppIcon(action.icon, fill: 1, size: 20),
|
||||
title: Text(action.label),
|
||||
onTap: () => Navigator.pop(context, action.value),
|
||||
hoverColor: action.hoverColor,
|
||||
textColor: action.foregroundColor,
|
||||
iconColor: action.foregroundColor,
|
||||
);
|
||||
}).toList(),
|
||||
// Menu
|
||||
Positioned(
|
||||
left: left,
|
||||
top: top,
|
||||
child: Material(
|
||||
elevation: 8,
|
||||
borderRadius: BorderRadius.circular(tokens(context).radiusSm),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minWidth: menuWidth, maxWidth: menuWidth, maxHeight: maxHeight),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: widget.actions.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final action = entry.value;
|
||||
return FocusableListTile(
|
||||
focusNode: index == 0 && widget.focusFirstItem ? _initialFocusNode : null,
|
||||
leading: AppIcon(action.icon, fill: 1, size: 20),
|
||||
title: Text(action.label),
|
||||
onTap: () => Navigator.pop(context, action.value),
|
||||
hoverColor: action.hoverColor,
|
||||
textColor: action.foregroundColor,
|
||||
iconColor: action.foregroundColor,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
bool _showPerformanceOverlay = false;
|
||||
bool _autoPlayNextEpisode = true;
|
||||
bool _audioPassthrough = false;
|
||||
bool _audioNormalization = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -146,6 +147,7 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
_showPerformanceOverlay = settings.getShowPerformanceOverlay();
|
||||
_autoPlayNextEpisode = settings.getAutoPlayNextEpisode();
|
||||
_audioPassthrough = settings.getAudioPassthrough();
|
||||
_audioNormalization = settings.getAudioNormalization();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,6 +194,17 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
await widget.player.setAudioPassthrough(newValue);
|
||||
}
|
||||
|
||||
Future<void> _toggleAudioNormalization() async {
|
||||
final newValue = !_audioNormalization;
|
||||
final settings = await SettingsService.getInstance();
|
||||
await settings.setAudioNormalization(newValue);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_audioNormalization = newValue;
|
||||
});
|
||||
await widget.player.setProperty('af', newValue ? 'loudnorm=I=-14:TP=-3:LRA=4' : '');
|
||||
}
|
||||
|
||||
void _navigateTo(_SettingsView view) {
|
||||
// Sync views open as a compact top bar instead of a sub-view
|
||||
if (view == _SettingsView.audioSync || view == _SettingsView.subtitleSync) {
|
||||
@@ -427,6 +440,23 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
onTap: _toggleAudioPassthrough,
|
||||
),
|
||||
|
||||
// Audio Normalization (MPV only)
|
||||
if (widget.player.playerType == 'mpv')
|
||||
ListTile(
|
||||
leading: AppIcon(
|
||||
Symbols.graphic_eq_rounded,
|
||||
fill: 1,
|
||||
color: _audioNormalization ? Colors.amber : tokens(context).textMuted,
|
||||
),
|
||||
title: Text(t.videoSettings.audioNormalization),
|
||||
trailing: Switch(
|
||||
value: _audioNormalization,
|
||||
onChanged: (_) => _toggleAudioNormalization(),
|
||||
activeThumbColor: Colors.amber,
|
||||
),
|
||||
onTap: _toggleAudioNormalization,
|
||||
),
|
||||
|
||||
// Shader Preset (MPV only)
|
||||
if (widget.shaderService != null && widget.shaderService!.isSupported)
|
||||
_SettingsMenuItem(
|
||||
|
||||
+60
-42
@@ -1,5 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io' show ProcessInfo;
|
||||
import 'dart:io' show Platform, ProcessInfo;
|
||||
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
@@ -214,7 +214,7 @@ class PerformanceStatsService {
|
||||
|
||||
/// Fetch stats from MPV via property queries.
|
||||
Future<void> _fetchMpvStats() async {
|
||||
// Fetch all properties in parallel for efficiency
|
||||
// Fetch core properties in parallel
|
||||
final results = await Future.wait([
|
||||
player.getProperty('video-codec'), // 0
|
||||
player.getProperty('video-params/w'), // 1
|
||||
@@ -228,28 +228,49 @@ class PerformanceStatsService {
|
||||
player.getProperty('audio-params/hr-channels'), // 9
|
||||
player.getProperty('audio-bitrate'), // 10
|
||||
player.getProperty('total-avsync-change'), // 11
|
||||
player.getProperty('cache-used'), // 12
|
||||
player.getProperty('cache-speed'), // 13
|
||||
player.getProperty('display-fps'), // 14
|
||||
player.getProperty('frame-drop-count'), // 15
|
||||
player.getProperty('decoder-frame-drop-count'), // 16
|
||||
player.getProperty('demuxer-cache-duration'), // 17
|
||||
// Color/Format properties
|
||||
player.getProperty('video-params/pixelformat'), // 18
|
||||
player.getProperty('video-params/hw-pixelformat'), // 19
|
||||
player.getProperty('video-params/colormatrix'), // 20
|
||||
player.getProperty('video-params/primaries'), // 21
|
||||
player.getProperty('video-params/gamma'), // 22
|
||||
// HDR metadata
|
||||
player.getProperty('video-params/max-luma'), // 23
|
||||
player.getProperty('video-params/min-luma'), // 24
|
||||
player.getProperty('video-params/max-cll'), // 25
|
||||
player.getProperty('video-params/max-fall'), // 26
|
||||
// Other
|
||||
player.getProperty('video-params/aspect-name'), // 27
|
||||
player.getProperty('video-params/rotate'), // 28
|
||||
player.getProperty('cache-speed'), // 12
|
||||
player.getProperty('frame-drop-count'), // 13
|
||||
player.getProperty('decoder-frame-drop-count'), // 14
|
||||
player.getProperty('demuxer-cache-duration'), // 15
|
||||
]);
|
||||
|
||||
final hasVideo = results[1] != null;
|
||||
|
||||
// Only query video-dependent properties when a video track is active.
|
||||
// On Android, skip properties that are typically unavailable (display-fps,
|
||||
// hw-pixelformat, HDR metadata) — MPV's native layer logs errors for these
|
||||
// that we cannot suppress.
|
||||
List<String?>? videoResults;
|
||||
if (hasVideo) {
|
||||
final isAndroid = Platform.isAndroid;
|
||||
videoResults = await Future.wait([
|
||||
isAndroid
|
||||
? Future.value(null)
|
||||
: player.getProperty('display-fps'), // 0
|
||||
player.getProperty('video-params/pixelformat'), // 1
|
||||
isAndroid
|
||||
? Future.value(null)
|
||||
: player.getProperty('video-params/hw-pixelformat'), // 2
|
||||
player.getProperty('video-params/colormatrix'), // 3
|
||||
player.getProperty('video-params/primaries'), // 4
|
||||
player.getProperty('video-params/gamma'), // 5
|
||||
isAndroid
|
||||
? Future.value(null)
|
||||
: player.getProperty('video-params/max-luma'), // 6
|
||||
isAndroid
|
||||
? Future.value(null)
|
||||
: player.getProperty('video-params/min-luma'), // 7
|
||||
isAndroid
|
||||
? Future.value(null)
|
||||
: player.getProperty('video-params/max-cll'), // 8
|
||||
isAndroid
|
||||
? Future.value(null)
|
||||
: player.getProperty('video-params/max-fall'), // 9
|
||||
player.getProperty('video-params/aspect-name'), // 10
|
||||
player.getProperty('video-params/rotate'), // 11
|
||||
]);
|
||||
}
|
||||
|
||||
// Get app memory usage
|
||||
int? appMemory;
|
||||
try {
|
||||
@@ -272,26 +293,23 @@ class PerformanceStatsService {
|
||||
audioChannels: results[9],
|
||||
audioBitrate: _parseInt(results[10]),
|
||||
avsyncChange: _parseDouble(results[11]),
|
||||
cacheUsed: _parseInt(results[12]),
|
||||
cacheSpeed: _parseDouble(results[13]),
|
||||
displayFps: _parseDouble(results[14]),
|
||||
frameDropCount: _parseInt(results[15]),
|
||||
decoderFrameDropCount: _parseInt(results[16]),
|
||||
cacheDuration: _parseDouble(results[17]),
|
||||
// Color/Format properties
|
||||
pixelformat: results[18],
|
||||
hwPixelformat: results[19],
|
||||
colormatrix: results[20],
|
||||
primaries: results[21],
|
||||
gamma: results[22],
|
||||
// HDR metadata
|
||||
maxLuma: _parseDouble(results[23]),
|
||||
minLuma: _parseDouble(results[24]),
|
||||
maxCll: _parseDouble(results[25]),
|
||||
maxFall: _parseDouble(results[26]),
|
||||
// Other
|
||||
aspectName: results[27],
|
||||
rotate: _parseInt(results[28]),
|
||||
cacheSpeed: _parseDouble(results[12]),
|
||||
frameDropCount: _parseInt(results[13]),
|
||||
decoderFrameDropCount: _parseInt(results[14]),
|
||||
cacheDuration: _parseDouble(results[15]),
|
||||
// Video-dependent properties
|
||||
displayFps: _parseDouble(videoResults?[0]),
|
||||
pixelformat: videoResults?[1],
|
||||
hwPixelformat: videoResults?[2],
|
||||
colormatrix: videoResults?[3],
|
||||
primaries: videoResults?[4],
|
||||
gamma: videoResults?[5],
|
||||
maxLuma: _parseDouble(videoResults?[6]),
|
||||
minLuma: _parseDouble(videoResults?[7]),
|
||||
maxCll: _parseDouble(videoResults?[8]),
|
||||
maxFall: _parseDouble(videoResults?[9]),
|
||||
aspectName: videoResults?[10],
|
||||
rotate: _parseInt(videoResults?[11]),
|
||||
appMemoryBytes: appMemory,
|
||||
uiFps: _currentUiFps,
|
||||
);
|
||||
|
||||
@@ -79,7 +79,7 @@ class _TimelineSliderState extends State<TimelineSlider> {
|
||||
// For now we will check half a second, but this can probably be made higher.
|
||||
if (widget.thumbnailDataBuilder != null && _dragValue == null) {
|
||||
final delta = (widget.position.inMilliseconds - oldWidget.position.inMilliseconds).abs();
|
||||
if (delta > 500) {
|
||||
if (delta > 500 && widget.focusNode?.hasFocus == true) {
|
||||
_showKeySeekThumbnail = true;
|
||||
_resetKeySeekTimer();
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: plezy
|
||||
description: "A beautiful Plex client for Flutter"
|
||||
publish_to: "none"
|
||||
version: 1.22.0+49
|
||||
version: 1.23.0+50
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
|
||||
@@ -156,6 +156,20 @@ function IsX64: Boolean;
|
||||
begin
|
||||
Result := not IsArm64;
|
||||
end;
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
var
|
||||
MarkerPath: String;
|
||||
begin
|
||||
if CurStep = ssPostInstall then
|
||||
begin
|
||||
MarkerPath := ExpandConstant('{app}\.winget');
|
||||
if ExpandConstant('{param:WINGET|0}') = '1' then
|
||||
SaveStringToFile(MarkerPath, '', False)
|
||||
else
|
||||
DeleteFile(MarkerPath);
|
||||
end;
|
||||
end;
|
||||
"@
|
||||
} else {
|
||||
# Single-arch installer (backward compatible, no Check: functions needed)
|
||||
@@ -206,6 +220,21 @@ Name: "{autodesktop}\{#Name}"; Filename: "{app}\{#ExeName}"; Tasks: desktopicon
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#ExeName}"; Description: "{cm:LaunchProgram,{#Name}}"; Flags: nowait postinstall
|
||||
|
||||
[Code]
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
var
|
||||
MarkerPath: String;
|
||||
begin
|
||||
if CurStep = ssPostInstall then
|
||||
begin
|
||||
MarkerPath := ExpandConstant('{app}\.winget');
|
||||
if ExpandConstant('{param:WINGET|0}') = '1' then
|
||||
SaveStringToFile(MarkerPath, '', False)
|
||||
else
|
||||
DeleteFile(MarkerPath);
|
||||
end;
|
||||
end;
|
||||
"@
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user