Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cc8b4c0d9 | ||
|
|
7a4cdc8b5e | ||
|
|
20896a3d48 | ||
|
|
fc96ddc1ab | ||
|
|
4522f42bbf | ||
|
|
a4b88df965 | ||
|
|
810ef002ad | ||
|
|
cb900c255a | ||
|
|
43ab083cda | ||
|
|
3fb90a4948 | ||
|
|
65713858ea | ||
|
|
744e72d76b | ||
|
|
761303de11 | ||
|
|
4a1111f435 | ||
|
|
4b6533d25b | ||
|
|
05ef93c55b | ||
|
|
8d2eca42d4 | ||
|
|
0f3d06668f | ||
|
|
7131be4cc0 | ||
|
|
436fd7d2d5 | ||
|
|
c198bab04c | ||
|
|
2a6f752860 | ||
|
|
16c0e00302 |
@@ -1,8 +1,13 @@
|
||||
name: Build
|
||||
run-name: ${{ inputs.release_tag != '' && format('Release {0}', inputs.release_tag) || format('Build {0}', github.sha) }}
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_tag:
|
||||
description: Tag for a draft release; omit to build Actions artifacts only
|
||||
default: ''
|
||||
type: string
|
||||
build_android:
|
||||
description: Build Android
|
||||
default: true
|
||||
@@ -860,7 +865,7 @@ jobs:
|
||||
|
||||
create-release:
|
||||
needs: [validate-trusted-ref, build-android, build-ios, build-macos, build-windows, package-windows, build-linux]
|
||||
if: ${{ always() && needs.validate-trusted-ref.result == 'success' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && inputs.build_android && inputs.build_ios && inputs.build_macos && inputs.build_windows && inputs.build_linux }}
|
||||
if: ${{ always() && needs.validate-trusted-ref.result == 'success' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && inputs.build_android && inputs.build_ios && inputs.build_macos && inputs.build_windows && inputs.build_linux && inputs.release_tag != '' }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -879,6 +884,21 @@ jobs:
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Validate release tag
|
||||
if: ${{ inputs.release_tag != '' }}
|
||||
env:
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
if [[ ! "$RELEASE_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Release tag must use semantic versioning: $RELEASE_TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$RELEASE_TAG" != "$VERSION" ]]; then
|
||||
echo "Release tag $RELEASE_TAG does not match pubspec version $VERSION." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Download Android artifacts
|
||||
if: ${{ inputs.build_android }}
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
||||
@@ -1043,5 +1063,8 @@ jobs:
|
||||
files: ${{ steps.release-files.outputs.files }}
|
||||
draft: true
|
||||
prerelease: false
|
||||
name: ${{ inputs.release_tag }}
|
||||
tag_name: ${{ inputs.release_tag }}
|
||||
target_commitish: ${{ github.sha }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
cask "plezy" do
|
||||
version "2.14.0"
|
||||
sha256 "35fcbc5bcad13691fda335f662af0e9e5ffd0d9d202ecae17705a25cda2f58a6"
|
||||
version "2.15.0"
|
||||
sha256 "ad1ada9278d42d706f9e17f0a1fc7a3d8b02ef25536c71674848699955bce9d6"
|
||||
|
||||
url "https://github.com/edde746/plezy/releases/download/#{version}/plezy-macos.dmg"
|
||||
name "Plezy"
|
||||
|
||||
@@ -1312,8 +1312,10 @@ class ExoPlayerPlugin :
|
||||
val observedProps = observedProperties.toList()
|
||||
val bufferSize = configuredBufferSizeBytes
|
||||
|
||||
// vo is owned by MpvPlayerCore's init: the fallback core hardware-decodes
|
||||
// (hwdec below), so it gets the legacy gpu VO — gpu-next under mediacodec
|
||||
// fails every frame on Tegra (#2010) and reshapes no DV anyway.
|
||||
core.setProperty("hwdec", "mediacodec,mediacodec-copy")
|
||||
core.setProperty("vo", "gpu-next,gpu")
|
||||
core.setProperty("ao", "audiotrack")
|
||||
|
||||
if (bufferSize != null && bufferSize > 0) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.edde746.plezy.exoplayer
|
||||
|
||||
import android.util.Log
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.common.DataReader
|
||||
import androidx.media3.extractor.DefaultExtractorInput
|
||||
import androidx.media3.extractor.ExtractorInput
|
||||
import androidx.media3.extractor.ExtractorOutput
|
||||
import androidx.media3.extractor.SeekMap
|
||||
@@ -8,6 +11,9 @@ import androidx.media3.extractor.TrackOutput
|
||||
import androidx.media3.extractor.text.SubtitleParser
|
||||
import com.edde746.plezy.libass.media.AssHandler
|
||||
import com.edde746.plezy.libass.media.extractor.AssMatroskaExtractor
|
||||
import java.io.EOFException
|
||||
import java.util.zip.DataFormatException
|
||||
import java.util.zip.Inflater
|
||||
|
||||
/**
|
||||
* Extends AssMatroskaExtractor to add support for MKV quirks media3 rejects:
|
||||
@@ -16,8 +22,19 @@ import com.edde746.plezy.libass.media.extractor.AssMatroskaExtractor
|
||||
* stripping). This subclass intercepts the compression algorithm during track
|
||||
* header parsing:
|
||||
* - Tells the parent it's header stripping (algo 3) to avoid the ParserException
|
||||
* - Wraps TrackOutputs with ZlibInflatingTrackOutput to decompress per-sample data
|
||||
* - Skips ContentCompSettings for zlib tracks (not applicable)
|
||||
* - For text subtitle tracks, inflates the block payload *before* the parent
|
||||
* parses it (see below). For every other zlib track, wraps TrackOutputs with
|
||||
* ZlibInflatingTrackOutput to decompress per-sample data.
|
||||
*
|
||||
* Text subtitle tracks (SRT/ASS/SSA/VTT) cannot be inflated at the TrackOutput
|
||||
* level: MatroskaExtractor rewrites their samples in-place before any TrackOutput
|
||||
* runs — it prepends a plaintext timecode prefix ("Dialogue: 0:00:00:00,…,") to
|
||||
* the still-compressed payload and truncates the sample at the first NUL byte,
|
||||
* which deflate streams routinely contain (#2023). AssTrackOutput additionally
|
||||
* feeds that same internal buffer straight to libass. So for zlib text tracks the
|
||||
* frame payload is inflated at the block level, before the parent's sample
|
||||
* assembly, and the TrackOutput wrapper is left inactive.
|
||||
*
|
||||
* LOAS/LATM AAC as A_MS/ACM — media3 sets audio/x-unknown for non-PCM ACM
|
||||
* tracks (silent playback). Detected tracks are wrapped with LatmTrackOutput,
|
||||
@@ -36,15 +53,43 @@ class ZlibMatroskaExtractor(
|
||||
private const val ID_TRACK_ENTRY = 0xAE
|
||||
private const val ID_CONTENT_COMPRESSION_ALGORITHM = 0x4254
|
||||
private const val ID_CONTENT_COMPRESSION_SETTINGS = 0x4255
|
||||
private const val ID_CONTENT_COMPRESSION = 0x5034
|
||||
private const val ID_SIMPLE_BLOCK = 0xA3
|
||||
private const val ID_BLOCK = 0xA1
|
||||
|
||||
/**
|
||||
* Codec IDs whose samples MatroskaExtractor rewrites in-place (timecode prefix
|
||||
* plus NUL truncation) before any TrackOutput runs — the authority is the
|
||||
* prefix list in MatroskaExtractor.writeSampleData.
|
||||
*/
|
||||
private val TEXT_SUBTITLE_CODEC_IDS = setOf("S_TEXT/UTF8", "S_TEXT/ASS", "S_TEXT/SSA", "S_TEXT/WEBVTT")
|
||||
|
||||
/** Subtitle blocks are tiny; anything above this passes through untouched. */
|
||||
private const val MAX_TEXT_BLOCK_BYTES = 16 * 1024 * 1024
|
||||
}
|
||||
|
||||
private var zlibOutput: ZlibExtractorOutputWrapper? = null
|
||||
private var latmOutput: LatmExtractorOutputWrapper? = null
|
||||
private var currentTrackUsesZlib = false
|
||||
|
||||
/** Track numbers whose blocks are inflated before the parent parses them. */
|
||||
private val zlibTextTrackNumbers = mutableSetOf<Int>()
|
||||
private val blockInflater = Inflater()
|
||||
private var blockBuf = ByteArray(0)
|
||||
private val peekBuf = ByteArray(8)
|
||||
|
||||
override fun startMasterElement(id: Int, contentPosition: Long, contentSize: Long) {
|
||||
super.startMasterElement(id, contentPosition, contentSize)
|
||||
|
||||
// ContentCompAlgo DEFAULTS to 0 (zlib), so mkvmerge omits the element for
|
||||
// zlib tracks entirely — the mere presence of ContentCompression means zlib
|
||||
// until an explicit ContentCompAlgo says otherwise. media3 ignores an empty
|
||||
// ContentCompression and would silently emit compressed samples.
|
||||
if (id == ID_CONTENT_COMPRESSION) {
|
||||
currentTrackUsesZlib = true
|
||||
Log.i(TAG, "Track has ContentCompression, assuming ContentCompAlgo 0 (zlib) until told otherwise")
|
||||
}
|
||||
|
||||
// After super installs AssSubtitleExtractorOutput, wrap it with our zlib +
|
||||
// LATM layers (zlib outermost so inflation runs before LATM parsing).
|
||||
if (id == ID_SEGMENT && zlibOutput == null) {
|
||||
@@ -59,12 +104,17 @@ class ZlibMatroskaExtractor(
|
||||
}
|
||||
|
||||
override fun integerElement(id: Int, value: Long) {
|
||||
if (id == ID_CONTENT_COMPRESSION_ALGORITHM && value == 0L) {
|
||||
currentTrackUsesZlib = true
|
||||
Log.i(TAG, "Track uses ContentCompAlgo 0 (zlib), will inflate samples")
|
||||
// Tell parent it's header stripping (algo 3) to avoid ParserException
|
||||
super.integerElement(id, 3)
|
||||
return
|
||||
if (id == ID_CONTENT_COMPRESSION_ALGORITHM) {
|
||||
if (value == 0L) {
|
||||
currentTrackUsesZlib = true
|
||||
Log.i(TAG, "Track uses explicit ContentCompAlgo 0 (zlib), will inflate samples")
|
||||
// Tell parent it's header stripping (algo 3) to avoid ParserException
|
||||
super.integerElement(id, 3)
|
||||
return
|
||||
}
|
||||
// Explicit non-zlib algorithm: header stripping (3) is handled by the
|
||||
// parent; anything else makes the parent throw, matching stock behavior.
|
||||
currentTrackUsesZlib = false
|
||||
}
|
||||
super.integerElement(id, value)
|
||||
}
|
||||
@@ -76,27 +126,47 @@ class ZlibMatroskaExtractor(
|
||||
input.skipFully(contentSize)
|
||||
return
|
||||
}
|
||||
if ((id == ID_SIMPLE_BLOCK || id == ID_BLOCK) &&
|
||||
zlibTextTrackNumbers.isNotEmpty() &&
|
||||
contentSize in MIN_BLOCK_BYTES..MAX_TEXT_BLOCK_BYTES &&
|
||||
peekBlockTrackNumber(input) in zlibTextTrackNumbers
|
||||
) {
|
||||
inflateTextBlock(id, contentSize, input)
|
||||
return
|
||||
}
|
||||
super.binaryElement(id, contentSize, input)
|
||||
}
|
||||
|
||||
override fun endMasterElement(id: Int) {
|
||||
var zlibTextTrackNumber: Int? = null
|
||||
if (id == ID_TRACK_ENTRY) {
|
||||
// Must mark before super — the track output is created inside super's
|
||||
// endMasterElement, and the x-unknown format must never reach the queue.
|
||||
// Must inspect before super — the track output is created inside super's
|
||||
// endMasterElement, and the current track is cleared afterwards.
|
||||
val track = getCurrentTrack(id)
|
||||
if (isLoasAcmTrack(track.codecId, track.codecPrivate)) {
|
||||
Log.i(TAG, "Track ${track.number} is LOAS/LATM AAC, unwrapping to raw AAC")
|
||||
latmOutput?.markNextTrackLatm()
|
||||
}
|
||||
if (currentTrackUsesZlib && track.codecId in TEXT_SUBTITLE_CODEC_IDS) {
|
||||
zlibTextTrackNumber = track.number
|
||||
}
|
||||
}
|
||||
|
||||
val wasZlib = currentTrackUsesZlib
|
||||
super.endMasterElement(id)
|
||||
|
||||
if (id == ID_TRACK_ENTRY && wasZlib) {
|
||||
zlibOutput?.activateLast()
|
||||
currentTrackUsesZlib = false
|
||||
Log.i(TAG, "Activated zlib inflation for track")
|
||||
if (zlibTextTrackNumber != null) {
|
||||
// Text subtitle samples are rewritten inside the parent before any
|
||||
// TrackOutput runs, so the TrackOutput wrapper stays inactive and the
|
||||
// block payload is inflated in binaryElement instead.
|
||||
zlibTextTrackNumbers.add(zlibTextTrackNumber)
|
||||
Log.i(TAG, "Track $zlibTextTrackNumber is a zlib text subtitle track, inflating at block level")
|
||||
} else {
|
||||
zlibOutput?.activateLast()
|
||||
Log.i(TAG, "Activated zlib inflation for track")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +176,64 @@ class ZlibMatroskaExtractor(
|
||||
super.seek(position, timeUs)
|
||||
}
|
||||
|
||||
/**
|
||||
* Peeks the EBML varint at the block start — the block's track number — without
|
||||
* consuming input. Returns null for malformed varints or truncated input; the
|
||||
* parent then produces the canonical failure for the untouched stream.
|
||||
*/
|
||||
private fun peekBlockTrackNumber(input: ExtractorInput): Int? {
|
||||
try {
|
||||
input.peekFully(peekBuf, 0, 1)
|
||||
val first = peekBuf[0].toInt() and 0xFF
|
||||
if (first == 0) return null
|
||||
val length = Integer.numberOfLeadingZeros(first) - 23
|
||||
var value = (first and (0xFF ushr length)).toLong()
|
||||
if (length > 1) {
|
||||
input.peekFully(peekBuf, 1, length - 1)
|
||||
for (i in 1 until length) {
|
||||
value = (value shl 8) or (peekBuf[i].toLong() and 0xFF)
|
||||
}
|
||||
}
|
||||
return if (value <= Int.MAX_VALUE) value.toInt() else null
|
||||
} catch (_: EOFException) {
|
||||
return null
|
||||
} finally {
|
||||
input.resetPeekPosition()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Buffers one text-subtitle block, inflates its frame payload, and hands the
|
||||
* parent a block whose payload is plaintext. A block that cannot be rewritten
|
||||
* (laced, corrupt, or over-bound) passes through byte-identical.
|
||||
*/
|
||||
private fun inflateTextBlock(id: Int, contentSize: Int, input: ExtractorInput) {
|
||||
val basePosition = input.position
|
||||
if (blockBuf.size < contentSize) blockBuf = ByteArray(maxOf(contentSize, blockBuf.size * 2))
|
||||
input.readFully(blockBuf, 0, contentSize)
|
||||
val rewritten = rewriteZlibTextBlock(blockBuf, contentSize, blockInflater)
|
||||
if (rewritten == null) {
|
||||
Log.w(TAG, "Passing zlib text block through uninflated (laced, corrupt, or over-bound)")
|
||||
super.binaryElement(id, contentSize, bufferedInput(blockBuf, contentSize, basePosition))
|
||||
} else {
|
||||
super.binaryElement(id, rewritten.size, bufferedInput(rewritten, rewritten.size, basePosition))
|
||||
}
|
||||
}
|
||||
|
||||
private fun bufferedInput(data: ByteArray, limit: Int, position: Long): ExtractorInput = DefaultExtractorInput(ByteRangeDataReader(data, limit), position, position + limit)
|
||||
|
||||
private class ByteRangeDataReader(private val data: ByteArray, private val limit: Int) : DataReader {
|
||||
private var position = 0
|
||||
|
||||
override fun read(buffer: ByteArray, offset: Int, length: Int): Int {
|
||||
if (position == limit) return C.RESULT_END_OF_INPUT
|
||||
val count = minOf(length, limit - position)
|
||||
System.arraycopy(data, position, buffer, offset, count)
|
||||
position += count
|
||||
return count
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ExtractorOutput wrapper that wraps all TrackOutputs with ZlibInflatingTrackOutput.
|
||||
* Tracks are created inactive; activateLast() enables inflation for the most recently
|
||||
@@ -138,3 +266,50 @@ class ZlibMatroskaExtractor(
|
||||
override fun seekMap(seekMap: SeekMap) = delegate.seekMap(seekMap)
|
||||
}
|
||||
}
|
||||
|
||||
/** Smallest well-formed unlaced block: 1-byte varint + 2-byte timecode + flags + 1 payload byte. */
|
||||
internal const val MIN_BLOCK_BYTES = 5
|
||||
|
||||
/**
|
||||
* Rewrites one unlaced Matroska block whose frame payload is zlib-compressed:
|
||||
* returns the unchanged block header followed by the inflated payload, or null
|
||||
* when the block must pass through unchanged — lacing (never produced for text
|
||||
* subtitle tracks), a truncated or corrupt deflate stream, or an inflated size
|
||||
* beyond the bounds shared with [ZlibInflatingTrackOutput]'s hardening.
|
||||
*/
|
||||
internal fun rewriteZlibTextBlock(data: ByteArray, limit: Int, inflater: Inflater): ByteArray? {
|
||||
if (limit < MIN_BLOCK_BYTES) return null
|
||||
val first = data[0].toInt() and 0xFF
|
||||
if (first == 0) return null // track-number varint longer than 8 bytes
|
||||
val varintLength = Integer.numberOfLeadingZeros(first) - 23
|
||||
val headerLength = varintLength + 3 // varint + 2-byte timecode + flags
|
||||
if (limit <= headerLength) return null
|
||||
if (data[headerLength - 1].toInt() and 0x06 != 0) return null // laced
|
||||
|
||||
val payloadLength = limit - headerLength
|
||||
val ratioBound = maxOf(1024L * 1024, payloadLength.toLong() * 1024)
|
||||
val maxInflatedBytes = 16 * 1024 * 1024
|
||||
inflater.reset()
|
||||
inflater.setInput(data, headerLength, payloadLength)
|
||||
var buf = ByteArray(maxOf(4096, payloadLength * 4))
|
||||
var written = 0
|
||||
try {
|
||||
while (true) {
|
||||
if (written == buf.size) {
|
||||
if (buf.size >= maxInflatedBytes) return null
|
||||
buf = buf.copyOf(minOf(maxInflatedBytes, buf.size * 2))
|
||||
}
|
||||
val count = inflater.inflate(buf, written, buf.size - written)
|
||||
written += count
|
||||
if (written > ratioBound) return null
|
||||
if (inflater.finished()) break
|
||||
if (count == 0) return null // truncated stream or preset-dictionary request
|
||||
}
|
||||
} catch (_: DataFormatException) {
|
||||
return null
|
||||
}
|
||||
return ByteArray(headerLength + written).also {
|
||||
System.arraycopy(data, 0, it, 0, headerLength)
|
||||
System.arraycopy(buf, 0, it, headerLength, written)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,20 +39,48 @@ import kotlinx.coroutines.sync.withLock
|
||||
class MpvPlayerCore private constructor(
|
||||
private val context: Context,
|
||||
private val audioOnly: Boolean,
|
||||
private val hardwareDecoding: Boolean,
|
||||
private val propertyWriterOverride: (suspend (String, String) -> Unit)?,
|
||||
initializedForTesting: Boolean
|
||||
) : SurfaceHolder.Callback,
|
||||
SurfacePlayerCore {
|
||||
constructor(context: Context, audioOnly: Boolean = false) : this(context, audioOnly, null, false)
|
||||
constructor(
|
||||
context: Context,
|
||||
audioOnly: Boolean = false,
|
||||
hardwareDecoding: Boolean = true
|
||||
) : this(context, audioOnly, hardwareDecoding, null, false)
|
||||
|
||||
internal constructor(
|
||||
context: Context,
|
||||
audioOnly: Boolean,
|
||||
propertyWriter: (suspend (String, String) -> Unit)?
|
||||
) : this(context, audioOnly, propertyWriter, true)
|
||||
) : this(context, audioOnly, true, propertyWriter, true)
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MpvPlayerCore"
|
||||
|
||||
/**
|
||||
* The initial `vo` chain, decided by whether this session will hardware-
|
||||
* decode.
|
||||
*
|
||||
* gpu-next (libplacebo) is the only Android path that applies Dolby Vision
|
||||
* RPU reshaping (#1902), but reshaping only ever happens under software
|
||||
* decode: FFmpeg's mediacodec wrapper exports no DOVI side data, so a
|
||||
* hardware-decoded stream renders the untouched base layer on any VO.
|
||||
* Hardware decode is also where gpu-next breaks: it samples the decoder
|
||||
* output as a samplerExternalOES that libplacebo declares in both shader
|
||||
* stages, and the Tegra GLES linker rejects that pair ("struct type
|
||||
* mismatch between shaders for uniform"), failing every frame — a solid
|
||||
* blue screen with audio on the Shield (#2010). The in-chain gpu fallback
|
||||
* cannot catch it because gpu-next initializes fine and only fails
|
||||
* per-frame renders.
|
||||
*
|
||||
* So gpu-next is offered exactly where it can help — sessions that will
|
||||
* software-decode — and hardware sessions keep the legacy gpu VO. A
|
||||
* mid-session hwdec fallback to software stays on vo=gpu, which renders
|
||||
* software frames correctly (the pre-2.15.0 behavior for every session).
|
||||
*/
|
||||
internal fun initialVideoOutput(hardwareDecoding: Boolean): String = if (hardwareDecoding) "gpu" else "gpu-next,gpu"
|
||||
}
|
||||
|
||||
/** Video-only paths. The plugin always constructs video cores with the
|
||||
@@ -293,15 +321,10 @@ class MpvPlayerCore private constructor(
|
||||
setOption("audio-display", "no")
|
||||
setOption("gapless-audio", "weak")
|
||||
} else {
|
||||
// gpu-next (libplacebo) is mpv 0.41's default VO and the only
|
||||
// Android path that applies Dolby Vision RPU reshaping — vo=gpu
|
||||
// renders the raw base layer, which for DV Profile 5 means
|
||||
// pink/purple IPTPQc2 output (#1902). Keep the explicit chain so
|
||||
// a device where gpu-next cannot initialize still gets the
|
||||
// legacy renderer instead of no video output. Film grain is left
|
||||
// on its `auto` default: applied by the VO under gpu-next, by
|
||||
// the decoder on the fallback path.
|
||||
setOption("vo", "gpu-next,gpu")
|
||||
// vo choice is decode-path-dependent; rationale on
|
||||
// initialVideoOutput. Film grain is left on its `auto` default:
|
||||
// applied by the VO under gpu-next, by the decoder under gpu.
|
||||
setOption("vo", initialVideoOutput(hardwareDecoding))
|
||||
setOption("gpu-context", "android")
|
||||
setOption("opengl-es", "yes")
|
||||
if (displayFpsOverride != null) {
|
||||
@@ -1049,6 +1072,9 @@ class MpvPlayerCore private constructor(
|
||||
"audio-codec-name" to getProperty("audio-codec-name"),
|
||||
"audio-params/samplerate" to getProperty("audio-params/samplerate"),
|
||||
"audio-params/hr-channels" to getProperty("audio-params/hr-channels"),
|
||||
"audio-params/format" to getProperty("audio-params/format"),
|
||||
"current-tracks/audio/demux-samplerate" to getProperty("current-tracks/audio/demux-samplerate"),
|
||||
"current-tracks/audio/demux-channel-count" to getProperty("current-tracks/audio/demux-channel-count"),
|
||||
"audio-bitrate" to getProperty("audio-bitrate"),
|
||||
"total-avsync-change" to getProperty("total-avsync-change"),
|
||||
"cache-used" to getProperty("cache-used"),
|
||||
|
||||
@@ -148,7 +148,7 @@ open class MpvPlayerPlugin(
|
||||
|
||||
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
|
||||
when (call.method) {
|
||||
"initialize" -> handleInitialize(result)
|
||||
"initialize" -> handleInitialize(call, result)
|
||||
"dispose" -> handleDispose(result)
|
||||
"setProperty" -> handleSetProperty(call, result)
|
||||
"getProperty" -> handleGetProperty(call, result)
|
||||
@@ -180,7 +180,11 @@ open class MpvPlayerPlugin(
|
||||
result.success(context?.let(::supportedMpvSpdifCodecs) ?: "")
|
||||
}
|
||||
|
||||
private fun handleInitialize(result: MethodChannel.Result) {
|
||||
private fun handleInitialize(call: MethodCall, result: MethodChannel.Result) {
|
||||
// Whether the session will hardware-decode; decides the initial vo chain
|
||||
// (MpvPlayerCore.initialVideoOutput). Absent on the audio-only core and
|
||||
// from older callers; hardware decode is the setting's default.
|
||||
val hardwareDecoding = call.argument<Boolean>("hardwareDecoding") ?: true
|
||||
// Video cores need the Activity (surface/view hierarchy); the audio-only
|
||||
// core is built on the application context so it can outlive it.
|
||||
val coreContext: Context? = if (audioOnly) applicationContext else activity
|
||||
@@ -239,7 +243,7 @@ open class MpvPlayerPlugin(
|
||||
}
|
||||
|
||||
gen = ++sessionGeneration
|
||||
core = MpvPlayerCore(coreContext, audioOnly).apply {
|
||||
core = MpvPlayerCore(coreContext, audioOnly, hardwareDecoding).apply {
|
||||
delegate = this@MpvPlayerPlugin
|
||||
}
|
||||
playerCore = core
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.edde746.plezy.exoplayer
|
||||
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.util.zip.Deflater
|
||||
import java.util.zip.DeflaterOutputStream
|
||||
import java.util.zip.Inflater
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Unit spec for [rewriteZlibTextBlock]: the block header (track-number varint,
|
||||
* timecode, flags) must survive byte-identically, the payload must inflate, and
|
||||
* every block the rewriter cannot prove safe must pass through unchanged (null).
|
||||
*/
|
||||
class ZlibTextBlockTest {
|
||||
|
||||
private val inflater = Inflater()
|
||||
|
||||
private fun block(header: ByteArray, payload: ByteArray): ByteArray = header + payload
|
||||
|
||||
private fun deflate(bytes: ByteArray): ByteArray {
|
||||
val target = ByteArrayOutputStream()
|
||||
DeflaterOutputStream(target, Deflater()).use { it.write(bytes) }
|
||||
return target.toByteArray()
|
||||
}
|
||||
|
||||
// Track 3 (varint 0x83), relative timecode 0x0102, no lacing.
|
||||
private val unlacedHeader = byteArrayOf(0x83.toByte(), 0x01, 0x02, 0x00)
|
||||
|
||||
@Test
|
||||
fun inflatesUnlacedBlockPayloadAndPreservesHeader() {
|
||||
val dialogue = "42,,Default,,0,0,0,,SUBTITLE LINE 1 (0:00:00.00)".toByteArray()
|
||||
val data = block(unlacedHeader, deflate(dialogue))
|
||||
|
||||
val rewritten = rewriteZlibTextBlock(data, data.size, inflater)!!
|
||||
|
||||
assertArrayEquals(unlacedHeader + dialogue, rewritten)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun twoByteTrackNumberVarintIsPreserved() {
|
||||
val dialogue = "1,,Default,,0,0,0,,hello".toByteArray()
|
||||
val header = byteArrayOf(0x41, 0x2A, 0x01, 0x02, 0x00) // varint 0x412A = track 298
|
||||
val data = block(header, deflate(dialogue))
|
||||
|
||||
val rewritten = rewriteZlibTextBlock(data, data.size, inflater)!!
|
||||
|
||||
assertArrayEquals(header + dialogue, rewritten)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun lacedBlockPassesThrough() {
|
||||
val laced = byteArrayOf(0x83.toByte(), 0x01, 0x02, 0x06) // EBML lacing bits set
|
||||
val data = block(laced, deflate("payload".toByteArray()))
|
||||
|
||||
assertNull(rewriteZlibTextBlock(data, data.size, inflater))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun corruptStreamPassesThrough() {
|
||||
val data = block(unlacedHeader, byteArrayOf(0x44, 0x69, 0x61, 0x6C)) // "Dial", not zlib
|
||||
|
||||
assertNull(rewriteZlibTextBlock(data, data.size, inflater))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun truncatedStreamPassesThrough() {
|
||||
val compressed = deflate("a longer payload that spans several deflate symbols".toByteArray())
|
||||
val truncated = compressed.copyOf(compressed.size - 4)
|
||||
val data = block(unlacedHeader, truncated)
|
||||
|
||||
assertNull(rewriteZlibTextBlock(data, data.size, inflater))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun headerOnlyBlockPassesThrough() {
|
||||
assertNull(rewriteZlibTextBlock(unlacedHeader, unlacedHeader.size, inflater))
|
||||
}
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
package com.edde746.plezy.exoplayer
|
||||
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.common.DataReader
|
||||
import androidx.media3.common.MimeTypes
|
||||
import androidx.media3.common.util.ParsableByteArray
|
||||
import androidx.media3.extractor.DefaultExtractorInput
|
||||
import androidx.media3.extractor.Extractor
|
||||
import androidx.media3.extractor.ExtractorOutput
|
||||
import androidx.media3.extractor.PositionHolder
|
||||
import androidx.media3.extractor.SeekMap
|
||||
import androidx.media3.extractor.TrackOutput
|
||||
import androidx.media3.extractor.text.CueDecoder
|
||||
import androidx.media3.extractor.text.DefaultSubtitleParserFactory
|
||||
import com.edde746.plezy.libass.media.AssHandler
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
/**
|
||||
* Extracts the committed fixtures — one ASS subtitle track muxed by mkvmerge with
|
||||
* `--compression 0:zlib` (ContentCompAlgo 0, the anime-release convention that
|
||||
* broke #2023) and an identical uncompressed mux — and verifies the zlib block
|
||||
* payloads are inflated *before* MatroskaExtractor's subtitle sample assembly.
|
||||
*
|
||||
* Regenerate with:
|
||||
* mkvmerge -o zlib_ssa.mkv --compression 0:zlib repro.ass
|
||||
* mkvmerge -o plain_ssa.mkv --compression 0:none repro.ass
|
||||
* where repro.ass holds 45 two-second "SUBTITLE LINE N (H:MM:SS.00)" events.
|
||||
*
|
||||
* Robolectric provides real android.util/android.os implementations —
|
||||
* MatroskaExtractor uses SparseArray and CueDecoder uses Parcel, both of which
|
||||
* are no-op stubs on plain JVM.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34])
|
||||
class ZlibTextSubtitleExtractionTest {
|
||||
|
||||
private class CapturedSample(val timeUs: Long, val data: ByteArray)
|
||||
|
||||
private class FakeTrackOutput : TrackOutput {
|
||||
val formats = mutableListOf<androidx.media3.common.Format>()
|
||||
val samples = mutableListOf<CapturedSample>()
|
||||
private var buf = ByteArray(64 * 1024)
|
||||
private var bufLen = 0
|
||||
|
||||
override fun format(format: androidx.media3.common.Format) {
|
||||
formats.add(format)
|
||||
}
|
||||
|
||||
override fun sampleData(input: DataReader, length: Int, allowEndOfInput: Boolean, sampleDataPart: Int): Int {
|
||||
ensureCapacity(bufLen + length)
|
||||
val read = input.read(buf, bufLen, length)
|
||||
if (read > 0) bufLen += read
|
||||
return read
|
||||
}
|
||||
|
||||
override fun sampleData(data: ParsableByteArray, length: Int, sampleDataPart: Int) {
|
||||
ensureCapacity(bufLen + length)
|
||||
data.readBytes(buf, bufLen, length)
|
||||
bufLen += length
|
||||
}
|
||||
|
||||
override fun sampleMetadata(timeUs: Long, flags: Int, size: Int, offset: Int, cryptoData: TrackOutput.CryptoData?) {
|
||||
val start = bufLen - offset - size
|
||||
samples.add(CapturedSample(timeUs, buf.copyOfRange(start, start + size)))
|
||||
if (offset == 0) bufLen = 0
|
||||
}
|
||||
|
||||
private fun ensureCapacity(needed: Int) {
|
||||
if (buf.size < needed) buf = buf.copyOf(maxOf(needed, buf.size * 2))
|
||||
}
|
||||
}
|
||||
|
||||
private class FakeExtractorOutput : ExtractorOutput {
|
||||
val tracks = mutableMapOf<Int, FakeTrackOutput>()
|
||||
|
||||
override fun track(id: Int, type: Int): TrackOutput = tracks.getOrPut(id) { FakeTrackOutput() }
|
||||
override fun endTracks() {}
|
||||
override fun seekMap(seekMap: SeekMap) {}
|
||||
}
|
||||
|
||||
private class ByteArrayDataReader(private val data: ByteArray) : DataReader {
|
||||
var position = 0L
|
||||
|
||||
override fun read(buffer: ByteArray, offset: Int, length: Int): Int {
|
||||
if (position >= data.size) return C.RESULT_END_OF_INPUT
|
||||
val toRead = minOf(length, data.size - position.toInt())
|
||||
System.arraycopy(data, position.toInt(), buffer, offset, toRead)
|
||||
position += toRead
|
||||
return toRead
|
||||
}
|
||||
}
|
||||
|
||||
private fun extract(resource: String): FakeExtractorOutput {
|
||||
val data = checkNotNull(javaClass.getResourceAsStream(resource)) {
|
||||
"fixture $resource missing from test resources"
|
||||
}.use { it.readBytes() }
|
||||
|
||||
// DefaultSubtitleParserFactory (not AssSubtitleParserFactory) so the SSA track
|
||||
// transcodes to decodable media3 cues instead of loading native libass.
|
||||
val extractor = ZlibMatroskaExtractor(DefaultSubtitleParserFactory(), AssHandler())
|
||||
val output = FakeExtractorOutput()
|
||||
extractor.init(output)
|
||||
|
||||
val reader = ByteArrayDataReader(data)
|
||||
var input = DefaultExtractorInput(reader, 0, data.size.toLong())
|
||||
val seekPosition = PositionHolder()
|
||||
while (true) {
|
||||
when (extractor.read(input, seekPosition)) {
|
||||
Extractor.RESULT_END_OF_INPUT -> return output
|
||||
Extractor.RESULT_SEEK -> {
|
||||
reader.position = seekPosition.position
|
||||
input = DefaultExtractorInput(reader, seekPosition.position, data.size.toLong())
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DecodedCue(val startTimeUs: Long, val durationUs: Long, val text: String)
|
||||
|
||||
private fun decodeCues(output: FakeExtractorOutput): List<DecodedCue> {
|
||||
val track = output.tracks.values.single()
|
||||
val format = track.formats.last()
|
||||
assertEquals(MimeTypes.APPLICATION_MEDIA3_CUES, format.sampleMimeType)
|
||||
assertEquals(MimeTypes.TEXT_SSA, format.codecs)
|
||||
val decoder = CueDecoder()
|
||||
return track.samples.map { sample ->
|
||||
val cues = decoder.decode(sample.timeUs, sample.data, 0, sample.data.size)
|
||||
DecodedCue(
|
||||
cues.startTimeUs,
|
||||
cues.durationUs,
|
||||
cues.cues.joinToString("\n") { it.text.toString() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun zlibCompressedAssDialogueIsInflatedToParseableCues() {
|
||||
val cues = decodeCues(extract("/zlib_ssa.mkv"))
|
||||
|
||||
assertEquals(45, cues.size)
|
||||
assertEquals("SUBTITLE LINE 1 (0:00:00.00)", cues.first().text)
|
||||
assertEquals(0L, cues.first().startTimeUs)
|
||||
assertEquals(2_000_000L, cues.first().durationUs)
|
||||
assertEquals("SUBTITLE LINE 45 (0:01:28.00)", cues.last().text)
|
||||
assertEquals(88_000_000L, cues.last().startTimeUs)
|
||||
cues.forEachIndexed { index, cue ->
|
||||
assertEquals(index * 2_000_000L, cue.startTimeUs)
|
||||
assertTrue("cue $index text: ${cue.text}", cue.text.startsWith("SUBTITLE LINE ${index + 1} "))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun zlibAndPlainMuxesProduceIdenticalCues() {
|
||||
val zlib = decodeCues(extract("/zlib_ssa.mkv"))
|
||||
val plain = decodeCues(extract("/plain_ssa.mkv"))
|
||||
|
||||
assertEquals(plain.size, zlib.size)
|
||||
plain.zip(zlib).forEachIndexed { index, (expected, actual) ->
|
||||
assertEquals("startTimeUs of cue $index", expected.startTimeUs, actual.startTimeUs)
|
||||
assertEquals("durationUs of cue $index", expected.durationUs, actual.durationUs)
|
||||
assertEquals("text of cue $index", expected.text, actual.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,17 @@ class MpvPlayerPluginTest {
|
||||
assertEquals(1, result.completionCount)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hardwareDecodeSessionsKeepTheLegacyGpuVo() {
|
||||
// gpu-next under hwdec=mediacodec fails every frame on Tegra (the
|
||||
// cross-stage samplerExternalOES linker bug): solid blue screen with
|
||||
// audio on the Shield (#2010). DV reshaping — the reason gpu-next exists
|
||||
// on Android (#1902) — only happens under software decode anyway, so
|
||||
// gpu-next is offered exactly there and nowhere else.
|
||||
assertEquals("gpu", MpvPlayerCore.initialVideoOutput(hardwareDecoding = true))
|
||||
assertEquals("gpu-next,gpu", MpvPlayerCore.initialVideoOutput(hardwareDecoding = false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun setPropertyWithoutCoreReportsNotInitializedForVideoAndAudio() {
|
||||
for (plugin in listOf(MpvPlayerPlugin(), MpvAudioPlayerPlugin())) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -798,7 +798,7 @@
|
||||
repositoryURL = "https://github.com/edde746/MPVKit";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 1.0.22;
|
||||
version = 1.0.23;
|
||||
};
|
||||
};
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/edde746/MPVKit",
|
||||
"state" : {
|
||||
"revision" : "2d818406d8aaa5e2fb5d7901c516e8f6c97d6ee0",
|
||||
"version" : "1.0.22"
|
||||
"revision" : "ee423a7e8727eeee4748f08cb7d3c00e935ed45e",
|
||||
"version" : "1.0.23"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/edde746/MPVKit",
|
||||
"state" : {
|
||||
"revision" : "2d818406d8aaa5e2fb5d7901c516e8f6c97d6ee0",
|
||||
"version" : "1.0.22"
|
||||
"revision" : "ee423a7e8727eeee4748f08cb7d3c00e935ed45e",
|
||||
"version" : "1.0.23"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../utils/scroll_utils.dart';
|
||||
import 'owned_focus_node_binding.dart';
|
||||
import 'input_mode_tracker.dart';
|
||||
import 'dpad_navigator.dart';
|
||||
import 'dpad_select_long_press_controller.dart';
|
||||
import 'key_event_utils.dart';
|
||||
@@ -92,8 +93,12 @@ mixin FocusableChipStateMixin<T extends StatefulWidget> on State<T> {
|
||||
}
|
||||
// Same convention as FocusableTileStateMixin: a chip inside a
|
||||
// scrollable strip (TabChipStrip, filter bars) reveals itself on
|
||||
// focus; a no-op when no ancestor scrollable exists.
|
||||
if (focusNode.hasFocus) scrollContextToCenter(context);
|
||||
// focus; a no-op when no ancestor scrollable exists. Keyboard/D-pad
|
||||
// sessions only — pointer-mode focus is programmatic and invisible,
|
||||
// so revealing it would yank the strip (issue #2031).
|
||||
if (focusNode.hasFocus && InputModeTracker.currentMode == InputMode.keyboard) {
|
||||
scrollContextToCenter(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../utils/scroll_utils.dart';
|
||||
import 'input_mode_tracker.dart';
|
||||
import 'owned_focus_node_binding.dart';
|
||||
|
||||
/// Manages the internal/external FocusNode lifecycle for list-tile widgets and
|
||||
@@ -39,7 +40,10 @@ mixin FocusableTileStateMixin<T extends StatefulWidget> on State<T> {
|
||||
}
|
||||
|
||||
void _onFocusChange() {
|
||||
if (effectiveFocusNode.hasFocus) {
|
||||
// Reveal on focus is keyboard/D-pad-only: pointer-mode focus is
|
||||
// programmatic and invisible, so revealing it would yank the scroll view
|
||||
// (issue #2031).
|
||||
if (effectiveFocusNode.hasFocus && InputModeTracker.currentMode == InputMode.keyboard) {
|
||||
scrollContextToCenter(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,8 +319,12 @@ class _FocusableWrapperState extends State<FocusableWrapper> with SingleTickerPr
|
||||
_animationController?.reverse();
|
||||
}
|
||||
|
||||
// Auto-scroll into view
|
||||
if (hasFocus && widget.autoScroll) {
|
||||
// Auto-scroll into view. Keyboard/D-pad sessions only: pointer-mode
|
||||
// focus is invisible and only ever parked or restored programmatically
|
||||
// (entry focus targets, a context menu re-focusing its trigger on
|
||||
// close), so revealing it would yank the viewport away from wherever
|
||||
// the user scrolled (issue #2031).
|
||||
if (hasFocus && widget.autoScroll && InputModeTracker.currentMode == InputMode.keyboard) {
|
||||
_scrollIntoView();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,19 @@ class InputModeTracker extends StatefulWidget {
|
||||
return of(context, listen: listen) == InputMode.keyboard;
|
||||
}
|
||||
|
||||
/// Live input mode, readable without a [BuildContext].
|
||||
///
|
||||
/// Focus-change listeners fire during key dispatch, before the inherited
|
||||
/// provider has rebuilt for a mode flip, so a context read through [of]
|
||||
/// is one frame stale on the first navigation key of a keyboard session.
|
||||
/// The tracker's own state is updated synchronously by its
|
||||
/// [HardwareKeyboard] handler, which runs before focus traversal moves
|
||||
/// focus. Falls back to the platform default when no tracker is mounted.
|
||||
static InputMode get currentMode => _instance?._mode ?? _defaultMode;
|
||||
|
||||
/// Keyboard/D-pad on TV, pointer everywhere else.
|
||||
static InputMode get _defaultMode => PlatformDetector.isTV() ? InputMode.keyboard : InputMode.pointer;
|
||||
|
||||
/// Whether system back must be blocked because the dpad key handler owns
|
||||
/// back navigation: on Android in keyboard mode (TV/gamepad), letting the
|
||||
/// system back through as well double-pops the route.
|
||||
@@ -74,8 +87,7 @@ class InputModeTracker extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _InputModeTrackerState extends State<InputModeTracker> {
|
||||
// Default to keyboard mode on Android TV, pointer mode elsewhere
|
||||
InputMode _mode = PlatformDetector.isTV() ? InputMode.keyboard : InputMode.pointer;
|
||||
InputMode _mode = InputModeTracker._defaultMode;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
@@ -32,4 +32,12 @@ class HubFocusMemory {
|
||||
final remembered = _perHubMemory[hubKey];
|
||||
return (remembered ?? fallback).clamp(0, itemCount - 1);
|
||||
}
|
||||
|
||||
/// Rewrite a hub's remembered index in place after its content reordered
|
||||
/// underneath it (a Continue Watching refresh, not user navigation). Unlike
|
||||
/// [setForHub] this never moves the cross-hub column hint, and it is a no-op
|
||||
/// for hubs without memory.
|
||||
void remapForHub(String hubKey, int index) {
|
||||
if (_perHubMemory.containsKey(hubKey)) _perHubMemory[hubKey] = index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Çözücü",
|
||||
"rawDecoder": "Xam çözücü",
|
||||
"tunneling": "Tünelləmə",
|
||||
"passthrough": "Birbaşa ötürmə",
|
||||
"aspect": "Nisbət",
|
||||
"rotation": "Dönmə",
|
||||
"dvSource": "DV mənbəyi",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Декодер",
|
||||
"rawDecoder": "Суров декодер",
|
||||
"tunneling": "Тунелиране",
|
||||
"passthrough": "Директно предаване",
|
||||
"aspect": "Съотношение",
|
||||
"rotation": "Завъртане",
|
||||
"dvSource": "DV източник",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Dekoder",
|
||||
"rawDecoder": "Rå dekoder",
|
||||
"tunneling": "Tunneling",
|
||||
"passthrough": "Passthrough",
|
||||
"aspect": "Billedformat",
|
||||
"rotation": "Rotation",
|
||||
"dvSource": "DV-kilde",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Decoder",
|
||||
"rawDecoder": "Raw-Decoder",
|
||||
"tunneling": "Tunneling",
|
||||
"passthrough": "Durchleitung",
|
||||
"aspect": "Seitenverhältnis",
|
||||
"rotation": "Drehung",
|
||||
"dvSource": "DV-Quelle",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Decoder",
|
||||
"rawDecoder": "Raw Decoder",
|
||||
"tunneling": "Tunneling",
|
||||
"passthrough": "Passthrough",
|
||||
"aspect": "Aspect",
|
||||
"rotation": "Rotation",
|
||||
"dvSource": "DV Source",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Decodificador",
|
||||
"rawDecoder": "Decodificador sin procesar",
|
||||
"tunneling": "Túnel",
|
||||
"passthrough": "Transferencia directa",
|
||||
"aspect": "Aspecto",
|
||||
"rotation": "Rotación",
|
||||
"dvSource": "Origen DV",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Décodeur",
|
||||
"rawDecoder": "Décodeur brut",
|
||||
"tunneling": "Tunnel",
|
||||
"passthrough": "Transmission directe",
|
||||
"aspect": "Format",
|
||||
"rotation": "Rotation",
|
||||
"dvSource": "Source DV",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Dekóder",
|
||||
"rawDecoder": "Nyers dekóder",
|
||||
"tunneling": "Alagutazás",
|
||||
"passthrough": "Passthrough",
|
||||
"aspect": "Méretarány",
|
||||
"rotation": "Forgatás",
|
||||
"dvSource": "DV-forrás",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Decoder",
|
||||
"rawDecoder": "Decoder raw",
|
||||
"tunneling": "Tunneling",
|
||||
"passthrough": "Passthrough",
|
||||
"aspect": "Proporzioni",
|
||||
"rotation": "Rotazione",
|
||||
"dvSource": "Sorgente DV",
|
||||
|
||||
@@ -1725,6 +1725,7 @@
|
||||
"decoder": "デコーダー",
|
||||
"rawDecoder": "Raw デコーダー",
|
||||
"tunneling": "トンネリング",
|
||||
"passthrough": "パススルー",
|
||||
"aspect": "アスペクト",
|
||||
"rotation": "回転",
|
||||
"dvSource": "DV ソース",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Декодер",
|
||||
"rawDecoder": "Өңделмеген декодер",
|
||||
"tunneling": "Туннельдеу",
|
||||
"passthrough": "Тікелей өткізу",
|
||||
"aspect": "Қатынас",
|
||||
"rotation": "Бұрылыс",
|
||||
"dvSource": "DV дереккөзі",
|
||||
|
||||
@@ -1725,6 +1725,7 @@
|
||||
"decoder": "디코더",
|
||||
"rawDecoder": "원본 디코더",
|
||||
"tunneling": "터널링",
|
||||
"passthrough": "패스스루",
|
||||
"aspect": "화면비",
|
||||
"rotation": "회전",
|
||||
"dvSource": "DV 소스",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Dekoder",
|
||||
"rawDecoder": "Rå dekoder",
|
||||
"tunneling": "Tunneling",
|
||||
"passthrough": "Direkte utgang",
|
||||
"aspect": "Format",
|
||||
"rotation": "Rotasjon",
|
||||
"dvSource": "DV-kilde",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Decoder",
|
||||
"rawDecoder": "Raw-decoder",
|
||||
"tunneling": "Tunneling",
|
||||
"passthrough": "Doorvoer",
|
||||
"aspect": "Verhouding",
|
||||
"rotation": "Rotatie",
|
||||
"dvSource": "DV-bron",
|
||||
|
||||
@@ -1755,6 +1755,7 @@
|
||||
"decoder": "Dekoder",
|
||||
"rawDecoder": "Surowy dekoder",
|
||||
"tunneling": "Tunelowanie",
|
||||
"passthrough": "Przekazywanie",
|
||||
"aspect": "Proporcje",
|
||||
"rotation": "Obrót",
|
||||
"dvSource": "Źródło DV",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Decodificador",
|
||||
"rawDecoder": "Decodificador bruto",
|
||||
"tunneling": "Túnel",
|
||||
"passthrough": "Passagem direta",
|
||||
"aspect": "Aspecto",
|
||||
"rotation": "Rotação",
|
||||
"dvSource": "Fonte DV",
|
||||
|
||||
@@ -1755,6 +1755,7 @@
|
||||
"decoder": "Декодер",
|
||||
"rawDecoder": "Raw-декодер",
|
||||
"tunneling": "Туннелирование",
|
||||
"passthrough": "Сквозной вывод",
|
||||
"aspect": "Соотношение",
|
||||
"rotation": "Поворот",
|
||||
"dvSource": "Источник DV",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/// To regenerate, run: `dart run slang`
|
||||
///
|
||||
/// Locales: 22
|
||||
/// Strings: 40942 (1861 per locale)
|
||||
/// Strings: 40964 (1862 per locale)
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint, unused_import
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$az extends Translations$performanceOverla
|
||||
@override String get decoder => 'Çözücü';
|
||||
@override String get rawDecoder => 'Xam çözücü';
|
||||
@override String get tunneling => 'Tünelləmə';
|
||||
@override String get passthrough => 'Birbaşa ötürmə';
|
||||
@override String get aspect => 'Nisbət';
|
||||
@override String get rotation => 'Dönmə';
|
||||
@override String get dvSource => 'DV mənbəyi';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsAz {
|
||||
'performanceOverlay.decoder' => 'Çözücü',
|
||||
'performanceOverlay.rawDecoder' => 'Xam çözücü',
|
||||
'performanceOverlay.tunneling' => 'Tünelləmə',
|
||||
'performanceOverlay.passthrough' => 'Birbaşa ötürmə',
|
||||
'performanceOverlay.aspect' => 'Nisbət',
|
||||
'performanceOverlay.rotation' => 'Dönmə',
|
||||
'performanceOverlay.dvSource' => 'DV mənbəyi',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$bg extends Translations$performanceOverla
|
||||
@override String get decoder => 'Декодер';
|
||||
@override String get rawDecoder => 'Суров декодер';
|
||||
@override String get tunneling => 'Тунелиране';
|
||||
@override String get passthrough => 'Директно предаване';
|
||||
@override String get aspect => 'Съотношение';
|
||||
@override String get rotation => 'Завъртане';
|
||||
@override String get dvSource => 'DV източник';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsBg {
|
||||
'performanceOverlay.decoder' => 'Декодер',
|
||||
'performanceOverlay.rawDecoder' => 'Суров декодер',
|
||||
'performanceOverlay.tunneling' => 'Тунелиране',
|
||||
'performanceOverlay.passthrough' => 'Директно предаване',
|
||||
'performanceOverlay.aspect' => 'Съотношение',
|
||||
'performanceOverlay.rotation' => 'Завъртане',
|
||||
'performanceOverlay.dvSource' => 'DV източник',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$da extends Translations$performanceOverla
|
||||
@override String get decoder => 'Dekoder';
|
||||
@override String get rawDecoder => 'Rå dekoder';
|
||||
@override String get tunneling => 'Tunneling';
|
||||
@override String get passthrough => 'Passthrough';
|
||||
@override String get aspect => 'Billedformat';
|
||||
@override String get rotation => 'Rotation';
|
||||
@override String get dvSource => 'DV-kilde';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsDa {
|
||||
'performanceOverlay.decoder' => 'Dekoder',
|
||||
'performanceOverlay.rawDecoder' => 'Rå dekoder',
|
||||
'performanceOverlay.tunneling' => 'Tunneling',
|
||||
'performanceOverlay.passthrough' => 'Passthrough',
|
||||
'performanceOverlay.aspect' => 'Billedformat',
|
||||
'performanceOverlay.rotation' => 'Rotation',
|
||||
'performanceOverlay.dvSource' => 'DV-kilde',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$de extends Translations$performanceOverla
|
||||
@override String get decoder => 'Decoder';
|
||||
@override String get rawDecoder => 'Raw-Decoder';
|
||||
@override String get tunneling => 'Tunneling';
|
||||
@override String get passthrough => 'Durchleitung';
|
||||
@override String get aspect => 'Seitenverhältnis';
|
||||
@override String get rotation => 'Drehung';
|
||||
@override String get dvSource => 'DV-Quelle';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsDe {
|
||||
'performanceOverlay.decoder' => 'Decoder',
|
||||
'performanceOverlay.rawDecoder' => 'Raw-Decoder',
|
||||
'performanceOverlay.tunneling' => 'Tunneling',
|
||||
'performanceOverlay.passthrough' => 'Durchleitung',
|
||||
'performanceOverlay.aspect' => 'Seitenverhältnis',
|
||||
'performanceOverlay.rotation' => 'Drehung',
|
||||
'performanceOverlay.dvSource' => 'DV-Quelle',
|
||||
|
||||
@@ -4375,6 +4375,9 @@ class Translations$performanceOverlay$en {
|
||||
/// en: 'Tunneling'
|
||||
String get tunneling => 'Tunneling';
|
||||
|
||||
/// en: 'Passthrough'
|
||||
String get passthrough => 'Passthrough';
|
||||
|
||||
/// en: 'Aspect'
|
||||
String get aspect => 'Aspect';
|
||||
|
||||
@@ -8006,6 +8009,7 @@ extension on Translations {
|
||||
'performanceOverlay.decoder' => 'Decoder',
|
||||
'performanceOverlay.rawDecoder' => 'Raw Decoder',
|
||||
'performanceOverlay.tunneling' => 'Tunneling',
|
||||
'performanceOverlay.passthrough' => 'Passthrough',
|
||||
'performanceOverlay.aspect' => 'Aspect',
|
||||
'performanceOverlay.rotation' => 'Rotation',
|
||||
'performanceOverlay.dvSource' => 'DV Source',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$es extends Translations$performanceOverla
|
||||
@override String get decoder => 'Decodificador';
|
||||
@override String get rawDecoder => 'Decodificador sin procesar';
|
||||
@override String get tunneling => 'Túnel';
|
||||
@override String get passthrough => 'Transferencia directa';
|
||||
@override String get aspect => 'Aspecto';
|
||||
@override String get rotation => 'Rotación';
|
||||
@override String get dvSource => 'Origen DV';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsEs {
|
||||
'performanceOverlay.decoder' => 'Decodificador',
|
||||
'performanceOverlay.rawDecoder' => 'Decodificador sin procesar',
|
||||
'performanceOverlay.tunneling' => 'Túnel',
|
||||
'performanceOverlay.passthrough' => 'Transferencia directa',
|
||||
'performanceOverlay.aspect' => 'Aspecto',
|
||||
'performanceOverlay.rotation' => 'Rotación',
|
||||
'performanceOverlay.dvSource' => 'Origen DV',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$fr extends Translations$performanceOverla
|
||||
@override String get decoder => 'Décodeur';
|
||||
@override String get rawDecoder => 'Décodeur brut';
|
||||
@override String get tunneling => 'Tunnel';
|
||||
@override String get passthrough => 'Transmission directe';
|
||||
@override String get aspect => 'Format';
|
||||
@override String get rotation => 'Rotation';
|
||||
@override String get dvSource => 'Source DV';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsFr {
|
||||
'performanceOverlay.decoder' => 'Décodeur',
|
||||
'performanceOverlay.rawDecoder' => 'Décodeur brut',
|
||||
'performanceOverlay.tunneling' => 'Tunnel',
|
||||
'performanceOverlay.passthrough' => 'Transmission directe',
|
||||
'performanceOverlay.aspect' => 'Format',
|
||||
'performanceOverlay.rotation' => 'Rotation',
|
||||
'performanceOverlay.dvSource' => 'Source DV',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$hu extends Translations$performanceOverla
|
||||
@override String get decoder => 'Dekóder';
|
||||
@override String get rawDecoder => 'Nyers dekóder';
|
||||
@override String get tunneling => 'Alagutazás';
|
||||
@override String get passthrough => 'Passthrough';
|
||||
@override String get aspect => 'Méretarány';
|
||||
@override String get rotation => 'Forgatás';
|
||||
@override String get dvSource => 'DV-forrás';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsHu {
|
||||
'performanceOverlay.decoder' => 'Dekóder',
|
||||
'performanceOverlay.rawDecoder' => 'Nyers dekóder',
|
||||
'performanceOverlay.tunneling' => 'Alagutazás',
|
||||
'performanceOverlay.passthrough' => 'Passthrough',
|
||||
'performanceOverlay.aspect' => 'Méretarány',
|
||||
'performanceOverlay.rotation' => 'Forgatás',
|
||||
'performanceOverlay.dvSource' => 'DV-forrás',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$it extends Translations$performanceOverla
|
||||
@override String get decoder => 'Decoder';
|
||||
@override String get rawDecoder => 'Decoder raw';
|
||||
@override String get tunneling => 'Tunneling';
|
||||
@override String get passthrough => 'Passthrough';
|
||||
@override String get aspect => 'Proporzioni';
|
||||
@override String get rotation => 'Rotazione';
|
||||
@override String get dvSource => 'Sorgente DV';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsIt {
|
||||
'performanceOverlay.decoder' => 'Decoder',
|
||||
'performanceOverlay.rawDecoder' => 'Decoder raw',
|
||||
'performanceOverlay.tunneling' => 'Tunneling',
|
||||
'performanceOverlay.passthrough' => 'Passthrough',
|
||||
'performanceOverlay.aspect' => 'Proporzioni',
|
||||
'performanceOverlay.rotation' => 'Rotazione',
|
||||
'performanceOverlay.dvSource' => 'Sorgente DV',
|
||||
|
||||
@@ -1789,6 +1789,7 @@ class _Translations$performanceOverlay$ja extends Translations$performanceOverla
|
||||
@override String get decoder => 'デコーダー';
|
||||
@override String get rawDecoder => 'Raw デコーダー';
|
||||
@override String get tunneling => 'トンネリング';
|
||||
@override String get passthrough => 'パススルー';
|
||||
@override String get aspect => 'アスペクト';
|
||||
@override String get rotation => '回転';
|
||||
@override String get dvSource => 'DV ソース';
|
||||
@@ -4282,6 +4283,7 @@ extension on TranslationsJa {
|
||||
'performanceOverlay.decoder' => 'デコーダー',
|
||||
'performanceOverlay.rawDecoder' => 'Raw デコーダー',
|
||||
'performanceOverlay.tunneling' => 'トンネリング',
|
||||
'performanceOverlay.passthrough' => 'パススルー',
|
||||
'performanceOverlay.aspect' => 'アスペクト',
|
||||
'performanceOverlay.rotation' => '回転',
|
||||
'performanceOverlay.dvSource' => 'DV ソース',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$kk extends Translations$performanceOverla
|
||||
@override String get decoder => 'Декодер';
|
||||
@override String get rawDecoder => 'Өңделмеген декодер';
|
||||
@override String get tunneling => 'Туннельдеу';
|
||||
@override String get passthrough => 'Тікелей өткізу';
|
||||
@override String get aspect => 'Қатынас';
|
||||
@override String get rotation => 'Бұрылыс';
|
||||
@override String get dvSource => 'DV дереккөзі';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsKk {
|
||||
'performanceOverlay.decoder' => 'Декодер',
|
||||
'performanceOverlay.rawDecoder' => 'Өңделмеген декодер',
|
||||
'performanceOverlay.tunneling' => 'Туннельдеу',
|
||||
'performanceOverlay.passthrough' => 'Тікелей өткізу',
|
||||
'performanceOverlay.aspect' => 'Қатынас',
|
||||
'performanceOverlay.rotation' => 'Бұрылыс',
|
||||
'performanceOverlay.dvSource' => 'DV дереккөзі',
|
||||
|
||||
@@ -1789,6 +1789,7 @@ class _Translations$performanceOverlay$ko extends Translations$performanceOverla
|
||||
@override String get decoder => '디코더';
|
||||
@override String get rawDecoder => '원본 디코더';
|
||||
@override String get tunneling => '터널링';
|
||||
@override String get passthrough => '패스스루';
|
||||
@override String get aspect => '화면비';
|
||||
@override String get rotation => '회전';
|
||||
@override String get dvSource => 'DV 소스';
|
||||
@@ -4282,6 +4283,7 @@ extension on TranslationsKo {
|
||||
'performanceOverlay.decoder' => '디코더',
|
||||
'performanceOverlay.rawDecoder' => '원본 디코더',
|
||||
'performanceOverlay.tunneling' => '터널링',
|
||||
'performanceOverlay.passthrough' => '패스스루',
|
||||
'performanceOverlay.aspect' => '화면비',
|
||||
'performanceOverlay.rotation' => '회전',
|
||||
'performanceOverlay.dvSource' => 'DV 소스',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$nb extends Translations$performanceOverla
|
||||
@override String get decoder => 'Dekoder';
|
||||
@override String get rawDecoder => 'Rå dekoder';
|
||||
@override String get tunneling => 'Tunneling';
|
||||
@override String get passthrough => 'Direkte utgang';
|
||||
@override String get aspect => 'Format';
|
||||
@override String get rotation => 'Rotasjon';
|
||||
@override String get dvSource => 'DV-kilde';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsNb {
|
||||
'performanceOverlay.decoder' => 'Dekoder',
|
||||
'performanceOverlay.rawDecoder' => 'Rå dekoder',
|
||||
'performanceOverlay.tunneling' => 'Tunneling',
|
||||
'performanceOverlay.passthrough' => 'Direkte utgang',
|
||||
'performanceOverlay.aspect' => 'Format',
|
||||
'performanceOverlay.rotation' => 'Rotasjon',
|
||||
'performanceOverlay.dvSource' => 'DV-kilde',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$nl extends Translations$performanceOverla
|
||||
@override String get decoder => 'Decoder';
|
||||
@override String get rawDecoder => 'Raw-decoder';
|
||||
@override String get tunneling => 'Tunneling';
|
||||
@override String get passthrough => 'Doorvoer';
|
||||
@override String get aspect => 'Verhouding';
|
||||
@override String get rotation => 'Rotatie';
|
||||
@override String get dvSource => 'DV-bron';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsNl {
|
||||
'performanceOverlay.decoder' => 'Decoder',
|
||||
'performanceOverlay.rawDecoder' => 'Raw-decoder',
|
||||
'performanceOverlay.tunneling' => 'Tunneling',
|
||||
'performanceOverlay.passthrough' => 'Doorvoer',
|
||||
'performanceOverlay.aspect' => 'Verhouding',
|
||||
'performanceOverlay.rotation' => 'Rotatie',
|
||||
'performanceOverlay.dvSource' => 'DV-bron',
|
||||
|
||||
@@ -1813,6 +1813,7 @@ class _Translations$performanceOverlay$pl extends Translations$performanceOverla
|
||||
@override String get decoder => 'Dekoder';
|
||||
@override String get rawDecoder => 'Surowy dekoder';
|
||||
@override String get tunneling => 'Tunelowanie';
|
||||
@override String get passthrough => 'Przekazywanie';
|
||||
@override String get aspect => 'Proporcje';
|
||||
@override String get rotation => 'Obrót';
|
||||
@override String get dvSource => 'Źródło DV';
|
||||
@@ -4312,6 +4313,7 @@ extension on TranslationsPl {
|
||||
'performanceOverlay.decoder' => 'Dekoder',
|
||||
'performanceOverlay.rawDecoder' => 'Surowy dekoder',
|
||||
'performanceOverlay.tunneling' => 'Tunelowanie',
|
||||
'performanceOverlay.passthrough' => 'Przekazywanie',
|
||||
'performanceOverlay.aspect' => 'Proporcje',
|
||||
'performanceOverlay.rotation' => 'Obrót',
|
||||
'performanceOverlay.dvSource' => 'Źródło DV',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$pt extends Translations$performanceOverla
|
||||
@override String get decoder => 'Decodificador';
|
||||
@override String get rawDecoder => 'Decodificador bruto';
|
||||
@override String get tunneling => 'Túnel';
|
||||
@override String get passthrough => 'Passagem direta';
|
||||
@override String get aspect => 'Aspecto';
|
||||
@override String get rotation => 'Rotação';
|
||||
@override String get dvSource => 'Fonte DV';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsPt {
|
||||
'performanceOverlay.decoder' => 'Decodificador',
|
||||
'performanceOverlay.rawDecoder' => 'Decodificador bruto',
|
||||
'performanceOverlay.tunneling' => 'Túnel',
|
||||
'performanceOverlay.passthrough' => 'Passagem direta',
|
||||
'performanceOverlay.aspect' => 'Aspecto',
|
||||
'performanceOverlay.rotation' => 'Rotação',
|
||||
'performanceOverlay.dvSource' => 'Fonte DV',
|
||||
|
||||
@@ -1813,6 +1813,7 @@ class _Translations$performanceOverlay$ru extends Translations$performanceOverla
|
||||
@override String get decoder => 'Декодер';
|
||||
@override String get rawDecoder => 'Raw-декодер';
|
||||
@override String get tunneling => 'Туннелирование';
|
||||
@override String get passthrough => 'Сквозной вывод';
|
||||
@override String get aspect => 'Соотношение';
|
||||
@override String get rotation => 'Поворот';
|
||||
@override String get dvSource => 'Источник DV';
|
||||
@@ -4312,6 +4313,7 @@ extension on TranslationsRu {
|
||||
'performanceOverlay.decoder' => 'Декодер',
|
||||
'performanceOverlay.rawDecoder' => 'Raw-декодер',
|
||||
'performanceOverlay.tunneling' => 'Туннелирование',
|
||||
'performanceOverlay.passthrough' => 'Сквозной вывод',
|
||||
'performanceOverlay.aspect' => 'Соотношение',
|
||||
'performanceOverlay.rotation' => 'Поворот',
|
||||
'performanceOverlay.dvSource' => 'Источник DV',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$sv extends Translations$performanceOverla
|
||||
@override String get decoder => 'Dekoder';
|
||||
@override String get rawDecoder => 'Rå dekoder';
|
||||
@override String get tunneling => 'Tunnling';
|
||||
@override String get passthrough => 'Genomströmning';
|
||||
@override String get aspect => 'Bildformat';
|
||||
@override String get rotation => 'Rotation';
|
||||
@override String get dvSource => 'DV-källa';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsSv {
|
||||
'performanceOverlay.decoder' => 'Dekoder',
|
||||
'performanceOverlay.rawDecoder' => 'Rå dekoder',
|
||||
'performanceOverlay.tunneling' => 'Tunnling',
|
||||
'performanceOverlay.passthrough' => 'Genomströmning',
|
||||
'performanceOverlay.aspect' => 'Bildformat',
|
||||
'performanceOverlay.rotation' => 'Rotation',
|
||||
'performanceOverlay.dvSource' => 'DV-källa',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$tr extends Translations$performanceOverla
|
||||
@override String get decoder => 'Çözücü';
|
||||
@override String get rawDecoder => 'Ham Çözücü';
|
||||
@override String get tunneling => 'Tünelleme';
|
||||
@override String get passthrough => 'Doğrudan geçiş';
|
||||
@override String get aspect => 'Oran';
|
||||
@override String get rotation => 'Döndürme';
|
||||
@override String get dvSource => 'DV Kaynağı';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsTr {
|
||||
'performanceOverlay.decoder' => 'Çözücü',
|
||||
'performanceOverlay.rawDecoder' => 'Ham Çözücü',
|
||||
'performanceOverlay.tunneling' => 'Tünelleme',
|
||||
'performanceOverlay.passthrough' => 'Doğrudan geçiş',
|
||||
'performanceOverlay.aspect' => 'Oran',
|
||||
'performanceOverlay.rotation' => 'Döndürme',
|
||||
'performanceOverlay.dvSource' => 'DV Kaynağı',
|
||||
|
||||
@@ -1797,6 +1797,7 @@ class _Translations$performanceOverlay$uz extends Translations$performanceOverla
|
||||
@override String get decoder => 'Dekoder';
|
||||
@override String get rawDecoder => 'Ishlov berilmagan dekoder';
|
||||
@override String get tunneling => 'Tunnellash';
|
||||
@override String get passthrough => 'Toʻgʻridan-toʻgʻri oʻtkazish';
|
||||
@override String get aspect => 'Nisbat';
|
||||
@override String get rotation => 'Aylanish';
|
||||
@override String get dvSource => 'DV manbasi';
|
||||
@@ -4292,6 +4293,7 @@ extension on TranslationsUz {
|
||||
'performanceOverlay.decoder' => 'Dekoder',
|
||||
'performanceOverlay.rawDecoder' => 'Ishlov berilmagan dekoder',
|
||||
'performanceOverlay.tunneling' => 'Tunnellash',
|
||||
'performanceOverlay.passthrough' => 'Toʻgʻridan-toʻgʻri oʻtkazish',
|
||||
'performanceOverlay.aspect' => 'Nisbat',
|
||||
'performanceOverlay.rotation' => 'Aylanish',
|
||||
'performanceOverlay.dvSource' => 'DV manbasi',
|
||||
|
||||
@@ -1789,6 +1789,7 @@ class Translations$performanceOverlay$zh extends Translations$performanceOverlay
|
||||
@override String get decoder => '解码器';
|
||||
@override String get rawDecoder => '原始解码器';
|
||||
@override String get tunneling => '隧道';
|
||||
@override String get passthrough => '直通';
|
||||
@override String get aspect => '宽高比';
|
||||
@override String get rotation => '旋转';
|
||||
@override String get dvSource => 'DV 来源';
|
||||
@@ -4282,6 +4283,7 @@ extension on TranslationsZh {
|
||||
'performanceOverlay.decoder' => '解码器',
|
||||
'performanceOverlay.rawDecoder' => '原始解码器',
|
||||
'performanceOverlay.tunneling' => '隧道',
|
||||
'performanceOverlay.passthrough' => '直通',
|
||||
'performanceOverlay.aspect' => '宽高比',
|
||||
'performanceOverlay.rotation' => '旋转',
|
||||
'performanceOverlay.dvSource' => 'DV 来源',
|
||||
|
||||
@@ -1790,6 +1790,7 @@ class _Translations$performanceOverlay$zh_Hant extends Translations$performanceO
|
||||
@override String get decoder => '解碼器';
|
||||
@override String get rawDecoder => '原始解碼器';
|
||||
@override String get tunneling => '通道模式';
|
||||
@override String get passthrough => '直通';
|
||||
@override String get aspect => '寬高比';
|
||||
@override String get rotation => '旋轉角度';
|
||||
@override String get dvSource => 'DV 來源';
|
||||
@@ -4283,6 +4284,7 @@ extension on TranslationsZhHant {
|
||||
'performanceOverlay.decoder' => '解碼器',
|
||||
'performanceOverlay.rawDecoder' => '原始解碼器',
|
||||
'performanceOverlay.tunneling' => '通道模式',
|
||||
'performanceOverlay.passthrough' => '直通',
|
||||
'performanceOverlay.aspect' => '寬高比',
|
||||
'performanceOverlay.rotation' => '旋轉角度',
|
||||
'performanceOverlay.dvSource' => 'DV 來源',
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Dekoder",
|
||||
"rawDecoder": "Rå dekoder",
|
||||
"tunneling": "Tunnling",
|
||||
"passthrough": "Genomströmning",
|
||||
"aspect": "Bildformat",
|
||||
"rotation": "Rotation",
|
||||
"dvSource": "DV-källa",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Çözücü",
|
||||
"rawDecoder": "Ham Çözücü",
|
||||
"tunneling": "Tünelleme",
|
||||
"passthrough": "Doğrudan geçiş",
|
||||
"aspect": "Oran",
|
||||
"rotation": "Döndürme",
|
||||
"dvSource": "DV Kaynağı",
|
||||
|
||||
@@ -1735,6 +1735,7 @@
|
||||
"decoder": "Dekoder",
|
||||
"rawDecoder": "Ishlov berilmagan dekoder",
|
||||
"tunneling": "Tunnellash",
|
||||
"passthrough": "Toʻgʻridan-toʻgʻri oʻtkazish",
|
||||
"aspect": "Nisbat",
|
||||
"rotation": "Aylanish",
|
||||
"dvSource": "DV manbasi",
|
||||
|
||||
@@ -1725,6 +1725,7 @@
|
||||
"decoder": "解碼器",
|
||||
"rawDecoder": "原始解碼器",
|
||||
"tunneling": "通道模式",
|
||||
"passthrough": "直通",
|
||||
"aspect": "寬高比",
|
||||
"rotation": "旋轉角度",
|
||||
"dvSource": "DV 來源",
|
||||
|
||||
@@ -1725,6 +1725,7 @@
|
||||
"decoder": "解码器",
|
||||
"rawDecoder": "原始解码器",
|
||||
"tunneling": "隧道",
|
||||
"passthrough": "直通",
|
||||
"aspect": "宽高比",
|
||||
"rotation": "旋转",
|
||||
"dvSource": "DV 来源",
|
||||
|
||||
+15
-1
@@ -1268,6 +1268,20 @@ class _MainAppState extends State<MainApp> with WidgetsBindingObserver {
|
||||
if (_shutdownStarted) return;
|
||||
_shutdownStarted = true;
|
||||
|
||||
// Hide the window before anything else so the exit reads as an instant
|
||||
// close: the teardown below runs against a still-mounted tree and its
|
||||
// state churn must never be user-visible. Cmd+Q and OS-initiated exits
|
||||
// arrive here directly, so the close-button path is not the only entry.
|
||||
// Bounded — hide() is a platform-channel round trip and a stalled
|
||||
// platform thread must not hold the already-accepted exit open.
|
||||
if (PlatformDetector.isDesktopOS()) {
|
||||
try {
|
||||
await windowManager.hide().timeout(const Duration(seconds: 1));
|
||||
} catch (e, st) {
|
||||
appLogger.w('Failed to hide window before exit teardown', error: e, stackTrace: st);
|
||||
}
|
||||
}
|
||||
|
||||
_syncDebounce?.cancel();
|
||||
await _watchStateSubscription?.cancel();
|
||||
_removeConnectivitySyncListener();
|
||||
@@ -1280,7 +1294,7 @@ class _MainAppState extends State<MainApp> with WidgetsBindingObserver {
|
||||
await TrackerCoordinator.instance.stopPlayback().timeout(const Duration(seconds: 3), onTimeout: () {});
|
||||
TrackerCoordinator.instance.cancelInFlight();
|
||||
|
||||
await _serverManager.disconnectAllGracefully();
|
||||
await _serverManager.shutdown();
|
||||
await Future.wait([
|
||||
httpClient.closeGracefully(drainTimeout: const Duration(seconds: 5)),
|
||||
closeArtworkHttpClientGracefully(),
|
||||
|
||||
@@ -109,6 +109,14 @@ enum MediaBrowserDialect {
|
||||
/// measured 200 on Emby 4.9.5 (the row leaves `/Users/{uid}/Items/Resume`
|
||||
/// while `UserData.PlaybackPositionTicks` survives), and 404 on Jellyfin
|
||||
/// 10.11 for both that spelling and `/UserItems/{id}/HideFromResume`.
|
||||
///
|
||||
/// The dedicated resume route is the *only* listing that honours the flag:
|
||||
/// `/Items?Filters=IsResumable` and `/Shows/NextUp?SeriesId=` keep returning
|
||||
/// hidden rows, and no public filter or `UserData` field exposes the flag
|
||||
/// (#2003), which is why every Emby playback shelf reads that route — see
|
||||
/// [resumeReturnsOnlyStartedItems]. Reporting new playback clears the flag
|
||||
/// server-side, so a removed item legitimately returns once the user resumes
|
||||
/// it.
|
||||
bool get supportsContinueWatchingRemoval => this == MediaBrowserDialect.emby;
|
||||
|
||||
/// `POST /Items/{id}` persists genre and tag edits from the `GenreItems` /
|
||||
@@ -134,17 +142,18 @@ enum MediaBrowserDialect {
|
||||
/// shelf has to be reconstructed client-side from recently played episodes.
|
||||
bool get supportsGlobalNextUp => this == MediaBrowserDialect.jellyfin;
|
||||
|
||||
/// The resume route returns only items with a saved playback position.
|
||||
/// The dedicated resume route returns only items with a saved playback
|
||||
/// position.
|
||||
///
|
||||
/// Jellyfin-only. Measured with one in-progress movie and 30 started series:
|
||||
/// Jellyfin's `/UserItems/Resume` returned exactly the movie, while Emby's
|
||||
/// `/Users/{uid}/Items/Resume` returned 30 rows — the movie plus 29
|
||||
/// zero-position *next* episodes — and `Filters=IsResumable` did not remove
|
||||
/// them. Emby's own UI merges both into one shelf; Plezy models Continue
|
||||
/// Watching and Next Up as separate rows, so the Emby resume leg is filtered
|
||||
/// to genuine progress and the next-up rows come from the Next Up path
|
||||
/// instead. Without the filter a started series occupies both rows and can
|
||||
/// push the real in-progress item out of a limited one.
|
||||
/// Jellyfin-only. Measured on Emby 4.9.5: `/Users/{uid}/Items/Resume`
|
||||
/// returns the genuinely in-progress items *and* one zero-position next
|
||||
/// episode per started series — Emby's own home merges both into one shelf —
|
||||
/// and no `Filters` value removes the extra rows. Plezy models Continue
|
||||
/// Watching and Next Up as separate rows, so the Emby client splits the
|
||||
/// response by `UserData.PlaybackPositionTicks` instead: positive rows feed
|
||||
/// Continue Watching, zero-position episode rows feed Next Up. The route has
|
||||
/// to be read despite the conflation because it is the only listing that
|
||||
/// honours `HideFromResume` — see [supportsContinueWatchingRemoval].
|
||||
bool get resumeReturnsOnlyStartedItems => this == MediaBrowserDialect.jellyfin;
|
||||
|
||||
/// `/Sessions/Playing` and `/Sessions/Playing/Progress` reject a body with no
|
||||
|
||||
@@ -95,3 +95,17 @@ List<String> _hubKeyTokens(String rawKey) {
|
||||
String _compactHubKey(String rawKey) => rawKey.toLowerCase().replaceAll(RegExp(r'[^a-z0-9]+'), '');
|
||||
|
||||
bool _hasTailToken(List<String> tokens, String token) => tokens.isNotEmpty && tokens.last == token;
|
||||
|
||||
/// Index of [previous] within [items] after a content refresh, so visual
|
||||
/// focus can follow the item it was on instead of staying at a stale
|
||||
/// position (a Continue Watching refresh moves the just-played entry to the
|
||||
/// front). The exact item wins; an episode that left the list falls back to
|
||||
/// its series' replacement entry (a finished episode becomes the next
|
||||
/// episode). Returns -1 when neither is present.
|
||||
int followItemIndex(List<MediaItem> items, MediaItem previous) {
|
||||
final exactIndex = items.indexWhere((item) => item.globalKey == previous.globalKey);
|
||||
if (exactIndex != -1) return exactIndex;
|
||||
final seriesKey = previous.seriesGlobalKey;
|
||||
if (seriesKey == null) return -1;
|
||||
return items.indexWhere((item) => item.seriesGlobalKey == seriesKey);
|
||||
}
|
||||
|
||||
@@ -566,7 +566,10 @@ abstract class MediaServerClient {
|
||||
/// artwork drawn with [BoxFit.contain] (clear logos), where the overshoot is
|
||||
/// decoded and thrown away: a 4313×1035 logo asked for at 1200×360 comes back
|
||||
/// 1500×360 covering versus 1200×288 fitting, for ~20-30% more bytes and no
|
||||
/// extra rendered detail. Neither mode crops or changes the aspect ratio.
|
||||
/// extra rendered detail. Neither mode crops, distorts, or upscales past the
|
||||
/// source: Plex requests are built with `upscale=0` so oversized requests
|
||||
/// return native resolution, and Jellyfin's `MaxWidth`/`MaxHeight` never
|
||||
/// enlarge.
|
||||
String thumbnailUrl(String? path, {int? width, int? height, bool cover = true});
|
||||
|
||||
/// Proxy an absolute external image URL through the server's transcoder
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../exceptions/media_server_exceptions.dart';
|
||||
|
||||
import '../media/media_item.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../utils/scroll_utils.dart';
|
||||
|
||||
/// Debounced free-text media search shared by the main search screen and the
|
||||
/// catalog (Explore) search screen: text controller + focus nodes, a 500ms
|
||||
@@ -172,14 +173,15 @@ mixin DebouncedMediaSearch<T extends StatefulWidget> on State<T> {
|
||||
}
|
||||
|
||||
/// The results list both screens render: padded, without keep-alives or
|
||||
/// semantic indexes, one child per entry of [searchResults].
|
||||
Widget buildResultsSliver(NullableIndexedWidgetBuilder itemBuilder) {
|
||||
/// semantic indexes. One child per entry of [searchResults] unless the
|
||||
/// caller renders a filtered view and passes its own [childCount].
|
||||
Widget buildResultsSliver(NullableIndexedWidgetBuilder itemBuilder, {int? childCount}) {
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
itemBuilder,
|
||||
childCount: searchResults.length,
|
||||
childCount: childCount ?? searchResults.length,
|
||||
addAutomaticKeepAlives: false,
|
||||
addSemanticIndexes: false,
|
||||
),
|
||||
@@ -194,6 +196,9 @@ mixin DebouncedMediaSearch<T extends StatefulWidget> on State<T> {
|
||||
if (query.isEmpty) return;
|
||||
if (searchResults.isNotEmpty && !isSearching && query == lastSearchedQuery) {
|
||||
firstResultFocusNode.requestFocus();
|
||||
// Focus-gain auto-scroll is keyboard/D-pad-only, so reveal explicitly:
|
||||
// a touch OSK submit must still jump to the results.
|
||||
scrollContextToCenter(firstResultFocusNode.context);
|
||||
return;
|
||||
}
|
||||
if ((_debounceTimer?.isActive ?? false) || !isSearching) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/// Pre-write snapshot of the viewer's list entry for one anime on a
|
||||
/// series-progress tracker (MAL, AniList), fetched in the same request as the
|
||||
/// episode count so preserving rewatch state costs no extra call (issue #2026).
|
||||
class AnimeListSnapshot {
|
||||
/// Total episodes when the service knows it; null while airing or unknown.
|
||||
final int? episodeCount;
|
||||
|
||||
/// The entry is an in-progress rewatch (AniList `REPEATING`,
|
||||
/// MAL `is_rewatching`).
|
||||
final bool rewatching;
|
||||
|
||||
/// The entry's list status is completed (AniList `COMPLETED`,
|
||||
/// MAL `completed`).
|
||||
final bool completed;
|
||||
|
||||
/// Finished rewatch count (AniList `repeat`, MAL `num_times_rewatched`).
|
||||
/// Zero when the entry is absent or the service omitted the field.
|
||||
final int rewatchCount;
|
||||
|
||||
const AnimeListSnapshot({this.episodeCount, this.rewatching = false, this.completed = false, this.rewatchCount = 0});
|
||||
}
|
||||
@@ -385,7 +385,12 @@ abstract class Player {
|
||||
/// On Android, pass [useExoPlayer] to override the default:
|
||||
/// - true: Use ExoPlayer (default, better hardware support)
|
||||
/// - false: Use MPV (more features, ASS subtitle rendering)
|
||||
factory Player({bool? useExoPlayer}) {
|
||||
///
|
||||
/// [hardwareDecoding] is the session's hardware-decoding setting. The
|
||||
/// Android mpv backend uses it to pick its initial video output — gpu for
|
||||
/// hardware sessions, gpu-next for software ones, where DV reshaping can
|
||||
/// actually happen (see MpvPlayerCore.initialVideoOutput; #2010).
|
||||
factory Player({bool? useExoPlayer, bool hardwareDecoding = true}) {
|
||||
if (Platform.isAndroid) {
|
||||
// Default to ExoPlayer on Android, with MPV as fallback
|
||||
// The caller should pass useExoPlayer based on SettingsService.getUseExoPlayer()
|
||||
@@ -393,7 +398,7 @@ abstract class Player {
|
||||
if (useExo) {
|
||||
return PlayerAndroid(); // ExoPlayer (default)
|
||||
}
|
||||
return PlayerNative(); // MPV fallback
|
||||
return PlayerNative(hardwareDecoding: hardwareDecoding); // MPV fallback
|
||||
}
|
||||
if (Platform.isMacOS || Platform.isIOS) {
|
||||
return PlayerNative();
|
||||
|
||||
@@ -1149,7 +1149,15 @@ abstract class PlayerBase with PlayerStreamControllersMixin implements Player {
|
||||
|
||||
/// mpv loudnorm targeting streaming-style loudness; mirrored by the
|
||||
/// Android ExoPlayer effect parameters in AudioNormalizationEffect.kt.
|
||||
static const _loudnormFilter = 'loudnorm=I=-14:TP=-3:LRA=4';
|
||||
///
|
||||
/// Dynamic-mode loudnorm always outputs float64 at 192 kHz, which made the
|
||||
/// AO open at f64/192k and forced the OS mixer to convert/resample on the
|
||||
/// deadline-critical path (~4x the per-cycle DSP work), underrunning during
|
||||
/// playback startup (#1720). The trailing mpv-native format filter pins the
|
||||
/// chain back to 48 kHz float, so the conversion runs once on the buffered
|
||||
/// decode side. mpv's own `format` filter is used instead of lavfi
|
||||
/// `aformat` because the bundled Linux ffmpeg prunes lavfi filters.
|
||||
static const _loudnormFilter = 'loudnorm=I=-14:TP=-3:LRA=4,format=srate=48000:format=floatp';
|
||||
|
||||
@override
|
||||
Future<void> setAudioNormalization(bool enabled) async {
|
||||
|
||||
@@ -25,7 +25,12 @@ typedef _AudioStateGenerations = ({int passthrough, int normalization, int downm
|
||||
/// MPV-backed player for platforms where AetherEngine is not the native route.
|
||||
class PlayerNative extends PlayerBase {
|
||||
/// Video player on the default mpv channels/core.
|
||||
PlayerNative()
|
||||
///
|
||||
/// [hardwareDecoding] mirrors the session's hardware-decoding setting so
|
||||
/// the Android core can pick its initial video output before mpv
|
||||
/// initializes: gpu for hardware sessions, gpu-next for software ones (see
|
||||
/// MpvPlayerCore.initialVideoOutput; #2010). Other platforms ignore it.
|
||||
PlayerNative({this._hardwareDecoding = true})
|
||||
: methodChannel = const MethodChannel('com.plezy/mpv_player'),
|
||||
eventChannel = const EventChannel('com.plezy/mpv_player/events'),
|
||||
audioOnly = false;
|
||||
@@ -37,7 +42,12 @@ class PlayerNative extends PlayerBase {
|
||||
PlayerNative.audio()
|
||||
: methodChannel = const MethodChannel('com.plezy/mpv_audio_player'),
|
||||
eventChannel = const EventChannel('com.plezy/mpv_audio_player/events'),
|
||||
audioOnly = true;
|
||||
audioOnly = true,
|
||||
_hardwareDecoding = true;
|
||||
|
||||
/// Whether this session intends to hardware-decode; carried on
|
||||
/// `initialize` for the Android core's vo decision.
|
||||
final bool _hardwareDecoding;
|
||||
|
||||
String _dvConversionMode = 'auto';
|
||||
String _dvConversionLog = 'no';
|
||||
@@ -215,7 +225,10 @@ class PlayerNative extends PlayerBase {
|
||||
|
||||
Future<void> _doInitialize() async {
|
||||
try {
|
||||
final result = await invoke<Object>('initialize');
|
||||
// The video core carries the session's decode intent so Android can
|
||||
// choose its vo before mpv_initialize; every other platform's handler
|
||||
// ignores initialize arguments.
|
||||
final result = await invoke<Object>('initialize', audioOnly ? null : {'hardwareDecoding': _hardwareDecoding});
|
||||
if (result != true) {
|
||||
throw Exception('Failed to initialize player');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../widgets/side_navigation_rail.dart';
|
||||
|
||||
/// Dependency aspects for [MainScreenFocusScope].
|
||||
///
|
||||
/// The scope is an [InheritedModel] so the per-sidebar-flip values (`offset`)
|
||||
@@ -119,9 +121,9 @@ class MainScreenFocusScope extends InheritedModel<MainScreenScopeAspect> {
|
||||
/// content box slides during sidebar expansion.
|
||||
///
|
||||
/// The duration/curve MUST mirror the content-slide tween in MainScreen's
|
||||
/// `_buildContent`: pinning works because the two tweens retarget on the same
|
||||
/// frame and track each other exactly, so the animated `-bleed` cancels the
|
||||
/// content translate tick for tick.
|
||||
/// `_buildContent` and the rail's own width animation: pinning works because
|
||||
/// the tweens retarget on the same frame and track each other exactly, so the
|
||||
/// animated `-bleed` cancels the content translate tick for tick.
|
||||
class SideNavigationBleedBuilder extends StatelessWidget {
|
||||
final double targetBleed;
|
||||
final Widget? child;
|
||||
@@ -133,8 +135,8 @@ class SideNavigationBleedBuilder extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return TweenAnimationBuilder<double>(
|
||||
tween: Tween(end: targetBleed),
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOutCubic,
|
||||
duration: SideNavigationRailState.expandDuration,
|
||||
curve: SideNavigationRailState.expandCurve,
|
||||
builder: builder,
|
||||
child: child,
|
||||
);
|
||||
|
||||
@@ -118,10 +118,13 @@ class _CatalogItemDetailScreenState extends State<CatalogItemDetailScreen> {
|
||||
final sources = context.read<CatalogSourcesProvider>();
|
||||
_watchlistSource = sources.watchlistSourceFor(widget.item);
|
||||
// Request needs a connected Seerr, the permission for this kind, and a
|
||||
// tmdb id (Trakt items carry one natively; MAL items get theirs from the
|
||||
// Fribb mapping at row time).
|
||||
// tmdb id. The id is checked at build time from the detail-enriched item,
|
||||
// not here: Trakt items carry one natively and MAL items get theirs from
|
||||
// the Fribb mapping at row time, but Plex Discover's hub/search/related
|
||||
// endpoints ignore includeGuids, so a Plex item's tmdb id only arrives
|
||||
// with the detail fetch (issue #1959).
|
||||
final seerr = sources.seerrSource;
|
||||
if (seerr != null && widget.item.ids.tmdb != null && seerr.canRequest(widget.item.kind)) {
|
||||
if (seerr != null && seerr.canRequest(widget.item.kind)) {
|
||||
_requestSource = seerr;
|
||||
}
|
||||
final source = _watchlistSource;
|
||||
@@ -290,7 +293,11 @@ class _CatalogItemDetailScreenState extends State<CatalogItemDetailScreen> {
|
||||
|
||||
bool get _hasTrailer => _item.trailerUrl?.trim().isNotEmpty ?? false;
|
||||
|
||||
bool get _hasActions => _watchlistSource != null || _requestSource != null || _hasTrailer;
|
||||
/// Whether the Request action can actually render: the tmdb id may only
|
||||
/// arrive with the detail fetch (see initState), so read the enriched item.
|
||||
bool get _canRequest => _requestSource != null && _item.ids.tmdb != null;
|
||||
|
||||
bool get _hasActions => _watchlistSource != null || _canRequest || _hasTrailer;
|
||||
|
||||
bool get _hasLibraryMatches => _libraryMatchFocusNodes.isNotEmpty;
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ import 'search_screen.dart';
|
||||
import 'downloads/downloads_screen.dart';
|
||||
import 'settings/settings_screen.dart';
|
||||
import 'profile/profile_switch_screen.dart';
|
||||
import 'video_player_screen.dart';
|
||||
import 'profile/profile_teardown.dart';
|
||||
import '../services/system_shelf_service.dart';
|
||||
import '../watch_together/watch_together.dart';
|
||||
@@ -88,6 +89,31 @@ bool shouldHandleDesktopRootEscape({
|
||||
return isDesktop && isPhysicalKeyboardEvent && logicalKey == LogicalKeyboardKey.escape && isCurrentRoute && isHomeTab;
|
||||
}
|
||||
|
||||
/// Whether a lifecycle resume should raise the "ask for a profile on open"
|
||||
/// picker.
|
||||
///
|
||||
/// Mobile-only: on desktop `resumed` fires on every window focus gain
|
||||
/// (alt-tab, click), which is far too frequent — the startup prompt is
|
||||
/// sufficient there. Never during active video playback: waking the device
|
||||
/// mid-stream must resume the stream, not stack the root-navigator picker
|
||||
/// over the live player route, whose focus self-heal fights the picker for
|
||||
/// the remote (#2034) — the playback session already belongs to the profile
|
||||
/// that started it.
|
||||
@visibleForTesting
|
||||
bool shouldShowProfileSelectionOnResume({
|
||||
required bool resumedFromBackground,
|
||||
required bool isOffline,
|
||||
required bool alreadyShowingProfileSelection,
|
||||
required bool isMobilePlatform,
|
||||
required bool hasActiveVideoPlayback,
|
||||
}) {
|
||||
return resumedFromBackground &&
|
||||
!isOffline &&
|
||||
!alreadyShowingProfileSelection &&
|
||||
isMobilePlatform &&
|
||||
!hasActiveVideoPlayback;
|
||||
}
|
||||
|
||||
/// Latches whether the app has genuinely left the foreground since the last
|
||||
/// `resumed`, and consumes that fact on the next resume so the "ask for a
|
||||
/// profile on open" rule can re-apply exactly once per backgrounding.
|
||||
@@ -296,6 +322,9 @@ class _MainScreenState extends State<MainScreen>
|
||||
final FocusScopeNode _sidebarFocusScope = FocusScopeNode(debugLabel: 'Sidebar');
|
||||
final FocusScopeNode _contentFocusScope = FocusScopeNode(debugLabel: 'Content');
|
||||
bool _isSidebarFocused = false;
|
||||
// Hover/touch rail expansion is an M3E modal overlay: the rail draws over
|
||||
// the content, so this only drives the scrim behind it — never the
|
||||
// content offset.
|
||||
bool _isSidebarInteractionExpanded = false;
|
||||
bool _isOverlaySheetOpen = false;
|
||||
|
||||
@@ -966,14 +995,16 @@ class _MainScreenState extends State<MainScreen>
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
final shouldPrompt = _profileSelectionResumeGate.consumePromptOn(state);
|
||||
if (shouldPrompt && !_isOffline && !_isShowingProfileSelection) {
|
||||
// Only show profile selection on resume for mobile platforms.
|
||||
// On desktop, "resumed" fires on every window focus gain (alt-tab, click),
|
||||
// which is too frequent — the initial prompt on startup is sufficient.
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
_showProfileSelectionOnResume();
|
||||
}
|
||||
// Always consume: the gate latches backgrounding on every lifecycle event.
|
||||
final resumedFromBackground = _profileSelectionResumeGate.consumePromptOn(state);
|
||||
if (shouldShowProfileSelectionOnResume(
|
||||
resumedFromBackground: resumedFromBackground,
|
||||
isOffline: _isOffline,
|
||||
alreadyShowingProfileSelection: _isShowingProfileSelection,
|
||||
isMobilePlatform: Platform.isAndroid || Platform.isIOS,
|
||||
hasActiveVideoPlayback: VideoPlayerScreenState.activeGlobalKey != null,
|
||||
)) {
|
||||
_showProfileSelectionOnResume();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1214,11 +1245,6 @@ class _MainScreenState extends State<MainScreen>
|
||||
_updateTvosMenuPassthrough();
|
||||
}
|
||||
|
||||
void _handleSidebarInteractionExpandedChanged(bool expanded) {
|
||||
if (_isSidebarInteractionExpanded == expanded) return;
|
||||
setState(() => _isSidebarInteractionExpanded = expanded);
|
||||
}
|
||||
|
||||
void _handleOverlaySheetOpenChanged(bool open) {
|
||||
if (_isOverlaySheetOpen == open) return;
|
||||
_isOverlaySheetOpen = open;
|
||||
@@ -1226,7 +1252,7 @@ class _MainScreenState extends State<MainScreen>
|
||||
}
|
||||
|
||||
double _sideNavigationWidth(BuildContext context, {required bool alwaysExpanded}) {
|
||||
final isExpanded = alwaysExpanded || _isSidebarFocused || _isSidebarInteractionExpanded;
|
||||
final isExpanded = alwaysExpanded || _isSidebarFocused;
|
||||
return isExpanded
|
||||
? SideNavigationRailState.expandedWidth
|
||||
: SideNavigationRailState.collapsedWidthForContext(context);
|
||||
@@ -1771,8 +1797,8 @@ class _MainScreenState extends State<MainScreen>
|
||||
return _handleBackKey(event);
|
||||
},
|
||||
child: TweenAnimationBuilder<double>(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOutCubic,
|
||||
duration: SideNavigationRailState.expandDuration,
|
||||
curve: SideNavigationRailState.expandCurve,
|
||||
tween: Tween<double>(end: targetContentOffset),
|
||||
child: FocusScope(
|
||||
node: _contentFocusScope,
|
||||
@@ -1821,6 +1847,19 @@ class _MainScreenState extends State<MainScreen>
|
||||
child: contentChild!,
|
||||
),
|
||||
),
|
||||
// Scrim behind the modal (hover/touch) rail
|
||||
// overlay; purely visual so content stays
|
||||
// interactive and hover-out still collapses.
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: AnimatedOpacity(
|
||||
opacity: _isSidebarInteractionExpanded ? 1.0 : 0.0,
|
||||
duration: SideNavigationRailState.expandDuration,
|
||||
curve: SideNavigationRailState.expandCurve,
|
||||
child: const ColoredBox(color: Color(0x66000000)),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
@@ -1835,7 +1874,6 @@ class _MainScreenState extends State<MainScreen>
|
||||
isSidebarFocused: _isSidebarFocused,
|
||||
alwaysExpanded: alwaysExpanded,
|
||||
isReconnecting: _isReconnecting,
|
||||
onInteractionExpandedChanged: _handleSidebarInteractionExpandedChanged,
|
||||
onDestinationSelected: (tab) {
|
||||
final restorePreviousFocus = tab == _currentTab;
|
||||
_selectTab(tab);
|
||||
@@ -1846,6 +1884,10 @@ class _MainScreenState extends State<MainScreen>
|
||||
_focusContent(restorePreviousFocus: false);
|
||||
},
|
||||
onNavigateToContent: _focusContent,
|
||||
onInteractionExpandedChanged: (expanded) {
|
||||
if (_isSidebarInteractionExpanded == expanded) return;
|
||||
setState(() => _isSidebarInteractionExpanded = expanded);
|
||||
},
|
||||
onReconnect: _triggerReconnect,
|
||||
),
|
||||
),
|
||||
|
||||
+179
-18
@@ -9,6 +9,7 @@ import '../focus/focusable_text_field.dart';
|
||||
import '../i18n/strings.g.dart';
|
||||
import '../media/ids.dart';
|
||||
import '../media/media_item.dart';
|
||||
import '../media/media_kind.dart';
|
||||
import '../media/media_item_merge.dart';
|
||||
import '../mixins/debounced_media_search.dart';
|
||||
import '../mixins/mounted_set_state_mixin.dart';
|
||||
@@ -21,10 +22,12 @@ import '../utils/app_logger.dart';
|
||||
import '../utils/platform_detector.dart';
|
||||
import '../utils/snackbar_helper.dart';
|
||||
import '../utils/media_server_http_client.dart';
|
||||
import '../utils/search_relevance.dart';
|
||||
import '../widgets/desktop_app_bar.dart';
|
||||
import '../widgets/loading_indicator_box.dart';
|
||||
import '../widgets/search_input_field.dart';
|
||||
import '../widgets/focusable_media_card.dart';
|
||||
import '../widgets/focusable_tab_chip.dart';
|
||||
import '../utils/focus_utils.dart';
|
||||
import 'libraries/state_messages.dart';
|
||||
import 'main_screen.dart';
|
||||
@@ -43,6 +46,17 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
AbortController? _activeSearchAbort;
|
||||
({String query, SearchAggregationResult result})? _pendingSearchOutcome;
|
||||
|
||||
/// Media-kind filter over the current results. Chips and the filtered view
|
||||
/// derive from [_searchCandidates] — the pre-rank pool behind the ranked
|
||||
/// [searchResults] — so a kind ranked out of the "All" top-N still gets a
|
||||
/// chip, and selecting it shows everything the servers returned for it.
|
||||
MediaKind? _selectedKind;
|
||||
List<MediaItem> _searchCandidates = const [];
|
||||
List<MediaKind> _candidateKinds = const [];
|
||||
List<MediaItem>? _rankedKindResults;
|
||||
late final FocusNode _allChipFocusNode = FocusNode(debugLabel: 'SearchKindChipAll');
|
||||
final Map<MediaKind, FocusNode> _kindChipFocusNodes = {};
|
||||
|
||||
HiddenLibrariesProvider? _hiddenLibraries;
|
||||
Set<String> _lastSeenHiddenKeys = const {};
|
||||
|
||||
@@ -56,6 +70,10 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
@override
|
||||
void dispose() {
|
||||
_hiddenLibraries?.removeListener(_onHiddenLibrariesChanged);
|
||||
_allChipFocusNode.dispose();
|
||||
for (final node in _kindChipFocusNodes.values) {
|
||||
node.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -137,6 +155,7 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
void onSearchError(Object error) {
|
||||
_focusResultsForQuery = null;
|
||||
_pendingSearchOutcome = null;
|
||||
_resetKindFilter();
|
||||
final message = error is _SearchUnavailableException
|
||||
? t.errors.searchUnavailable
|
||||
: t.errors.searchFailed(error: error);
|
||||
@@ -147,13 +166,25 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
void onSearchCleared() {
|
||||
_focusResultsForQuery = null;
|
||||
_pendingSearchOutcome = null;
|
||||
_resetKindFilter();
|
||||
}
|
||||
|
||||
@override
|
||||
void onSearchCompleted(String query, List<MediaItem> results) {
|
||||
final outcome = _pendingSearchOutcome;
|
||||
_pendingSearchOutcome = null;
|
||||
if (outcome?.query == query && outcome!.result.failedServerIds.isNotEmpty) {
|
||||
final matched = outcome != null && outcome.query == query ? outcome.result : null;
|
||||
|
||||
// Committed alongside the results the pending setState renders (build has
|
||||
// not run yet): the pre-rank pool the kind chips derive from. A selected
|
||||
// filter survives a refined query as long as its kind still has
|
||||
// candidates; otherwise it falls back to "All".
|
||||
_searchCandidates = matched?.candidates ?? results;
|
||||
_candidateKinds = _kindsIn(_searchCandidates);
|
||||
if (_selectedKind != null && !_candidateKinds.contains(_selectedKind)) _selectedKind = null;
|
||||
_rankedKindResults = _rankKindResults(_selectedKind, query);
|
||||
|
||||
if (matched != null && matched.failedServerIds.isNotEmpty) {
|
||||
showAppSnackBar(context, t.messages.searchPartialResults);
|
||||
}
|
||||
|
||||
@@ -242,18 +273,20 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
final multiServer = context.read<MultiServerProvider>();
|
||||
final updated = await multiServer.getClientForServer(ServerId(serverId))?.fetchItem(source.id);
|
||||
if (!mounted || updated == null) return;
|
||||
final index = searchResults.indexWhere((item) => item.globalKey == source.globalKey);
|
||||
if (index == -1) return;
|
||||
setState(() {
|
||||
// A fresh Jellyfin `fetchItem` carries no library field, and a
|
||||
// library-less row would lose its label (#1970); keep the identity
|
||||
// and library context the search stamped on the original row.
|
||||
searchResults[index] = mergeFetchedMediaItem(
|
||||
fetched: updated,
|
||||
fallbackServerId: ServerId(serverId),
|
||||
existing: source,
|
||||
);
|
||||
});
|
||||
// A fresh Jellyfin `fetchItem` carries no library field, and a
|
||||
// library-less row would lose its label (#1970); keep the identity
|
||||
// and library context the search stamped on the original row.
|
||||
final merged = mergeFetchedMediaItem(fetched: updated, fallbackServerId: ServerId(serverId), existing: source);
|
||||
// The same row can sit in the ranked "All" list, the kind-filtered
|
||||
// view, and the candidate pool; refresh every copy so a later chip
|
||||
// switch cannot resurrect the stale row.
|
||||
var replaced = _replaceByGlobalKey(searchResults, source.globalKey, merged);
|
||||
replaced = _replaceByGlobalKey(_searchCandidates, source.globalKey, merged) || replaced;
|
||||
final filtered = _rankedKindResults;
|
||||
if (filtered != null) {
|
||||
replaced = _replaceByGlobalKey(filtered, source.globalKey, merged) || replaced;
|
||||
}
|
||||
if (replaced) setState(() {});
|
||||
} catch (e) {
|
||||
appLogger.d('Search item refresh skipped for ${source.globalKey}', error: e);
|
||||
}
|
||||
@@ -264,12 +297,136 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
MainScreenFocusScope.focusSidebarOf(context);
|
||||
}
|
||||
|
||||
/// Chip display order. `folder`/`unknown` are never search kinds, and
|
||||
/// `clip`/`photo` rows (rare Plex extras) stay reachable under "All"
|
||||
/// without a chip of their own.
|
||||
static const List<MediaKind> _kindFilterOrder = [
|
||||
MediaKind.movie,
|
||||
MediaKind.show,
|
||||
MediaKind.season,
|
||||
MediaKind.episode,
|
||||
MediaKind.artist,
|
||||
MediaKind.album,
|
||||
MediaKind.track,
|
||||
MediaKind.collection,
|
||||
MediaKind.playlist,
|
||||
];
|
||||
|
||||
static List<MediaKind> _kindsIn(List<MediaItem> candidates) {
|
||||
if (candidates.isEmpty) return const [];
|
||||
final present = {for (final item in candidates) item.kind};
|
||||
return [
|
||||
for (final kind in _kindFilterOrder)
|
||||
if (present.contains(kind)) kind,
|
||||
];
|
||||
}
|
||||
|
||||
static bool _replaceByGlobalKey(List<MediaItem> items, String globalKey, MediaItem replacement) {
|
||||
final index = items.indexWhere((item) => item.globalKey == globalKey);
|
||||
if (index == -1) return false;
|
||||
items[index] = replacement;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// The list the results sliver renders: the aggregation's ranked list, or
|
||||
/// the selected kind's candidates re-ranked with the full display budget.
|
||||
List<MediaItem> get _visibleResults => _rankedKindResults ?? searchResults;
|
||||
|
||||
/// A single-kind result set has nothing to filter.
|
||||
bool get _showKindChips => _candidateKinds.length > 1;
|
||||
|
||||
List<MediaItem>? _rankKindResults(MediaKind? kind, String query) {
|
||||
if (kind == null) return null;
|
||||
return rankMediaSearchResults(
|
||||
[
|
||||
for (final item in _searchCandidates)
|
||||
if (item.kind == kind) item,
|
||||
],
|
||||
query,
|
||||
limit: defaultMediaSearchLimit,
|
||||
);
|
||||
}
|
||||
|
||||
void _selectKindFilter(MediaKind? kind) {
|
||||
if (kind == _selectedKind) return;
|
||||
setState(() {
|
||||
_selectedKind = kind;
|
||||
_rankedKindResults = _rankKindResults(kind, lastSearchedQuery);
|
||||
});
|
||||
}
|
||||
|
||||
void _resetKindFilter() {
|
||||
_selectedKind = null;
|
||||
_searchCandidates = const [];
|
||||
_candidateKinds = const [];
|
||||
_rankedKindResults = null;
|
||||
}
|
||||
|
||||
FocusNode _chipFocusNode(MediaKind? kind) {
|
||||
if (kind == null) return _allChipFocusNode;
|
||||
return _kindChipFocusNodes.putIfAbsent(kind, () => FocusNode(debugLabel: 'SearchKindChip_${kind.id}'));
|
||||
}
|
||||
|
||||
/// D-pad landing point for the chip row: the chip that is currently active.
|
||||
void _focusKindChips() => _chipFocusNode(_selectedKind).requestFocus();
|
||||
|
||||
void _focusFirstResult() {
|
||||
if (_visibleResults.isNotEmpty) firstResultFocusNode.requestFocus();
|
||||
}
|
||||
|
||||
String _kindFilterLabel(MediaKind kind) => switch (kind) {
|
||||
MediaKind.movie => t.libraries.groupings.movies,
|
||||
MediaKind.show => t.libraries.groupings.shows,
|
||||
MediaKind.season => t.libraries.groupings.seasons,
|
||||
MediaKind.episode => t.libraries.groupings.episodes,
|
||||
MediaKind.artist => t.libraries.groupings.artists,
|
||||
MediaKind.album => t.libraries.groupings.albums,
|
||||
MediaKind.track => t.libraries.groupings.tracks,
|
||||
MediaKind.collection => t.libraries.tabs.collections,
|
||||
MediaKind.playlist => t.libraries.tabs.playlists,
|
||||
// Unreachable: excluded from _kindFilterOrder.
|
||||
MediaKind.clip || MediaKind.photo || MediaKind.folder || MediaKind.unknown => kind.id,
|
||||
};
|
||||
|
||||
Widget _buildKindFilterChips() {
|
||||
// Chips trap RIGHT to keep focus inside the strip (see
|
||||
// FocusableChipStateMixin), so left/right neighbors are wired explicitly,
|
||||
// like every other tab-chip strip.
|
||||
final kinds = <MediaKind?>[null, ..._candidateKinds];
|
||||
return SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: TabChipStrip(
|
||||
children: [
|
||||
for (final (index, kind) in kinds.indexed) ...[
|
||||
if (index > 0) const SizedBox(width: 8),
|
||||
FocusableTabChip(
|
||||
label: kind == null ? t.libraries.groupings.all : _kindFilterLabel(kind),
|
||||
isSelected: _selectedKind == kind,
|
||||
focusNode: _chipFocusNode(kind),
|
||||
onSelect: () => _selectKindFilter(kind),
|
||||
onNavigateLeft: index == 0 ? _navigateToSidebar : () => _chipFocusNode(kinds[index - 1]).requestFocus(),
|
||||
onNavigateRight: index < kinds.length - 1
|
||||
? () => _chipFocusNode(kinds[index + 1]).requestFocus()
|
||||
: null,
|
||||
onNavigateUp: focusSearchInput,
|
||||
onNavigateDown: _focusFirstResult,
|
||||
onBack: _navigateToSidebar,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildResultsList(BuildContext context) {
|
||||
final multiServer = context.watch<MultiServerProvider>();
|
||||
final libraries = context.watch<LibrariesProvider>();
|
||||
final showServerName = multiServer.totalServerCount > 1;
|
||||
return buildResultsSliver((context, index) {
|
||||
final item = searchResults[index];
|
||||
final visible = _visibleResults;
|
||||
return buildResultsSliver(childCount: visible.length, (context, index) {
|
||||
final item = visible[index];
|
||||
return FocusableMediaCard(
|
||||
key: Key(item.globalKey),
|
||||
item: item,
|
||||
@@ -279,7 +436,7 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
onRefresh: updateItem,
|
||||
onListRefresh: refresh,
|
||||
onNavigateLeft: _navigateToSidebar,
|
||||
onNavigateUp: index == 0 ? focusSearchInput : null,
|
||||
onNavigateUp: index == 0 ? (_showKindChips ? _focusKindChips : focusSearchInput) : null,
|
||||
showServerName: showServerName,
|
||||
libraryName: libraries.libraryLabelFor(item),
|
||||
);
|
||||
@@ -302,7 +459,9 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
hintText: t.search.hint,
|
||||
tvTextInputController: _tvTextInputController,
|
||||
onNavigateLeft: _navigateToSidebar,
|
||||
onNavigateDown: searchResults.isNotEmpty && !isSearching ? firstResultFocusNode.requestFocus : null,
|
||||
onNavigateDown: searchResults.isNotEmpty && !isSearching
|
||||
? (_showKindChips ? _focusKindChips : firstResultFocusNode.requestFocus)
|
||||
: null,
|
||||
onEditingComplete: PlatformDetector.isTV() ? handleSearchSubmit : null,
|
||||
onBack: () {
|
||||
if (searchController.text.isNotEmpty) {
|
||||
@@ -337,8 +496,10 @@ class _SearchScreenState extends State<SearchScreen>
|
||||
iconSize: 80,
|
||||
),
|
||||
)
|
||||
else
|
||||
else ...[
|
||||
if (_showKindChips) _buildKindFilterChips(),
|
||||
_buildResultsList(context),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -84,6 +84,7 @@ import '../utils/platform_detector.dart';
|
||||
import '../utils/provider_extensions.dart';
|
||||
import '../utils/snackbar_helper.dart';
|
||||
import '../utils/stream_buffer_sizing.dart';
|
||||
import '../utils/route_visibility.dart';
|
||||
import '../utils/video_player_navigation.dart';
|
||||
import '../utils/android_exit_diagnostics.dart';
|
||||
import 'video_player/completion_latch.dart';
|
||||
@@ -1396,7 +1397,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
if (!mounted || generation != _playerInitializationGeneration) return;
|
||||
|
||||
initPhase = 'creating player';
|
||||
final currentPlayer = Player(useExoPlayer: useExoPlayer);
|
||||
final currentPlayer = Player(useExoPlayer: useExoPlayer, hardwareDecoding: enableHardwareDecoding);
|
||||
attemptPlayer = currentPlayer;
|
||||
if (!mounted || generation != _playerInitializationGeneration) return;
|
||||
if (Platform.isAndroid && useExoPlayer) {
|
||||
@@ -2102,13 +2103,20 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
/// `_screenFocusNode.hasFocus` is true when the node itself OR any
|
||||
/// descendant has focus, so internal movement between child controls
|
||||
/// does NOT trigger this.
|
||||
///
|
||||
/// Reclaim only while this screen is the app's top visible route. The
|
||||
/// build's `canRequestFocus` already tracks routes pushed above the player
|
||||
/// on its own (profile-session) navigator, but a route on an ancestor
|
||||
/// navigator — the root-navigator profile picker on resume — leaves it
|
||||
/// true, and reclaiming then yanks the remote off the visible route,
|
||||
/// wedging D-pad devices (#2034).
|
||||
void _onScreenFocusChanged() {
|
||||
if (_reclaimingFocus) return;
|
||||
if (!_screenFocusNode.hasFocus && mounted && !_isExiting.value) {
|
||||
_reclaimingFocus = true;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_reclaimingFocus = false;
|
||||
if (mounted && !_isExiting.value && !_screenFocusNode.hasFocus) {
|
||||
if (mounted && !_isExiting.value && !_screenFocusNode.hasFocus && isRouteChainCurrent(context)) {
|
||||
_screenFocusNode.requestFocus();
|
||||
}
|
||||
});
|
||||
@@ -2124,7 +2132,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
event,
|
||||
focusNode: _screenFocusNode,
|
||||
playerReady: _isPlayerInitialized && player != null && _hasFirstFrame.value,
|
||||
isCurrentRoute: ModalRoute.of(context)?.isCurrent == true,
|
||||
isCurrentRoute: isRouteChainCurrent(context),
|
||||
isAppleTV: PlatformDetector.isAppleTV(),
|
||||
);
|
||||
return false;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../focus/focus_navigation_intent.dart';
|
||||
import '../focus/input_mode_tracker.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../utils/key_event_simulator.dart' as key_sim;
|
||||
@@ -19,25 +17,33 @@ class AppleTvRemotePlayPauseAction {
|
||||
}
|
||||
|
||||
const double _axisSwitchDominanceRatio = 1.5;
|
||||
const Duration _swipeRepeatInterval = Duration(milliseconds: 140);
|
||||
// Device-tuned on an Apple TV 4K against native focus feel: UIKit's
|
||||
// indirect-touch acceleration means roughly half an item's extent of
|
||||
// reported travel already reads as "one deliberate swipe".
|
||||
const double _swipeExtentGain = 0.55;
|
||||
const double _maxSwipeThreshold = 180;
|
||||
// Retuned against the native tvOS focus engine, measured on-device on an
|
||||
// Apple TV 4K (issue #2006), poster grid 230x345:
|
||||
// - one focus step per ~400pt of indirect-touch travel (UITouch points — the
|
||||
// same accelerated space the engine reports on this channel), measured
|
||||
// identical for the 230pt and 345pt axes: the step distance does NOT
|
||||
// follow the focused item's extent;
|
||||
// - steps repeat every ~60ms (native median) during a committed drag;
|
||||
// - a fast lift glides on: one extra step past ~2000pt/s, two past ~8000pt/s,
|
||||
// landing within ~130ms of the lift.
|
||||
// Small extents (chips, list rows) are unmeasured; the fixed step distance
|
||||
// extrapolates the measured axis-independence to them.
|
||||
const Duration _swipeRepeatInterval = Duration(milliseconds: 60);
|
||||
const double _swipeStepDistance = 400;
|
||||
const Duration _glideStepInterval = Duration(milliseconds: 70);
|
||||
const double _glideVelocity = 2000;
|
||||
const double _glideDoubleStepVelocity = 8000;
|
||||
const Duration _liftVelocityWindow = Duration(milliseconds: 100);
|
||||
|
||||
/// Bridges tvOS touch-surface events from Apple's iOS Remote app into the
|
||||
/// focus-tree key events Plezy already handles for D-pad navigation.
|
||||
/// Bridges tvOS touch-surface events (Siri Remote and Apple's iOS Remote app)
|
||||
/// into the focus-tree key events Plezy already handles for D-pad navigation.
|
||||
///
|
||||
/// Like the native focus engine, the pan distance for one focus step follows
|
||||
/// the focused control's on-screen size: small chips traverse quickly, large
|
||||
/// cards demand a longer swipe. When no usable geometry exists (a bare focus
|
||||
/// scope, the video player's screen-sized catch-all surfaces) the step falls
|
||||
/// back to a fixed threshold.
|
||||
/// One focus step costs a fixed [swipeThreshold] of touch travel regardless
|
||||
/// of the focused control's size, steps repeat on a short cadence during a
|
||||
/// sustained drag, and a fast lift "glides" one or two further steps — all
|
||||
/// three tuned to on-device measurements of the native focus engine.
|
||||
class AppleTvRemoteTouchService {
|
||||
static const String _channelName = 'flutter/gamepadtouchevent';
|
||||
static const double defaultSwipeThreshold = 180;
|
||||
static const double defaultMinSwipeThreshold = 50;
|
||||
|
||||
static final AppleTvRemoteTouchService instance = AppleTvRemoteTouchService();
|
||||
|
||||
@@ -50,13 +56,8 @@ class AppleTvRemoteTouchService {
|
||||
final StreamController<AppleTvRemotePlayPauseAction> _playPauseController =
|
||||
StreamController<AppleTvRemotePlayPauseAction>.broadcast();
|
||||
|
||||
/// Fallback step distance when no usable focus geometry exists.
|
||||
/// Touch travel that prices one focus step.
|
||||
final double swipeThreshold;
|
||||
final double minSwipeThreshold;
|
||||
|
||||
/// Global rect of the control that prices a focus step, or null when no
|
||||
/// usable geometry exists. Injected so tests can supply fake geometry.
|
||||
final Rect? Function() _focusedItemRect;
|
||||
|
||||
bool _listening = false;
|
||||
bool _nativeKeyHandlerRegistered = false;
|
||||
@@ -67,19 +68,18 @@ class AppleTvRemoteTouchService {
|
||||
double _anchorY = 0;
|
||||
_SwipeAxis? _lastSwipeAxis;
|
||||
DateTime? _lastSwipeAt;
|
||||
LogicalKeyboardKey? _lastSwipeKey;
|
||||
final List<({DateTime t, double x, double y})> _moveSamples = [];
|
||||
Timer? _glideTimer;
|
||||
|
||||
AppleTvRemoteTouchService({
|
||||
void Function(LogicalKeyboardKey logicalKey)? simulateKeyPress,
|
||||
VoidCallback? scheduleFrame,
|
||||
DateTime Function()? now,
|
||||
this.swipeThreshold = defaultSwipeThreshold,
|
||||
this.minSwipeThreshold = defaultMinSwipeThreshold,
|
||||
Rect? Function()? focusedItemRect,
|
||||
}) : assert(minSwipeThreshold > 0 && minSwipeThreshold <= _maxSwipeThreshold),
|
||||
_simulateKeyPress = simulateKeyPress ?? key_sim.simulateKeyPress,
|
||||
this.swipeThreshold = _swipeStepDistance,
|
||||
}) : _simulateKeyPress = simulateKeyPress ?? key_sim.simulateKeyPress,
|
||||
_scheduleFrame = scheduleFrame ?? key_sim.scheduleFrameIfIdle,
|
||||
_now = now ?? DateTime.now,
|
||||
_focusedItemRect = focusedItemRect ?? _defaultFocusedItemRect,
|
||||
_duplicateInputGuard = GamepadDuplicateInputGuard(now: now);
|
||||
|
||||
Stream<AppleTvRemotePlayPauseAction> get playPauseActions => _playPauseController.stream;
|
||||
@@ -95,6 +95,7 @@ class AppleTvRemoteTouchService {
|
||||
void stop() {
|
||||
if (!_listening) return;
|
||||
_channel.setMessageHandler(null);
|
||||
_cancelGlide();
|
||||
_unregisterNativeKeyHandler();
|
||||
_duplicateInputGuard.clear();
|
||||
_resetTouch();
|
||||
@@ -134,12 +135,12 @@ class AppleTvRemoteTouchService {
|
||||
if (position == null) return;
|
||||
_moveTouch(position.$1, position.$2);
|
||||
case 'ended':
|
||||
// Drop the lift frame: the final position on touchesEnded is
|
||||
// unreliable on the Siri Remote — a natural finger pivot during
|
||||
// lift can register enough delta from the post-last-swipe anchor
|
||||
// to fire a stray opposite-direction swipe. In-gesture 'move'
|
||||
// events have already covered any legitimate swipe motion.
|
||||
_resetTouch();
|
||||
// Drop the lift frame position: it is unreliable on the Siri Remote —
|
||||
// a natural finger pivot during lift can register enough delta from
|
||||
// the post-last-swipe anchor to fire a stray opposite-direction
|
||||
// swipe. The gesture's recorded move samples still price a post-lift
|
||||
// glide.
|
||||
_endTouch();
|
||||
case 'cancelled':
|
||||
_resetTouch();
|
||||
case 'play_pause':
|
||||
@@ -167,6 +168,7 @@ class AppleTvRemoteTouchService {
|
||||
}
|
||||
|
||||
void _startTouch(double x, double y) {
|
||||
_cancelGlide();
|
||||
_touchActive = true;
|
||||
_startX = x;
|
||||
_startY = y;
|
||||
@@ -174,6 +176,10 @@ class AppleTvRemoteTouchService {
|
||||
_anchorY = y;
|
||||
_lastSwipeAxis = null;
|
||||
_lastSwipeAt = null;
|
||||
_lastSwipeKey = null;
|
||||
_moveSamples
|
||||
..clear()
|
||||
..add((t: _now(), x: x, y: y));
|
||||
}
|
||||
|
||||
void _moveTouch(double x, double y) {
|
||||
@@ -186,6 +192,7 @@ class AppleTvRemoteTouchService {
|
||||
final deltaY = _anchorY - y;
|
||||
|
||||
final now = _now();
|
||||
_recordMoveSample(now, x, y);
|
||||
final lastSwipeAt = _lastSwipeAt;
|
||||
if (lastSwipeAt != null && now.difference(lastSwipeAt) < _swipeRepeatInterval) {
|
||||
// Travel during the repeat cooldown never counts toward the next step:
|
||||
@@ -204,8 +211,7 @@ class AppleTvRemoteTouchService {
|
||||
return;
|
||||
}
|
||||
|
||||
final thresholds = _stepThresholds();
|
||||
final axis = _resolveSwipeAxis(x: x, y: y, deltaX: deltaX, deltaY: deltaY, thresholds: thresholds);
|
||||
final axis = _resolveSwipeAxis(x: x, y: y, deltaX: deltaX, deltaY: deltaY);
|
||||
if (axis == null) return;
|
||||
|
||||
final logicalKey = axis == _SwipeAxis.horizontal
|
||||
@@ -217,36 +223,33 @@ class AppleTvRemoteTouchService {
|
||||
source: 'swipe',
|
||||
detail:
|
||||
'dx=${_formatDouble(deltaX)} dy=${_formatDouble(deltaY)} '
|
||||
'thX=${_formatDouble(thresholds.horizontal)} thY=${_formatDouble(thresholds.vertical)}',
|
||||
'th=${_formatDouble(swipeThreshold)}',
|
||||
);
|
||||
_anchorX = x;
|
||||
_anchorY = y;
|
||||
_lastSwipeAxis = axis;
|
||||
_lastSwipeAt = now;
|
||||
_lastSwipeKey = logicalKey;
|
||||
}
|
||||
|
||||
/// Resolves which axis, if any, crossed its step threshold.
|
||||
///
|
||||
/// Distances are normalized by the per-axis thresholds so that, like the
|
||||
/// native focus engine, a wide-flat control steps vertically once the finger
|
||||
/// covers the item's height even while the raw horizontal delta is larger.
|
||||
/// Resolves which axis, if any, covered a full step distance, with
|
||||
/// hysteresis so incidental drift does not zig-zag an established swipe.
|
||||
_SwipeAxis? _resolveSwipeAxis({
|
||||
required double x,
|
||||
required double y,
|
||||
required double deltaX,
|
||||
required double deltaY,
|
||||
required ({double horizontal, double vertical}) thresholds,
|
||||
}) {
|
||||
final progressX = deltaX.abs() / thresholds.horizontal;
|
||||
final progressY = deltaY.abs() / thresholds.vertical;
|
||||
final progressX = deltaX.abs() / swipeThreshold;
|
||||
final progressY = deltaY.abs() / swipeThreshold;
|
||||
if (progressX < 1 && progressY < 1) return null;
|
||||
|
||||
final candidate = progressX >= progressY ? _SwipeAxis.horizontal : _SwipeAxis.vertical;
|
||||
final lastAxis = _lastSwipeAxis;
|
||||
if (lastAxis == null || candidate == lastAxis) return candidate;
|
||||
|
||||
final totalProgressX = (_startX - x).abs() / thresholds.horizontal;
|
||||
final totalProgressY = (_startY - y).abs() / thresholds.vertical;
|
||||
final totalProgressX = (_startX - x).abs() / swipeThreshold;
|
||||
final totalProgressY = (_startY - y).abs() / swipeThreshold;
|
||||
final candidateTotal = _axisValue(candidate, totalProgressX, totalProgressY);
|
||||
final lastAxisTotal = _axisValue(lastAxis, totalProgressX, totalProgressY);
|
||||
final candidateSegment = _axisValue(candidate, progressX, progressY);
|
||||
@@ -263,31 +266,61 @@ class AppleTvRemoteTouchService {
|
||||
return axis == _SwipeAxis.horizontal ? horizontal : vertical;
|
||||
}
|
||||
|
||||
({double horizontal, double vertical}) _stepThresholds() {
|
||||
final rect = _focusedItemRect();
|
||||
if (rect == null) return (horizontal: swipeThreshold, vertical: swipeThreshold);
|
||||
return (horizontal: _thresholdForExtent(rect.width), vertical: _thresholdForExtent(rect.height));
|
||||
void _recordMoveSample(DateTime now, double x, double y) {
|
||||
_moveSamples.add((t: now, x: x, y: y));
|
||||
final cutoff = now.subtract(_liftVelocityWindow);
|
||||
while (_moveSamples.isNotEmpty && _moveSamples.first.t.isBefore(cutoff)) {
|
||||
_moveSamples.removeAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
double _thresholdForExtent(double extent) {
|
||||
if (!extent.isFinite || extent <= 0) return swipeThreshold;
|
||||
return (extent * _swipeExtentGain).clamp(minSwipeThreshold, _maxSwipeThreshold).toDouble();
|
||||
void _endTouch() {
|
||||
final glideKey = _lastSwipeKey;
|
||||
final glideSteps = _liftGlideSteps();
|
||||
_resetTouch();
|
||||
if (glideKey != null && glideSteps > 0) _startGlide(glideKey, glideSteps);
|
||||
}
|
||||
|
||||
/// Reads the primary focus geometry, rejecting nodes whose rect cannot
|
||||
/// meaningfully price a step: bare scopes (nothing real is focused yet) and
|
||||
/// the player's catch-all [DirectionalShortcutFocusNode] surfaces are
|
||||
/// screen-sized, and a detached or unlaid-out node has no rect at all.
|
||||
static Rect? _defaultFocusedItemRect() {
|
||||
final node = FocusManager.instance.primaryFocus;
|
||||
if (node == null || node is FocusScopeNode || node is DirectionalShortcutFocusNode) return null;
|
||||
final context = node.context;
|
||||
if (context == null) return null;
|
||||
final renderObject = context.findRenderObject();
|
||||
if (renderObject is! RenderBox || !renderObject.attached || !renderObject.hasSize) return null;
|
||||
final rect = node.rect;
|
||||
if (!rect.isFinite || rect.isEmpty) return null;
|
||||
return rect;
|
||||
/// Prices the post-lift glide from the finger's velocity over the last
|
||||
/// [_liftVelocityWindow] of the gesture, measured along the established
|
||||
/// swipe axis. A gesture that never produced a step has no established
|
||||
/// direction and never glides; neither does a lift moving against the last
|
||||
/// step (a reversal pivot).
|
||||
int _liftGlideSteps() {
|
||||
final key = _lastSwipeKey;
|
||||
final axis = _lastSwipeAxis;
|
||||
if (key == null || axis == null || _moveSamples.length < 2) return 0;
|
||||
final first = _moveSamples.first;
|
||||
final last = _moveSamples.last;
|
||||
final dt = last.t.difference(first.t).inMicroseconds / Duration.microsecondsPerSecond;
|
||||
if (dt <= 0) return 0;
|
||||
final velocity = axis == _SwipeAxis.horizontal ? (last.x - first.x) / dt : (last.y - first.y) / dt;
|
||||
final towardKey = axis == _SwipeAxis.horizontal
|
||||
? (velocity < 0 ? LogicalKeyboardKey.arrowLeft : LogicalKeyboardKey.arrowRight)
|
||||
: (velocity < 0 ? LogicalKeyboardKey.arrowUp : LogicalKeyboardKey.arrowDown);
|
||||
if (towardKey != key) return 0;
|
||||
final speed = velocity.abs();
|
||||
if (speed < _glideVelocity) return 0;
|
||||
return speed >= _glideDoubleStepVelocity ? 2 : 1;
|
||||
}
|
||||
|
||||
void _startGlide(LogicalKeyboardKey key, int steps) {
|
||||
_cancelGlide();
|
||||
var remaining = steps;
|
||||
_log('start glide key=${_keyName(key)} steps=$steps');
|
||||
_glideTimer = Timer.periodic(_glideStepInterval, (timer) {
|
||||
_emitKey(key, source: 'glide');
|
||||
remaining -= 1;
|
||||
if (remaining <= 0) {
|
||||
timer.cancel();
|
||||
if (identical(_glideTimer, timer)) _glideTimer = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _cancelGlide() {
|
||||
_glideTimer?.cancel();
|
||||
_glideTimer = null;
|
||||
}
|
||||
|
||||
bool _emitKey(LogicalKeyboardKey logicalKey, {required String source, String? detail}) {
|
||||
@@ -307,6 +340,8 @@ class AppleTvRemoteTouchService {
|
||||
_touchActive = false;
|
||||
_lastSwipeAxis = null;
|
||||
_lastSwipeAt = null;
|
||||
_lastSwipeKey = null;
|
||||
_moveSamples.clear();
|
||||
}
|
||||
|
||||
void _registerNativeKeyHandler() {
|
||||
|
||||
@@ -49,8 +49,14 @@ typedef LibraryAggregationResult = ({
|
||||
Set<String> cancelledServerIds,
|
||||
Set<String> failedServerIds,
|
||||
});
|
||||
|
||||
/// `items` is the ranked list trimmed to the caller's limit; `candidates` is
|
||||
/// the full post-hidden-filter, pre-rank pool behind it, so a caller can
|
||||
/// re-rank a subset (e.g. one media kind) without a kind ranked out of
|
||||
/// `items` disappearing from its own filter.
|
||||
typedef SearchAggregationResult = ({
|
||||
List<MediaItem> items,
|
||||
List<MediaItem> candidates,
|
||||
Set<String> succeededServerIds,
|
||||
Set<String> cancelledServerIds,
|
||||
Set<String> failedServerIds,
|
||||
@@ -712,6 +718,7 @@ class DataAggregationService {
|
||||
if (query.trim().isEmpty) {
|
||||
return (
|
||||
items: const <MediaItem>[],
|
||||
candidates: const <MediaItem>[],
|
||||
succeededServerIds: const <String>{},
|
||||
cancelledServerIds: const <String>{},
|
||||
failedServerIds: const <String>{},
|
||||
@@ -723,6 +730,7 @@ class DataAggregationService {
|
||||
if (clients.isEmpty) {
|
||||
return (
|
||||
items: const <MediaItem>[],
|
||||
candidates: const <MediaItem>[],
|
||||
succeededServerIds: const <String>{},
|
||||
cancelledServerIds: const <String>{},
|
||||
failedServerIds: const <String>{},
|
||||
@@ -764,6 +772,7 @@ class DataAggregationService {
|
||||
|
||||
return (
|
||||
items: items,
|
||||
candidates: visible,
|
||||
succeededServerIds: fetched.succeededServerIds,
|
||||
cancelledServerIds: fetched.cancelledServerIds,
|
||||
failedServerIds: fetched.failedServerIds,
|
||||
|
||||
@@ -155,8 +155,11 @@ class DevicePerformance {
|
||||
cache.maximumSize = 1000;
|
||||
cache.maximumSizeBytes = 150 << 20; // 150MB
|
||||
} else if (isReduced) {
|
||||
// Tiles decode at full TV DPR even on this tier (#2020), so the byte
|
||||
// budget matches the TV baseline. The display budget factor is pinned
|
||||
// to 1.0 here, keeping the ceiling fixed.
|
||||
cache.maximumSize = 400;
|
||||
cache.maximumSizeBytes = 48 << 20; // 48MB
|
||||
cache.maximumSizeBytes = 64 << 20; // 64MB
|
||||
} else if (PlatformDetector.isTV()) {
|
||||
// TV boxes share limited RAM with 4K video decode buffers. The byte
|
||||
// budget follows the display budget: 4K-surface artwork carries up to
|
||||
|
||||
@@ -162,10 +162,13 @@ const _episodeQueuePageSize = 200;
|
||||
/// improving (0.65s at 3, 0.56s at both 4 and 6).
|
||||
const _seriesLastPlayedConcurrency = 4;
|
||||
|
||||
/// Ceiling on how many series [_attachSeriesLastPlayed] dates in one call. Sits
|
||||
/// just above `DiscoverProvider`'s 21-row continue-watching probe so the home
|
||||
/// shelf is always fully dated, and caps the uncapped `count: null` shelf, whose
|
||||
/// Next Up half is limited only by how many series the user has started.
|
||||
/// Ceiling on how many series [_attachSeriesLastPlayed] dates in one call and
|
||||
/// on how many series [_fetchRecentlyPlayedSeriesIds] returns — which also
|
||||
/// bounds the Emby Next Up shelf, since [_stampEmbyNextUpRows] drops rows the
|
||||
/// scan cannot vouch for. Sits just above `DiscoverProvider`'s 21-row
|
||||
/// continue-watching probe so the home shelf is always fully dated, and caps
|
||||
/// the uncapped `count: null` shelf, whose Next Up half is limited only by how
|
||||
/// many series the user has started.
|
||||
const _seriesLastPlayedLookupLimit = 24;
|
||||
|
||||
/// Per-phase budget for one [_fetchSeriesLastPlayed] lookup.
|
||||
@@ -177,18 +180,28 @@ const _seriesLastPlayedLookupLimit = 24;
|
||||
/// shelf is better off unstamped than waiting on the 10s/120s shared defaults.
|
||||
const _seriesLastPlayedRequestTimeout = Duration(seconds: 3);
|
||||
|
||||
/// Hard ceiling on [_attachSeriesLastPlayed] and on the reconstructed Next Up
|
||||
/// pass, recency probe included. On expiry it aborts whatever is in flight, so it
|
||||
/// bounds the whole pass regardless of how many batches remain or which request
|
||||
/// phase a lookup is stuck in — the per-request timeouts alone cannot, because
|
||||
/// each applies to the connect and receive phases independently. Two orders of
|
||||
/// magnitude under the 10s-connect/120s-receive defaults the single unscoped scan
|
||||
/// ran with, so a stalled endpoint cannot make the scoped form slower than the
|
||||
/// query it fixes.
|
||||
/// Hard ceiling on one [_attachSeriesLastPlayed] pass. On expiry it aborts
|
||||
/// whatever is in flight, so it bounds the whole pass regardless of how many
|
||||
/// batches remain or which request phase a lookup is stuck in — the
|
||||
/// per-request timeouts alone cannot, because each applies to the connect and
|
||||
/// receive phases independently. Two orders of magnitude under the
|
||||
/// 10s-connect/120s-receive defaults the single unscoped scan ran with, so a
|
||||
/// stalled endpoint cannot make the scoped form slower than the query it
|
||||
/// fixes.
|
||||
const _seriesLastPlayedBudget = Duration(seconds: 4);
|
||||
|
||||
const _childrenPageSize = 500;
|
||||
const _pagedListPageSize = 200;
|
||||
|
||||
/// Ceiling on the one dedicated-resume-route window that feeds every Emby
|
||||
/// playback shelf (see [_embyResumeWindowQuery]). The route cannot be
|
||||
/// server-filtered to either shelf half, so previews slice the split halves
|
||||
/// and the see-all surfaces page them in memory; this bounds that response.
|
||||
/// The rows arrive recency-ordered — the genuinely in-progress items plus one
|
||||
/// row per started series — so anything past a few hundred rows is old enough
|
||||
/// that the Next Up cutoff would drop it anyway.
|
||||
const _embyResumeWindowLimit = 300;
|
||||
|
||||
const _playableDescendantTypes = 'Movie,Episode,Audio';
|
||||
const _playableFolderDescendantTypes = 'Movie,Episode,Video,MusicVideo';
|
||||
const _episodeOrderQueryParameters = {
|
||||
@@ -1601,10 +1614,22 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
|
||||
@override
|
||||
Future<List<MediaItem>> fetchContinueWatching({int? count = 20}) async {
|
||||
if (!dialect.resumeReturnsOnlyStartedItems) {
|
||||
// Emby: both shelf halves ride the one hide-aware window request — see
|
||||
// [_embyResumeWindowQuery].
|
||||
final split = _splitEmbyResumeRows(
|
||||
await _fetchItemsArray(paths.resumeItems, _embyResumeWindowQuery(), retry: _continueWatchingRetry),
|
||||
);
|
||||
return _mergeContinueWatchingAndNextUp(
|
||||
resume: _mapItems(split.resume),
|
||||
nextUp: _mapItems(await _stampEmbyNextUpRows(split.nextUp)),
|
||||
limit: count,
|
||||
);
|
||||
}
|
||||
|
||||
final results = await Future.wait([
|
||||
_fetchItemsArray(_resumePath, {
|
||||
_fetchItemsArray(paths.resumeItems, {
|
||||
'userId': connection.userId,
|
||||
..._resumeFilterQuery,
|
||||
'Limit': ?count?.toString(),
|
||||
'Fields': _hubRowFields,
|
||||
'MediaTypes': 'Video',
|
||||
@@ -1612,7 +1637,7 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
'EnableTotalRecordCount': 'false',
|
||||
...jellyfinImageQueryParameters,
|
||||
}, retry: _continueWatchingRetry),
|
||||
_fetchNextUpRows({
|
||||
_safeFetchItemsArray('/Shows/NextUp', {
|
||||
'userId': connection.userId,
|
||||
'Limit': ?count?.toString(),
|
||||
'Fields': _hubRowFields,
|
||||
@@ -1623,13 +1648,11 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
}, retry: _continueWatchingRetry),
|
||||
]);
|
||||
|
||||
final nextUp = _mapItems(results[1]);
|
||||
return _mergeContinueWatchingAndNextUp(
|
||||
resume: _mapItems(results.first),
|
||||
// Only the server-side shelf needs enriching: `/Shows/NextUp` rows carry no
|
||||
// series play date, while the reconstructed rows were already stamped from
|
||||
// the recency query that ordered them.
|
||||
nextUp: dialect.supportsGlobalNextUp ? await _attachSeriesLastPlayed(nextUp) : nextUp,
|
||||
// `/Shows/NextUp` rows carry no series play date, so stamp them with one
|
||||
// before the recency merge.
|
||||
nextUp: await _attachSeriesLastPlayed(_mapItems(results[1])),
|
||||
limit: count,
|
||||
);
|
||||
}
|
||||
@@ -1752,13 +1775,13 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
return [hub('recent', recentTitle, 'mixed', latest)].where((h) => h.items.isNotEmpty).toList();
|
||||
}
|
||||
|
||||
final results = await Future.wait([
|
||||
latestFuture,
|
||||
_safeFetchItemsArray(
|
||||
_resumePath,
|
||||
final Future<List<Map<String, dynamic>>> resumeRowsFuture;
|
||||
final Future<List<Map<String, dynamic>>> nextUpRowsFuture;
|
||||
if (dialect.resumeReturnsOnlyStartedItems) {
|
||||
resumeRowsFuture = _safeFetchItemsArray(
|
||||
paths.resumeItems,
|
||||
{
|
||||
'userId': connection.userId,
|
||||
..._resumeFilterQuery,
|
||||
'ParentId': ?parentId,
|
||||
'Limit': limit.toString(),
|
||||
'Fields': _hubRowFields,
|
||||
@@ -1769,9 +1792,10 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
},
|
||||
retry: retry,
|
||||
diagnostics: diagnostics,
|
||||
),
|
||||
includeNextUp
|
||||
? _fetchNextUpRows(
|
||||
);
|
||||
nextUpRowsFuture = includeNextUp
|
||||
? _safeFetchItemsArray(
|
||||
'/Shows/NextUp',
|
||||
{
|
||||
'userId': connection.userId,
|
||||
'ParentId': ?parentId,
|
||||
@@ -1785,14 +1809,29 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
retry: retry,
|
||||
diagnostics: diagnostics,
|
||||
)
|
||||
: Future.value(const <Map<String, dynamic>>[]),
|
||||
]);
|
||||
: Future.value(const <Map<String, dynamic>>[]);
|
||||
} else {
|
||||
// Emby: one hide-aware window request feeds both playback shelves — see
|
||||
// [_embyResumeWindowQuery].
|
||||
final splitFuture = _safeFetchItemsArray(
|
||||
paths.resumeItems,
|
||||
_embyResumeWindowQuery(parentId: parentId),
|
||||
retry: retry,
|
||||
diagnostics: diagnostics,
|
||||
).then(_splitEmbyResumeRows);
|
||||
resumeRowsFuture = splitFuture.then((split) => split.resume);
|
||||
nextUpRowsFuture = includeNextUp
|
||||
? splitFuture.then((split) => _stampEmbyNextUpRows(split.nextUp, parentId: parentId))
|
||||
: Future.value(const <Map<String, dynamic>>[]);
|
||||
}
|
||||
|
||||
final results = await Future.wait([latestFuture, resumeRowsFuture, nextUpRowsFuture]);
|
||||
|
||||
return [
|
||||
hub('continue', continueTitle, 'mixed', results[1]),
|
||||
// The reconstructed Emby shelf is capped by the series lookup limit rather
|
||||
// than the caller's, so slice it to the requested preview size the way the
|
||||
// server-side query already does for Jellyfin.
|
||||
// The Emby halves are carved out of the shared window rather than capped by
|
||||
// the request, so slice both to the requested preview size the way the
|
||||
// server-side queries already do for Jellyfin.
|
||||
hub('continue', continueTitle, 'mixed', results[1].take(limit).toList(growable: false)),
|
||||
hub('nextup', nextUpTitle, 'episode', results[2].take(limit).toList(growable: false)),
|
||||
hub('recent', recentTitle, 'mixed', results.first),
|
||||
].where((h) => h.items.isNotEmpty).toList();
|
||||
@@ -1967,11 +2006,18 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
abort: abort,
|
||||
);
|
||||
case 'continue':
|
||||
if (!dialect.resumeReturnsOnlyStartedItems) {
|
||||
// Emby: page the hide-aware window in memory — see [_embyResumeWindowQuery].
|
||||
final resume = _splitEmbyResumeRows(
|
||||
await _fetchItemsArray(paths.resumeItems, _embyResumeWindowQuery(parentId: parentId), abort: abort),
|
||||
).resume;
|
||||
final window = resume.skip(offset).take(pageSize).toList(growable: false);
|
||||
return LibraryPage<MediaItem>(items: _mapItems(window), totalCount: resume.length, offset: offset);
|
||||
}
|
||||
return _safeFetchMediaPage(
|
||||
_resumePath,
|
||||
paths.resumeItems,
|
||||
{
|
||||
'userId': connection.userId,
|
||||
..._resumeFilterQuery,
|
||||
'StartIndex': offset.toString(),
|
||||
'Limit': effectiveLimit,
|
||||
'Fields': _hubRowFields,
|
||||
@@ -1985,29 +2031,31 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
abort: abort,
|
||||
);
|
||||
case 'nextup':
|
||||
final nextUpQuery = <String, dynamic>{
|
||||
'userId': connection.userId,
|
||||
'StartIndex': offset.toString(),
|
||||
'Limit': effectiveLimit,
|
||||
'Fields': _hubRowFields,
|
||||
'ParentId': ?parentId,
|
||||
'EnableResumable': 'false',
|
||||
'NextUpDateCutoff': _nextUpDateCutoff(),
|
||||
'EnableTotalRecordCount': 'true',
|
||||
...jellyfinImageQueryParameters,
|
||||
};
|
||||
if (dialect.supportsGlobalNextUp) {
|
||||
return _safeFetchMediaPage(
|
||||
'/Shows/NextUp',
|
||||
nextUpQuery,
|
||||
{
|
||||
'userId': connection.userId,
|
||||
'StartIndex': offset.toString(),
|
||||
'Limit': effectiveLimit,
|
||||
'Fields': _hubRowFields,
|
||||
'ParentId': ?parentId,
|
||||
'EnableResumable': 'false',
|
||||
'NextUpDateCutoff': _nextUpDateCutoff(),
|
||||
'EnableTotalRecordCount': 'true',
|
||||
...jellyfinImageQueryParameters,
|
||||
},
|
||||
offset: offset,
|
||||
requestedSize: pageSize,
|
||||
abort: abort,
|
||||
);
|
||||
}
|
||||
// Emby's shelf is assembled client-side and is capped by
|
||||
// [_seriesLastPlayedLookupLimit], so it is paged in memory.
|
||||
final rows = await _fetchNextUpRows(nextUpQuery, abort: abort);
|
||||
// Emby: the shelf is carved from the hide-aware window and paged in
|
||||
// memory — see [_embyResumeWindowQuery].
|
||||
final split = _splitEmbyResumeRows(
|
||||
await _fetchItemsArray(paths.resumeItems, _embyResumeWindowQuery(parentId: parentId), abort: abort),
|
||||
);
|
||||
final rows = await _stampEmbyNextUpRows(split.nextUp, parentId: parentId, abort: abort);
|
||||
final window = rows.skip(offset).take(pageSize).toList(growable: false);
|
||||
return LibraryPage<MediaItem>(items: _mapItems(window), totalCount: rows.length, offset: offset);
|
||||
case 'recentlyplayed':
|
||||
@@ -2198,148 +2246,78 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
];
|
||||
}
|
||||
|
||||
/// Route and extra query that list genuinely in-progress items.
|
||||
/// Query for the one dedicated-resume-route window that feeds every Emby
|
||||
/// playback shelf.
|
||||
///
|
||||
/// Jellyfin's dedicated resume route already returns only started items. Emby's
|
||||
/// does not: measured against one in-progress movie and 30 started series it
|
||||
/// returned 30 rows — the movie plus every started series' next episode — with
|
||||
/// the movie sorted *last*, and no `Filters` value removed them. Paging that is
|
||||
/// unusable, so Emby reads the ordinary `/Items` route with
|
||||
/// `Filters=IsResumable`, which returned exactly the movie
|
||||
/// (`TotalRecordCount: 1`) and supports the same sort, paging and `ParentId`
|
||||
/// scoping. Those next episodes reach the UI through the Next Up shelf, which
|
||||
/// is where Plezy models them.
|
||||
Map<String, dynamic> get _resumeFilterQuery => dialect.resumeReturnsOnlyStartedItems
|
||||
? const {}
|
||||
: const {'Filters': 'IsResumable', 'SortBy': 'DatePlayed', 'SortOrder': 'Descending'};
|
||||
/// Emby's route conflates the two shelves Plezy models separately: it returns
|
||||
/// the genuinely in-progress items *and* one zero-position next episode per
|
||||
/// started series, and no server-side filter separates them (measured on
|
||||
/// 4.9.5: `Filters=IsResumable` changes nothing). It is nevertheless the only
|
||||
/// listing that honours `HideFromResume` — `/Items?Filters=IsResumable` and
|
||||
/// `/Shows/NextUp?SeriesId=` keep returning hidden rows, and no public filter
|
||||
/// or `UserData` field exposes the flag — so reading anything else pins a
|
||||
/// removed row to the shelf forever (#2003). The response is split by
|
||||
/// [_splitEmbyResumeRows] instead: previews slice the halves and the see-all
|
||||
/// surfaces page them in memory.
|
||||
Map<String, dynamic> _embyResumeWindowQuery({String? parentId}) => {
|
||||
'userId': connection.userId,
|
||||
'ParentId': ?parentId,
|
||||
'Limit': _embyResumeWindowLimit.toString(),
|
||||
'Fields': _hubRowFields,
|
||||
'MediaTypes': 'Video',
|
||||
'Recursive': 'true',
|
||||
'EnableTotalRecordCount': 'false',
|
||||
...jellyfinImageQueryParameters,
|
||||
};
|
||||
|
||||
/// `/Items` on Emby (see [_resumeFilterQuery]); the dedicated route otherwise.
|
||||
String get _resumePath => dialect.resumeReturnsOnlyStartedItems ? paths.resumeItems : '/Items';
|
||||
|
||||
/// Library-wide Next Up rows.
|
||||
///
|
||||
/// Jellyfin computes this server-side. Emby only computes Next Up per series
|
||||
/// — an unscoped `/Shows/NextUp` returns nothing there under any parameter
|
||||
/// combination (see [MediaBrowserDialect.supportsGlobalNextUp]) — so this
|
||||
/// reconstructs the shelf in two phases:
|
||||
///
|
||||
/// 1. one `/Items` query for the most recently played episodes, newest first,
|
||||
/// which yields the started series in exactly the order the shelf wants;
|
||||
/// 2. one `/Shows/NextUp?SeriesId=` per distinct series, bounded by the same
|
||||
/// concurrency and lookup cap [_attachSeriesLastPlayed] uses, and by one
|
||||
/// [_seriesLastPlayedBudget] wall clock that covers phase 1 as well, so a
|
||||
/// slow server cannot hold the home screen.
|
||||
///
|
||||
/// Rows come back series-recency-ordered, which is what the caller's merge
|
||||
/// expects, and a failed per-series lookup drops only that series.
|
||||
Future<List<Map<String, dynamic>>> _fetchNextUpRows(
|
||||
Map<String, dynamic> queryParameters, {
|
||||
_HubRetryPolicy? retry,
|
||||
AbortController? abort,
|
||||
HubFetchDiagnostics? diagnostics,
|
||||
}) async {
|
||||
if (dialect.supportsGlobalNextUp) {
|
||||
return _safeFetchItemsArray(
|
||||
'/Shows/NextUp',
|
||||
queryParameters,
|
||||
retry: retry,
|
||||
abort: abort,
|
||||
diagnostics: diagnostics,
|
||||
);
|
||||
}
|
||||
|
||||
final budgetAbort = AbortController();
|
||||
final deadline = Timer(_seriesLastPlayedBudget, budgetAbort.abort);
|
||||
// The caller's cancellation has to reach the requests this pass owns, which
|
||||
// all run under [budgetAbort].
|
||||
if (abort != null) unawaited(abort.trigger.then((_) => budgetAbort.abort()));
|
||||
try {
|
||||
return await _reconstructNextUpRows(queryParameters, abort: abort, budgetAbort: budgetAbort);
|
||||
} finally {
|
||||
deadline.cancel();
|
||||
budgetAbort.abort();
|
||||
/// Split one Emby resume-route window into the two shelves it conflates:
|
||||
/// rows with progress are Continue Watching, zero-position episode rows are
|
||||
/// each started series' Next Up entry. Both halves keep the server's
|
||||
/// recency order.
|
||||
({List<Map<String, dynamic>> resume, List<Map<String, dynamic>> nextUp}) _splitEmbyResumeRows(
|
||||
List<Map<String, dynamic>> rows,
|
||||
) {
|
||||
final resume = <Map<String, dynamic>>[];
|
||||
final nextUp = <Map<String, dynamic>>[];
|
||||
for (final row in rows) {
|
||||
final userData = row['UserData'];
|
||||
final positionMs = jellyfinTicksToMs(userData is Map<String, dynamic> ? userData['PlaybackPositionTicks'] : null);
|
||||
if (positionMs != null && positionMs > 0) {
|
||||
resume.add(row);
|
||||
} else if (row['Type'] == 'Episode') {
|
||||
nextUp.add(row);
|
||||
}
|
||||
}
|
||||
return (resume: resume, nextUp: nextUp);
|
||||
}
|
||||
|
||||
/// The reconstruction itself, under a caller-supplied wall-clock budget.
|
||||
Future<List<Map<String, dynamic>>> _reconstructNextUpRows(
|
||||
Map<String, dynamic> queryParameters, {
|
||||
required AbortController? abort,
|
||||
required AbortController budgetAbort,
|
||||
/// Stamp Emby's zero-position Next Up rows with their series' newest play
|
||||
/// date and apply the [_nextUpDateCutoff] window Jellyfin enforces
|
||||
/// server-side.
|
||||
///
|
||||
/// A Next Up episode has never been played, so its own `UserData` carries no
|
||||
/// date and the shelf's recency sort would degrade to when the episode was
|
||||
/// added to the library. The dates come from one recently-played-episodes
|
||||
/// scan ([_fetchRecentlyPlayedSeriesIds]); a series the scan did not reach is
|
||||
/// dropped, which keeps the shelf bounded to the series the scan can vouch
|
||||
/// for — the same [_seriesLastPlayedLookupLimit] bound the shelf had when it
|
||||
/// was reconstructed from per-series `/Shows/NextUp` lookups. A failed scan
|
||||
/// therefore costs the Next Up half, never the resume half.
|
||||
Future<List<Map<String, dynamic>>> _stampEmbyNextUpRows(
|
||||
List<Map<String, dynamic>> rows, {
|
||||
String? parentId,
|
||||
AbortController? abort,
|
||||
}) async {
|
||||
final probe = _fetchRecentlyPlayedSeriesIds(parentId: queryParameters['ParentId'] as String?, abort: budgetAbort);
|
||||
final List<(String, String?)> probed;
|
||||
try {
|
||||
// Raced, not just awaited: aborting is advisory at the transport, and the
|
||||
// probe's own timeout applies to the connect and receive phases
|
||||
// independently, so a delayed header plus a stalled body could outlive the
|
||||
// deadline. Same policy as the per-series batches below.
|
||||
probed = await Future.any([probe, budgetAbort.trigger.then((_) => const <(String, String?)>[])]);
|
||||
} on MediaServerHttpException catch (e) {
|
||||
// Our own deadline expiring is not a disrupted fetch: this shelf is
|
||||
// best-effort, so an over-budget probe costs the Next Up half rather than
|
||||
// the caller's whole request. A cancellation the *caller* asked for still
|
||||
// propagates.
|
||||
if (e.isCancellation && abort?.isAborted != true) return const [];
|
||||
rethrow;
|
||||
} finally {
|
||||
// The loser may still fail later; its outcome is no longer anyone's.
|
||||
probe.ignore();
|
||||
}
|
||||
// Before the early return below: an empty probe can also mean the caller
|
||||
// cancelled mid-request and the transport reported an ordinary timeout, which
|
||||
// must not be published as "nothing to watch next".
|
||||
abort?.throwIfAborted();
|
||||
|
||||
final recentSeries = _withinNextUpCutoff(probed, queryParameters['NextUpDateCutoff'] as String?);
|
||||
if (recentSeries.isEmpty) return const [];
|
||||
final seriesIds = [for (final (seriesId, _) in recentSeries) seriesId];
|
||||
|
||||
// Per-series queries carry the caller's field/image selection but never its
|
||||
// paging: the shelf is assembled here and sliced by the caller.
|
||||
final perSeriesQuery = <String, dynamic>{
|
||||
for (final entry in queryParameters.entries)
|
||||
if (entry.key != 'StartIndex' && entry.key != 'Limit' && entry.key != 'ParentId') entry.key: entry.value,
|
||||
'Limit': '1',
|
||||
};
|
||||
|
||||
final rowsBySeries = <String, Map<String, dynamic>>{};
|
||||
for (var start = 0; start < seriesIds.length; start += _seriesLastPlayedConcurrency) {
|
||||
if (budgetAbort.isAborted || abort?.isAborted == true) break;
|
||||
final batch = seriesIds.skip(start).take(_seriesLastPlayedConcurrency);
|
||||
// Each lookup records itself as it completes, so a sibling that is still
|
||||
// slow when the deadline fires costs only its own row. Awaiting the batch
|
||||
// as one future would discard every result it had already collected.
|
||||
final lookups = [
|
||||
for (final seriesId in batch)
|
||||
_fetchSeriesNextUp(seriesId, perSeriesQuery, budgetAbort).then((result) {
|
||||
final (id, row) = result;
|
||||
if (row != null) rowsBySeries[id] = row;
|
||||
}),
|
||||
];
|
||||
final batchDone = Future.wait(lookups);
|
||||
await Future.any([batchDone, budgetAbort.trigger]);
|
||||
// No-op once the batch has won; suppresses the loser's late completion.
|
||||
batchDone.ignore();
|
||||
}
|
||||
|
||||
// The loop breaks on either abort, and the caller's means disruption: a
|
||||
// partial shelf must not be published as though the series had no next
|
||||
// episode. Our own budget expiring keeps degrading to whatever was collected.
|
||||
abort?.throwIfAborted();
|
||||
|
||||
// Reassemble in series-recency order rather than completion order, stamping
|
||||
// each row with its series' newest play date. A Next Up episode has never
|
||||
// been played, so its own `UserData` carries no date, and the shelf's sort
|
||||
// key would otherwise fall back to when the episode was added to the
|
||||
// library. The date comes from the same response that established this
|
||||
// order, so no extra request is needed.
|
||||
if (rows.isEmpty) return rows;
|
||||
final recentSeries = _withinNextUpCutoff(
|
||||
await _fetchRecentlyPlayedSeriesIds(parentId: parentId, abort: abort),
|
||||
_nextUpDateCutoff(),
|
||||
);
|
||||
final lastPlayedBySeries = {for (final (seriesId, lastPlayed) in recentSeries) seriesId: lastPlayed};
|
||||
return [
|
||||
for (final (seriesId, lastPlayed) in recentSeries)
|
||||
if (rowsBySeries[seriesId] case final row?)
|
||||
if (lastPlayed == null)
|
||||
row
|
||||
else
|
||||
for (final row in rows)
|
||||
if (lastPlayedBySeries.containsKey(row['SeriesId']))
|
||||
if (lastPlayedBySeries[row['SeriesId']] case final lastPlayed?)
|
||||
{
|
||||
...row,
|
||||
// Tolerant read: a dto whose `UserData` is absent or not an object
|
||||
@@ -2348,17 +2326,19 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
...?(row['UserData'] is Map<String, dynamic> ? row['UserData'] as Map<String, dynamic> : null),
|
||||
'LastPlayedDate': lastPlayed,
|
||||
},
|
||||
},
|
||||
}
|
||||
else
|
||||
row,
|
||||
];
|
||||
}
|
||||
|
||||
/// Drop series whose newest play predates [cutoff], the window Jellyfin's own
|
||||
/// `/Shows/NextUp` applies through `NextUpDateCutoff`.
|
||||
///
|
||||
/// Measured on Emby 4.9.5: `/Shows/NextUp` ignores `NextUpDateCutoff` entirely
|
||||
/// — a cutoff of 2030 still returned the row that a 2019 cutoff did, while
|
||||
/// Jellyfin 10.11 returned nothing for a future cutoff. Without this the
|
||||
/// reconstructed shelf would resurrect series the user abandoned years ago that
|
||||
/// Measured on Emby 4.9.5: nothing on the server applies the window — a
|
||||
/// `NextUpDateCutoff` of 2030 still returned the row that a 2019 cutoff did,
|
||||
/// while Jellyfin 10.11 returned nothing for a future cutoff. Without this the
|
||||
/// Next Up shelf would resurrect series the user abandoned years ago that
|
||||
/// Jellyfin hides.
|
||||
///
|
||||
/// Filtered here rather than on the server because Emby has no played-date
|
||||
@@ -2388,9 +2368,9 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
/// signal Emby exposes for series: a series dto carries neither a usable
|
||||
/// `PlayCount` nor a `DatePlayed` sort key, so the episodes have to supply the
|
||||
/// order. Because the rows arrive newest-first, the first row naming a series
|
||||
/// *is* that series' newest play, so this one request yields both the shelf
|
||||
/// order and the timestamp each reconstructed row needs — no per-series
|
||||
/// enrichment round trip.
|
||||
/// *is* that series' newest play, so this one request yields both the cutoff
|
||||
/// input and the timestamp each of [_stampEmbyNextUpRows]'s rows needs — no
|
||||
/// per-series enrichment round trip.
|
||||
Future<List<(String, String?)>> _fetchRecentlyPlayedSeriesIds({String? parentId, AbortController? abort}) async {
|
||||
final rows = await _safeFetchItemsArray(
|
||||
'/Items',
|
||||
@@ -2417,10 +2397,10 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
// Best-effort shelf: a timeout or 5xx here must not move the client's
|
||||
// active endpoint, which is what every other hub leg also avoids.
|
||||
//
|
||||
// This [timeout] bounds a single request phase, not the probe: like every
|
||||
// per-call timeout it applies to connect and receive independently. The
|
||||
// wall clock comes from the caller's shared [_seriesLastPlayedBudget],
|
||||
// which covers this probe and the per-series lookups together.
|
||||
// This [timeout] bounds a single request phase, not the scan: like every
|
||||
// per-call timeout it applies to connect and receive independently, so a
|
||||
// stalled endpoint costs at most two phases before the Next Up half
|
||||
// degrades to empty.
|
||||
//
|
||||
// Deliberately *not* the hub retry policy: `_getItemsResponse` ignores
|
||||
// `timeout` on the retried path, which would leave this request bounded
|
||||
@@ -2441,23 +2421,6 @@ mixin _JellyfinBrowseMethods on _JellyfinClientInternals {
|
||||
return [for (final entry in lastPlayedBySeries.entries) (entry.key, entry.value)];
|
||||
}
|
||||
|
||||
/// The single Next Up episode for [seriesId], or null when the series has none
|
||||
/// left — or when the lookup failed, which drops only this series.
|
||||
Future<(String, Map<String, dynamic>?)> _fetchSeriesNextUp(
|
||||
String seriesId,
|
||||
Map<String, dynamic> queryParameters,
|
||||
AbortController abort,
|
||||
) async {
|
||||
final rows = await _safeFetchItemsArray(
|
||||
'/Shows/NextUp',
|
||||
{...queryParameters, 'SeriesId': seriesId},
|
||||
abort: abort,
|
||||
timeout: _seriesLastPlayedRequestTimeout,
|
||||
allowEndpointFailover: false,
|
||||
);
|
||||
return (seriesId, rows.isEmpty ? null : rows.first);
|
||||
}
|
||||
|
||||
/// Newest `LastPlayedDate` across [seriesId]'s episodes, or null when the
|
||||
/// series has never been played — or when the lookup failed, in which case the
|
||||
/// row keeps a null date and degrades to its `addedAt` in the shelf sort.
|
||||
|
||||
@@ -47,10 +47,15 @@ mixin _JellyfinWatchStateMethods on _JellyfinClientInternals {
|
||||
/// Hide [item] from Continue Watching while keeping its resume position.
|
||||
///
|
||||
/// Emby-only. `POST /Users/{uid}/Items/{id}/HideFromResume?Hide=true` drops
|
||||
/// the row from `/Users/{uid}/Items/Resume` and leaves
|
||||
/// `UserData.PlaybackPositionTicks` untouched (verified on Emby 4.9.5).
|
||||
/// Jellyfin 10.11 has no equivalent route, so it keeps throwing and
|
||||
/// [ServerCapabilities.continueWatchingRemoval] keeps the affordance hidden.
|
||||
/// the row from `/Users/{uid}/Items/Resume` — the one listing that honours
|
||||
/// the flag, and therefore the route every Emby playback shelf reads (see
|
||||
/// [MediaBrowserDialect.resumeReturnsOnlyStartedItems]) — while leaving
|
||||
/// `UserData.PlaybackPositionTicks` untouched. Hiding a zero-position Next Up
|
||||
/// row also removes its series' entry, and reporting new playback clears the
|
||||
/// flag, so a removed item returns once the user actually resumes it (all
|
||||
/// verified on Emby 4.9.5). Jellyfin 10.11 has no equivalent route, so it
|
||||
/// keeps throwing and [ServerCapabilities.continueWatchingRemoval] keeps the
|
||||
/// affordance hidden.
|
||||
@override
|
||||
Future<void> removeFromContinueWatching(MediaItem item) async {
|
||||
if (!dialect.supportsContinueWatchingRemoval) {
|
||||
|
||||
@@ -27,7 +27,10 @@ class MediaBrowserPaths {
|
||||
/// The authenticated user's own DTO — health probe and user-preference read.
|
||||
String get currentUser => dialect.requiresUserScopedItemRoutes ? _user : '/Users/Me';
|
||||
|
||||
/// Continue Watching / resumable items.
|
||||
/// Continue Watching / resumable items. On Emby the response also carries
|
||||
/// one zero-position next episode per started series, and it is the only
|
||||
/// listing that honours `HideFromResume` — see
|
||||
/// [MediaBrowserDialect.resumeReturnsOnlyStartedItems].
|
||||
String get resumeItems => dialect.requiresUserScopedItemRoutes ? '$_user/Items/Resume' : '/UserItems/Resume';
|
||||
|
||||
/// Played flag write route (`POST` to mark, `DELETE` to unmark).
|
||||
@@ -66,7 +69,9 @@ class MediaBrowserPaths {
|
||||
: '/Items/${_id(itemId)}/SpecialFeatures';
|
||||
|
||||
/// Hide an item from Continue Watching without touching its playback
|
||||
/// position (`?Hide=true` to hide, `?Hide=false` to restore).
|
||||
/// position (`?Hide=true` to hide, `?Hide=false` to restore). Honoured only
|
||||
/// by the dedicated [resumeItems] route, which is why every Emby playback
|
||||
/// shelf reads it.
|
||||
///
|
||||
/// Emby-only: Jellyfin 10.11 has no equivalent under either spelling
|
||||
/// (measured 404 for both `/UserItems/{id}/HideFromResume` and the
|
||||
|
||||
@@ -78,8 +78,13 @@ class MultiServerManager {
|
||||
Stream<Map<String, bool>> get statusStream => _statusController.stream;
|
||||
|
||||
/// Publish a snapshot of the per-server online map — subscribers must never
|
||||
/// receive the live [_serverStatus] instance.
|
||||
void _emitStatus() => _statusController.add(Map.from(_serverStatus));
|
||||
/// receive the live [_serverStatus] instance. A no-op once [shutdown] or
|
||||
/// [dispose] closed the controller, so a health probe or reconnect landing
|
||||
/// mid-exit cannot throw into a closed stream.
|
||||
void _emitStatus() {
|
||||
if (_statusController.isClosed) return;
|
||||
_statusController.add(Map.from(_serverStatus));
|
||||
}
|
||||
|
||||
/// Per-server connect progress during a bind. Unlike [statusStream] — whose
|
||||
/// first emission means "the binder's first connect pass finished" and which
|
||||
@@ -1447,6 +1452,20 @@ class MultiServerManager {
|
||||
return clients;
|
||||
}
|
||||
|
||||
/// Terminal app-exit teardown: closes the status streams first, then drains
|
||||
/// every client connection.
|
||||
///
|
||||
/// Unlike [disconnectAllGracefully] — whose empty snapshot profile-switch
|
||||
/// and disconnect flows must observe — exit teardown must stay invisible:
|
||||
/// the widget tree is still mounted while the exit request is serviced, and
|
||||
/// an empty snapshot reads as "all servers gone", flipping the app into
|
||||
/// offline UI and dismantling screens mid-shutdown.
|
||||
Future<void> shutdown({Duration drainTimeout = const Duration(seconds: 5)}) async {
|
||||
if (!_statusController.isClosed) unawaited(_statusController.close());
|
||||
if (!_connectProgressController.isClosed) unawaited(_connectProgressController.close());
|
||||
await disconnectAllGracefully(drainTimeout: drainTimeout);
|
||||
}
|
||||
|
||||
/// Dispose resources
|
||||
void dispose() {
|
||||
disconnectAll();
|
||||
|
||||
@@ -4220,15 +4220,23 @@ class PlexClient
|
||||
|
||||
/// `minSize`/`upscale` are how Plex's photo transcoder picks the scale
|
||||
/// factor. `minSize=1` scales until the *smaller* axis reaches the request
|
||||
/// (cover) and `upscale=1` lets it enlarge past the original; both return
|
||||
/// the whole image — Plex never crops or distorts. `minSize=0&upscale=0`
|
||||
/// scales the *larger* axis to fit inside the box instead, which is what
|
||||
/// `BoxFit.contain` artwork wants: the covering overshoot is decoded and
|
||||
/// then thrown away by the fit-policy decode bounds.
|
||||
/// (cover) and `minSize=0` fits the *larger* axis inside the box instead,
|
||||
/// which is what `BoxFit.contain` artwork wants. Neither crops or distorts.
|
||||
///
|
||||
/// `upscale=0` caps the scale factor at 1.0: a request larger than the
|
||||
/// source returns the native image instead of a server-side enlargement.
|
||||
/// Covers deliberately never upscale — the client renders `BoxFit.cover`
|
||||
/// and the fit-policy decode bounds never enlarge either, so a server
|
||||
/// upscale is pure transcoder CPU and transfer bytes for zero rendered
|
||||
/// detail (verified against PMS 1.43: 1920×1080 art requested at 3840×2160
|
||||
/// upscaled costs ~2.5× the transcode time and bytes; downscale results are
|
||||
/// byte-identical either way). It also stops PMS flagging every request
|
||||
/// `upscaled: 1` in its logs, which reads as constant re-transcoding (#1975).
|
||||
List<String> _transcodeSizeParams({int? width, int? height, required bool cover}) => [
|
||||
if (width != null) 'width=$width',
|
||||
if (height != null) 'height=$height',
|
||||
if (cover) ...['minSize=1', 'upscale=1'] else ...['minSize=0', 'upscale=0'],
|
||||
'minSize=${cover ? 1 : 0}',
|
||||
'upscale=0',
|
||||
];
|
||||
|
||||
@override
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../models/anilist/anilist_media.dart';
|
||||
import '../../../models/trackers/anime_list_snapshot.dart';
|
||||
|
||||
import '../../../utils/json_utils.dart';
|
||||
import '../tracker.dart';
|
||||
@@ -237,15 +238,33 @@ class AnilistClient implements DisposableTrackerClient {
|
||||
}
|
||||
|
||||
/// Update the viewer's media-list entry for an AniList media ID.
|
||||
Future<void> saveMediaListEntry({required int mediaId, required int progress, required String status}) async {
|
||||
const mutation = '''
|
||||
///
|
||||
/// [repeat] is the absolute finished-rewatch count and is written only when
|
||||
/// provided (completing a rewatch). The argument is omitted from the
|
||||
/// document otherwise: AniList's treatment of an explicit null is
|
||||
/// undocumented and must not clear the stored count.
|
||||
Future<void> saveMediaListEntry({
|
||||
required int mediaId,
|
||||
required int progress,
|
||||
required String status,
|
||||
int? repeat,
|
||||
}) async {
|
||||
final mutation = repeat == null
|
||||
? '''
|
||||
mutation(\$mediaId: Int, \$progress: Int, \$status: MediaListStatus) {
|
||||
SaveMediaListEntry(mediaId: \$mediaId, progress: \$progress, status: \$status) {
|
||||
id
|
||||
}
|
||||
}
|
||||
'''
|
||||
: '''
|
||||
mutation(\$mediaId: Int, \$progress: Int, \$status: MediaListStatus, \$repeat: Int) {
|
||||
SaveMediaListEntry(mediaId: \$mediaId, progress: \$progress, status: \$status, repeat: \$repeat) {
|
||||
id
|
||||
}
|
||||
}
|
||||
''';
|
||||
await query(mutation, variables: {'mediaId': mediaId, 'progress': progress, 'status': status});
|
||||
await query(mutation, variables: {'mediaId': mediaId, 'progress': progress, 'status': status, 'repeat': ?repeat});
|
||||
}
|
||||
|
||||
Future<void> deleteMediaListEntry(int mediaId) async {
|
||||
@@ -307,11 +326,17 @@ class AnilistClient implements DisposableTrackerClient {
|
||||
return (scoreRaw / 10).round().clamp(1, 10).toInt();
|
||||
}
|
||||
|
||||
Future<int?> getAnimeEpisodeCount(int mediaId) async {
|
||||
/// Episode count plus the viewer's list entry in one request, so the
|
||||
/// rewatch-preserving scrobble path costs no extra call.
|
||||
Future<AnimeListSnapshot?> getAnimeListSnapshot(int mediaId) async {
|
||||
const mediaQuery = '''
|
||||
query(\$mediaId: Int) {
|
||||
Media(id: \$mediaId, type: ANIME) {
|
||||
episodes
|
||||
mediaListEntry {
|
||||
status
|
||||
repeat
|
||||
}
|
||||
}
|
||||
}
|
||||
''';
|
||||
@@ -319,7 +344,14 @@ class AnilistClient implements DisposableTrackerClient {
|
||||
final media = data['Media'];
|
||||
if (media is! Map) return null;
|
||||
final count = flexibleInt(media['episodes']);
|
||||
return count != null && count > 0 ? count : null;
|
||||
final entry = media['mediaListEntry'];
|
||||
final status = entry is Map ? entry['status'] : null;
|
||||
return AnimeListSnapshot(
|
||||
episodeCount: count != null && count > 0 ? count : null,
|
||||
rewatching: status == 'REPEATING',
|
||||
completed: status == 'COMPLETED',
|
||||
rewatchCount: entry is Map ? (flexibleInt(entry['repeat']) ?? 0) : 0,
|
||||
);
|
||||
}
|
||||
|
||||
Future<AnilistPage> getTrendingAnime({int page = 1, int limit = 25}) =>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../models/trackers/anime_ids.dart';
|
||||
import '../../../models/trackers/anime_list_snapshot.dart';
|
||||
import '../../../models/trackers/tracker_context.dart';
|
||||
import '../../../utils/app_logger.dart';
|
||||
import '../anime_list_tracker_base.dart';
|
||||
@@ -10,7 +11,8 @@ import '../tracker_session.dart';
|
||||
import 'anilist_client.dart';
|
||||
|
||||
/// AniList scrobble tracker. Saves `SaveMediaListEntry(progress, status)`
|
||||
/// once playback crosses the watched threshold.
|
||||
/// once playback crosses the watched threshold, preserving a `REPEATING`
|
||||
/// entry instead of stomping it back to `CURRENT` (issue #2026).
|
||||
///
|
||||
/// AniList is anime-only: no-op when [TrackerContext.anime] is null.
|
||||
class AnilistTracker extends TrackerBase with ClientBackedTracker<AnilistClient>, AnimeListTrackerBase<AnilistClient> {
|
||||
@@ -44,7 +46,8 @@ class AnilistTracker extends TrackerBase with ClientBackedTracker<AnilistClient>
|
||||
int? animeId(AnimeIds? anime) => anime?.anilist;
|
||||
|
||||
@override
|
||||
Future<int?> loadAnimeEpisodeCount(AnilistClient client, int anilistId) => client.getAnimeEpisodeCount(anilistId);
|
||||
Future<AnimeListSnapshot?> loadAnimeListSnapshot(AnilistClient client, int anilistId) =>
|
||||
client.getAnimeListSnapshot(anilistId);
|
||||
|
||||
@override
|
||||
Future<void> saveAnimeProgress(
|
||||
@@ -52,10 +55,16 @@ class AnilistTracker extends TrackerBase with ClientBackedTracker<AnilistClient>
|
||||
required int animeId,
|
||||
required int progress,
|
||||
required bool completed,
|
||||
required bool rewatching,
|
||||
int? rewatchCount,
|
||||
}) async {
|
||||
final status = completed ? 'COMPLETED' : 'CURRENT';
|
||||
await client.saveMediaListEntry(mediaId: animeId, progress: progress, status: status);
|
||||
appLogger.d('AniList: saved entry (anilist=$animeId, progress=$progress, status=$status)');
|
||||
final status = completed
|
||||
? 'COMPLETED'
|
||||
: rewatching
|
||||
? 'REPEATING'
|
||||
: 'CURRENT';
|
||||
await client.saveMediaListEntry(mediaId: animeId, progress: progress, status: status, repeat: rewatchCount);
|
||||
appLogger.d('AniList: saved entry (anilist=$animeId, progress=$progress, status=$status, repeat=$rewatchCount)');
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import '../../models/trackers/anime_ids.dart';
|
||||
import '../../models/trackers/anime_list_snapshot.dart';
|
||||
import '../../models/trackers/tracker_context.dart';
|
||||
import '../../utils/app_logger.dart';
|
||||
import 'future_coalescer.dart';
|
||||
@@ -7,7 +8,7 @@ import 'tracker_id_resolver.dart';
|
||||
|
||||
mixin AnimeListTrackerBase<TClient extends DisposableTrackerClient> on TrackerBase, ClientBackedTracker<TClient>
|
||||
implements TrackerRatingSource, SeriesProgressTracker {
|
||||
final KeyedFutureCache<int, int?> _episodeCountLoads = KeyedFutureCache();
|
||||
final KeyedFutureCache<int, AnimeListSnapshot?> _listSnapshotLoads = KeyedFutureCache();
|
||||
|
||||
@override
|
||||
bool get needsFribb => true;
|
||||
@@ -15,19 +16,27 @@ mixin AnimeListTrackerBase<TClient extends DisposableTrackerClient> on TrackerBa
|
||||
String get logLabel;
|
||||
|
||||
int? animeId(AnimeIds? anime);
|
||||
Future<int?> loadAnimeEpisodeCount(TClient client, int animeId);
|
||||
Future<AnimeListSnapshot?> loadAnimeListSnapshot(TClient client, int animeId);
|
||||
|
||||
/// Write watched progress to the service.
|
||||
///
|
||||
/// [rewatching] means the write must represent an in-progress rewatch
|
||||
/// instead of a first watch. [rewatchCount] is the absolute finished-rewatch
|
||||
/// count to record and is non-null only when this write completes a rewatch.
|
||||
Future<void> saveAnimeProgress(
|
||||
TClient client, {
|
||||
required int animeId,
|
||||
required int progress,
|
||||
required bool completed,
|
||||
required bool rewatching,
|
||||
int? rewatchCount,
|
||||
});
|
||||
Future<void> deleteAnimeEntry(TClient client, int animeId);
|
||||
Future<void> setAnimeRating(TClient client, int animeId, int score);
|
||||
Future<int?> loadAnimeRating(TClient client, int animeId);
|
||||
|
||||
void clearAnimeListTrackerCache() {
|
||||
_episodeCountLoads.clear();
|
||||
_listSnapshotLoads.clear();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -40,6 +49,13 @@ mixin AnimeListTrackerBase<TClient extends DisposableTrackerClient> on TrackerBa
|
||||
|
||||
/// [watchedAt] is ignored: a list entry stores a progress counter, not dated
|
||||
/// plays, so a replayed write is indistinguishable from a fresh one.
|
||||
///
|
||||
/// Rewatch state is preserved rather than stomped back to watching (issue
|
||||
/// #2026): an entry the user set to rewatching stays a rewatch until it
|
||||
/// completes, and new progress on a completed entry starts a rewatch.
|
||||
/// Completing a rewatch records the bumped rewatch count as an absolute
|
||||
/// value from the snapshot, so a replayed completion writes the same count
|
||||
/// instead of incrementing again.
|
||||
@override
|
||||
Future<void> markWatched(TrackerContext ctx, {DateTime? watchedAt}) async {
|
||||
final activeClient = client;
|
||||
@@ -48,11 +64,26 @@ mixin AnimeListTrackerBase<TClient extends DisposableTrackerClient> on TrackerBa
|
||||
|
||||
final progress = seriesProgress(ctx);
|
||||
if (progress == null || progress <= 0) return;
|
||||
final total = ctx.isMovie || ctx.animeProgress == null ? null : await _episodeCount(activeClient, id);
|
||||
|
||||
final snapshot = await _listSnapshot(activeClient, id);
|
||||
// The total is only comparable when Fribb mapped this playback into the
|
||||
// anime's own episode space; a local episode number says nothing about
|
||||
// the mapped entry's total. Movies complete in a single unit.
|
||||
final total = ctx.isMovie || ctx.animeProgress == null ? null : snapshot?.episodeCount;
|
||||
final watched = total != null && progress > total ? total : progress;
|
||||
final completed = ctx.isMovie || (total != null && progress >= total);
|
||||
|
||||
await saveAnimeProgress(activeClient, animeId: id, progress: watched, completed: completed);
|
||||
final rewatching = !completed && snapshot != null && (snapshot.rewatching || snapshot.completed);
|
||||
final rewatchCount = completed && (snapshot?.rewatching ?? false) ? snapshot!.rewatchCount + 1 : null;
|
||||
|
||||
await saveAnimeProgress(
|
||||
activeClient,
|
||||
animeId: id,
|
||||
progress: watched,
|
||||
completed: completed,
|
||||
rewatching: rewatching,
|
||||
rewatchCount: rewatchCount,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -95,11 +126,11 @@ mixin AnimeListTrackerBase<TClient extends DisposableTrackerClient> on TrackerBa
|
||||
return (activeClient, id);
|
||||
}
|
||||
|
||||
Future<int?> _episodeCount(TClient activeClient, int id) => _episodeCountLoads
|
||||
Future<AnimeListSnapshot?> _listSnapshot(TClient activeClient, int id) => _listSnapshotLoads
|
||||
.run(
|
||||
id,
|
||||
() => loadAnimeEpisodeCount(activeClient, id),
|
||||
onError: (e) => appLogger.d('$logLabel: failed to fetch anime episode count ($name=$id)', error: e),
|
||||
() => loadAnimeListSnapshot(activeClient, id),
|
||||
onError: (e) => appLogger.d('$logLabel: failed to fetch anime list snapshot ($name=$id)', error: e),
|
||||
)
|
||||
.catchError((Object _) => null);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../models/mal/mal_anime.dart';
|
||||
import '../../../models/mal/mal_character.dart';
|
||||
import '../../../models/trackers/anime_list_snapshot.dart';
|
||||
import '../../../utils/app_logger.dart';
|
||||
import '../../../utils/json_utils.dart';
|
||||
import '../future_coalescer.dart';
|
||||
@@ -152,11 +153,19 @@ class MalClient implements DisposableTrackerClient {
|
||||
return MalPage.fromJson(res, MalAnime.fromJson);
|
||||
}
|
||||
|
||||
Future<int?> getAnimeEpisodeCount(int animeId) async {
|
||||
final res = await _request('GET', '/anime/$animeId?fields=num_episodes');
|
||||
/// Episode count plus the viewer's list status in one request, so the
|
||||
/// rewatch-preserving scrobble path costs no extra call.
|
||||
Future<AnimeListSnapshot?> getAnimeListSnapshot(int animeId) async {
|
||||
final res = await _request('GET', '/anime/$animeId?fields=num_episodes,my_list_status');
|
||||
if (res is! Map) return null;
|
||||
final count = flexibleInt(res['num_episodes']);
|
||||
return count != null && count > 0 ? count : null;
|
||||
final list = res['my_list_status'];
|
||||
return AnimeListSnapshot(
|
||||
episodeCount: count != null && count > 0 ? count : null,
|
||||
rewatching: list is Map && flexibleBool(list['is_rewatching']),
|
||||
completed: list is Map && list['status'] == 'completed',
|
||||
rewatchCount: list is Map ? (flexibleInt(list['num_times_rewatched']) ?? 0) : 0,
|
||||
);
|
||||
}
|
||||
|
||||
Future<TrackerSession> _refresh() => _refreshCoalescer.run(_doRefresh);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../../models/trackers/anime_ids.dart';
|
||||
import '../../../models/trackers/anime_list_snapshot.dart';
|
||||
import '../../../utils/app_logger.dart';
|
||||
import '../anime_list_tracker_base.dart';
|
||||
import '../tracker.dart';
|
||||
@@ -52,7 +53,7 @@ class MalTracker extends TrackerBase with ClientBackedTracker<MalClient>, AnimeL
|
||||
int? animeId(AnimeIds? anime) => anime?.mal;
|
||||
|
||||
@override
|
||||
Future<int?> loadAnimeEpisodeCount(MalClient client, int malId) => client.getAnimeEpisodeCount(malId);
|
||||
Future<AnimeListSnapshot?> loadAnimeListSnapshot(MalClient client, int malId) => client.getAnimeListSnapshot(malId);
|
||||
|
||||
@override
|
||||
Future<void> saveAnimeProgress(
|
||||
@@ -60,8 +61,23 @@ class MalTracker extends TrackerBase with ClientBackedTracker<MalClient>, AnimeL
|
||||
required int animeId,
|
||||
required int progress,
|
||||
required bool completed,
|
||||
required bool rewatching,
|
||||
int? rewatchCount,
|
||||
}) async {
|
||||
final fields = {'status': completed ? 'completed' : 'watching', 'num_watched_episodes': '$progress'};
|
||||
final fields = {'num_watched_episodes': '$progress'};
|
||||
if (rewatching) {
|
||||
// MAL models a rewatch as the existing status (normally completed) plus
|
||||
// is_rewatching, so writing status=watching here would yank the show out
|
||||
// of the completed list (issue #2026). Omitted form fields are untouched.
|
||||
fields['is_rewatching'] = 'true';
|
||||
} else {
|
||||
fields['status'] = completed ? 'completed' : 'watching';
|
||||
if (rewatchCount != null) {
|
||||
// Finishing a rewatch: land back on completed with the counter bumped.
|
||||
fields['is_rewatching'] = 'false';
|
||||
fields['num_times_rewatched'] = '$rewatchCount';
|
||||
}
|
||||
}
|
||||
await client.updateMyListStatus(animeId, fields);
|
||||
appLogger.d('MAL: updated list status (mal=$animeId, fields=$fields)');
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ class MediaImageHelper {
|
||||
/// Minimum DPR for TV to ensure sharp artwork on large screens
|
||||
static const double _tvMinDpr = 2.0;
|
||||
|
||||
/// Reduced tier caps: tiles at 1.5× DPR, backdrops at ~720p. Smaller
|
||||
/// transcodes mean fewer bytes fetched AND cheaper decodes on weak 32-bit
|
||||
/// hardware; the art cap is masked by the gradient scrims drawn over it.
|
||||
static const double _reducedMaxDpr = 1.5;
|
||||
/// Reduced-tier art caps: backdrops at ~720p, masked by the gradient scrims
|
||||
/// drawn over them. Tiles (posters/thumbs/squares) deliberately keep full
|
||||
/// resolution — capping them reads as blur on large TV panels (#2020) —
|
||||
/// while backdrops are the largest RGBA decodes on screen.
|
||||
static const int _reducedMaxArtWidth = 1280;
|
||||
static const int _reducedMaxArtHeight = 720;
|
||||
|
||||
@@ -89,7 +89,6 @@ class MediaImageHelper {
|
||||
} catch (_) {
|
||||
dpr = reportedDpr;
|
||||
}
|
||||
if (DevicePerformance.isReduced) return min(dpr, _reducedMaxDpr);
|
||||
if (PlatformDetector.isTV()) dpr = max(dpr, _tvMinDpr);
|
||||
return dpr;
|
||||
}
|
||||
@@ -250,23 +249,20 @@ class MediaImageHelper {
|
||||
|
||||
// Full-tier caps are a 1080p baseline scaled to the display, so slots on
|
||||
// a 4K surface decode at the resolution they render at instead of being
|
||||
// GPU-upscaled from phone-sized budgets. Reduced-tier caps stay fixed
|
||||
// (the factor is pinned to 1.0 there, and the explicit pairs keep the
|
||||
// low-RAM budget independent of display probing).
|
||||
// GPU-upscaled from phone-sized budgets. On the reduced tier the factor
|
||||
// is pinned to 1.0, so tiles keep the fixed 1080p baseline there; only
|
||||
// art gets an explicit smaller pair.
|
||||
final budget = DevicePerformance.displayBudgetFactor();
|
||||
int scaled(int cap) => (cap * budget).round();
|
||||
final (int maxW, int maxH) = switch (imageType) {
|
||||
// Reduced-tier caps match the smaller fetch sizes so oversized
|
||||
// originals (failed transcodes, external images) can't decode past
|
||||
// the tile budget on low-RAM hardware.
|
||||
ImageType.poster when DevicePerformance.isReduced => (480, 720),
|
||||
ImageType.poster => (scaled(720), scaled(1080)),
|
||||
// Square music artwork fills the same grid cells as posters, so both
|
||||
// axes cap at the poster width budget.
|
||||
ImageType.square when DevicePerformance.isReduced => (480, 480),
|
||||
ImageType.square => (scaled(720), scaled(720)),
|
||||
ImageType.thumb when DevicePerformance.isReduced => (640, 360),
|
||||
ImageType.thumb => (scaled(960), scaled(540)),
|
||||
// Reduced-tier backdrops match the ~720p fetch cap so oversized
|
||||
// originals (failed transcodes, external images) can't decode past
|
||||
// the low-RAM art budget.
|
||||
ImageType.art when DevicePerformance.isReduced => (_reducedMaxArtWidth, _reducedMaxArtHeight),
|
||||
ImageType.art => (scaled(1920), scaled(1080)),
|
||||
ImageType.logo => (scaled(600), scaled(300)),
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// Whether [context]'s enclosing route is the app's top visible route.
|
||||
///
|
||||
/// `ModalRoute.of(context).isCurrent` only answers for the route's own
|
||||
/// navigator. With nested navigators that is not "nothing is on top": a route
|
||||
/// pushed on an ancestor navigator — e.g. the root-navigator profile picker
|
||||
/// over the nested profile-session navigator (#2034) — covers this route
|
||||
/// while its own `isCurrent` stays true. Walks the hosting route of each
|
||||
/// enclosing navigator up to the root, so any route stacked above [context]'s
|
||||
/// route on any navigator makes this false.
|
||||
bool isRouteChainCurrent(BuildContext context) {
|
||||
ModalRoute<Object?>? route = ModalRoute.of(context);
|
||||
while (route != null) {
|
||||
if (!route.isCurrent) return false;
|
||||
final navigator = route.navigator;
|
||||
if (navigator == null) break;
|
||||
route = ModalRoute.of(navigator.context);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -170,6 +170,10 @@ class HubSectionState extends State<HubSection> with MountedSetStateMixin, Skele
|
||||
_mediaCardKeys.removeWhere((index, _) => index >= widget.hub.items.length);
|
||||
}
|
||||
|
||||
if (widget.hub.id == oldWidget.hub.id) {
|
||||
_followFocusedItem(oldWidget.hub.items);
|
||||
}
|
||||
|
||||
if (widget.hub.items.length != oldWidget.hub.items.length || widget.hub.more != oldWidget.hub.more) {
|
||||
final maxIndex = _totalItemCount == 0 ? 0 : _totalItemCount - 1;
|
||||
if (_focusedIndex > maxIndex) {
|
||||
@@ -178,6 +182,29 @@ class HubSectionState extends State<HubSection> with MountedSetStateMixin, Skele
|
||||
}
|
||||
}
|
||||
|
||||
/// Keep visual focus on the media it was on when the hub's items reorder
|
||||
/// underneath it — a Continue Watching refresh after playback moves the
|
||||
/// just-played item to the front (#1987). The exact item wins; an episode
|
||||
/// that left the row follows its series' replacement entry (next episode).
|
||||
/// When neither is present the positional clamp above applies unchanged.
|
||||
void _followFocusedItem(List<MediaItem> oldItems) {
|
||||
if (identical(oldItems, widget.hub.items)) return;
|
||||
if (_focusedIndex < 0 || _focusedIndex >= oldItems.length) return;
|
||||
final followedIndex = followItemIndex(widget.hub.items, oldItems[_focusedIndex]);
|
||||
if (followedIndex == -1 || followedIndex == _focusedIndex) return;
|
||||
_focusedIndex = followedIndex;
|
||||
widget.focusMemory.remapForHub(_focusMemoryKey, followedIndex);
|
||||
if (_hubFocusNode.hasFocus) {
|
||||
// didUpdateWidget runs during the build phase; notifying listeners or
|
||||
// jumping scroll positions here could setState mid-build upstream.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted || _focusedIndex != followedIndex || !_hubFocusNode.hasFocus) return;
|
||||
_notifyFocusedItemChanged();
|
||||
_scrollToIndex(followedIndex, animate: false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_selectLongPress.dispose();
|
||||
|
||||
@@ -430,13 +430,13 @@ class OptimizedMediaImage extends StatelessWidget {
|
||||
/// `CachedNetworkImage` instead decodes under `ResizeImagePolicy.exact`, which
|
||||
/// pins the logo to whatever ratio those two bounds happen to have.
|
||||
///
|
||||
/// Plex serves logos with `minSize=1&upscale=1`, so the transcode covers the
|
||||
/// requested box on both axes (a 4313×1035 logo asked for at 1200×360 comes
|
||||
/// back 1500×360, aspect intact). `exact` then clamps neither axis down to the
|
||||
/// source and squashes the logo to the bound ratio: on a phone at DPR 3 the
|
||||
/// 400×120 hero slot decodes to exactly 1000×360 — the width capped by
|
||||
/// [MediaImageHelper.getMemCacheDimensions] — turning a 4.17∶1 logo into
|
||||
/// 2.78∶1.
|
||||
/// Plex serves logos as fitting transcodes (`minSize=0&upscale=0`), so the
|
||||
/// image comes back inside the requested box with aspect intact (a 4313×1035
|
||||
/// logo asked for at 1200×360 comes back 1200×288). `exact` ignores the
|
||||
/// source ratio and decodes to whatever ratio the two bounds happen to have:
|
||||
/// on a phone at DPR 3 the 400×120 hero slot decodes to exactly 1000×360 —
|
||||
/// the width capped by [MediaImageHelper.getMemCacheDimensions] — turning a
|
||||
/// 4.17∶1 logo into 2.78∶1.
|
||||
///
|
||||
/// [fallbackBuilder] renders the title in place of the logo when the path is
|
||||
/// missing, the URL can't be built, or the image fails to load.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ui' show lerpDouble;
|
||||
import '../media/ids.dart';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
@@ -68,8 +69,23 @@ KeyEventResult _handleRailItemKey(KeyEvent event, {required VoidCallback onSelec
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
/// Reusable navigation rail item widget that handles focus, selection, and interaction
|
||||
/// Reusable navigation rail item widget that handles focus, selection, and interaction.
|
||||
///
|
||||
/// Renders the two M3 Expressive destination layouts and morphs between them:
|
||||
/// collapsed is an icon-only 56x32 pill indicator centered in the strip
|
||||
/// (announced via [collapsedLabel]); expanded is a full-width stadium row
|
||||
/// with leading icon and [label]. Items that never render collapsed
|
||||
/// (library rows) leave [collapsedLabel] null and always use the expanded
|
||||
/// layout.
|
||||
class NavigationRailItem extends StatelessWidget {
|
||||
/// M3E collapsed-rail active indicator geometry.
|
||||
static const double collapsedIndicatorWidth = 56;
|
||||
static const double collapsedIndicatorHeight = 32;
|
||||
|
||||
/// Fixed collapsed item height so the collapse morph interpolates between
|
||||
/// known extents (32px pill + breathing room).
|
||||
static const double collapsedItemHeight = 40;
|
||||
|
||||
final IconData icon;
|
||||
final IconData? selectedIcon;
|
||||
|
||||
@@ -78,17 +94,30 @@ class NavigationRailItem extends StatelessWidget {
|
||||
final Widget? iconWidget;
|
||||
final Widget label;
|
||||
|
||||
/// Semantic label for the icon-only collapsed pill. Null means the item
|
||||
/// has no collapsed representation and always lays out expanded.
|
||||
final String? collapsedLabel;
|
||||
|
||||
/// Widget rendered after the [label] (e.g. a section header's chevron).
|
||||
/// Expanded layout only.
|
||||
final Widget? trailing;
|
||||
final bool isSelected;
|
||||
final bool isCollapsed;
|
||||
final bool useSimpleLayout;
|
||||
final VoidCallback onTap;
|
||||
final FocusNode focusNode;
|
||||
final bool autofocus;
|
||||
final BorderRadius borderRadius;
|
||||
final double iconSize;
|
||||
|
||||
/// Horizontal content padding of the expanded row.
|
||||
final double horizontalPadding;
|
||||
|
||||
/// Fixed content width of the expanded layout, so the collapse morph and
|
||||
/// the rail width animation stay in lockstep.
|
||||
final double expandedContentWidth;
|
||||
|
||||
/// Expanded row height: fixed for collapsible items, a minimum for
|
||||
/// expanded-only items (whose labels may add a second line).
|
||||
final double expandedHeight;
|
||||
final bool suppressSelectedBackground;
|
||||
|
||||
/// Background tint while keyboard-focused, and its stronger variant used
|
||||
@@ -105,31 +134,156 @@ class NavigationRailItem extends StatelessWidget {
|
||||
this.selectedIcon,
|
||||
this.iconWidget,
|
||||
required this.label,
|
||||
this.collapsedLabel,
|
||||
this.trailing,
|
||||
required this.isSelected,
|
||||
this.isCollapsed = false,
|
||||
this.useSimpleLayout = false,
|
||||
required this.onTap,
|
||||
required this.focusNode,
|
||||
this.autofocus = false,
|
||||
this.borderRadius = const BorderRadius.all(Radius.circular(12)),
|
||||
this.iconSize = 22,
|
||||
this.horizontalPadding = 17,
|
||||
this.expandedContentWidth = SideNavigationRailState.expandedWidth - 24,
|
||||
this.expandedHeight = 48,
|
||||
this.suppressSelectedBackground = false,
|
||||
this.focusAlpha = 0.12,
|
||||
this.selectedFocusAlpha = 0.15,
|
||||
this.onNavigateRight,
|
||||
});
|
||||
|
||||
Color? _indicatorColor(MonoTokens t, {required bool focused, required bool collapsedLayout}) {
|
||||
// The collapsed TV rail is a transparent overlay strip; a persistent
|
||||
// active pill over artwork is noise there, so it shows focus only.
|
||||
final showSelected = isSelected && !suppressSelectedBackground && !(collapsedLayout && PlatformDetector.isTV());
|
||||
if (focused) return t.text.withValues(alpha: showSelected ? selectedFocusAlpha : focusAlpha);
|
||||
if (showSelected) return t.text.withValues(alpha: 0.1);
|
||||
return null;
|
||||
}
|
||||
|
||||
Widget _leadingIcon(MonoTokens t) =>
|
||||
iconWidget ??
|
||||
AppIcon(
|
||||
isSelected && selectedIcon != null ? selectedIcon! : icon,
|
||||
fill: 1,
|
||||
size: iconSize,
|
||||
color: isSelected ? t.text : t.textMuted,
|
||||
);
|
||||
|
||||
static double _collapsedItemWidth(BuildContext context) =>
|
||||
SideNavigationRailState.collapsedWidthForContext(context) -
|
||||
2 * SideNavigationRailState.horizontalPaddingForContext(context, isCollapsed: true);
|
||||
|
||||
/// M3E collapsed destination: an icon-only pill indicator.
|
||||
Widget _buildCollapsedLayout(BuildContext context, MonoTokens t, {required bool focused}) {
|
||||
final width = _collapsedItemWidth(context);
|
||||
return SizedBox(
|
||||
width: width,
|
||||
height: collapsedItemHeight,
|
||||
child: Center(
|
||||
child: Semantics(
|
||||
label: collapsedLabel,
|
||||
child: Container(
|
||||
width: width < collapsedIndicatorWidth ? width : collapsedIndicatorWidth,
|
||||
height: collapsedIndicatorHeight,
|
||||
alignment: .center,
|
||||
decoration: BoxDecoration(
|
||||
color: _indicatorColor(t, focused: focused, collapsedLayout: true),
|
||||
borderRadius: BorderRadius.circular(MonoTokens.radiusFull),
|
||||
),
|
||||
child: _leadingIcon(t),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// M3E expanded destination: full-width stadium indicator behind the row.
|
||||
Widget _buildExpandedLayout(MonoTokens t, {required bool focused, required bool fixedHeight}) {
|
||||
return Container(
|
||||
constraints: fixedHeight ? null : BoxConstraints(minHeight: expandedHeight),
|
||||
alignment: .centerLeft,
|
||||
padding: EdgeInsets.symmetric(horizontal: horizontalPadding, vertical: fixedHeight ? 0 : 8),
|
||||
decoration: BoxDecoration(
|
||||
color: _indicatorColor(t, focused: focused, collapsedLayout: false),
|
||||
borderRadius: BorderRadius.circular(MonoTokens.radiusFull),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_leadingIcon(t),
|
||||
const SizedBox(width: 11),
|
||||
Expanded(child: label),
|
||||
?trailing,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// At the endpoints only the active layout exists in the tree; mid-morph
|
||||
/// both are stacked and crossfaded inside a box that lerps between their
|
||||
/// fixed extents, tracking the rail's own width animation tick for tick.
|
||||
Widget _buildMorphingLayouts(BuildContext context, MonoTokens t, {required bool focused, required double expansion}) {
|
||||
if (expansion <= 0) return _buildCollapsedLayout(context, t, focused: focused);
|
||||
if (expansion >= 1) {
|
||||
return SizedBox(
|
||||
width: expandedContentWidth,
|
||||
height: expandedHeight,
|
||||
child: _buildExpandedLayout(t, focused: focused, fixedHeight: true),
|
||||
);
|
||||
}
|
||||
final collapsedWidth = _collapsedItemWidth(context);
|
||||
const collapsedHeight = collapsedItemHeight;
|
||||
// Both children keep their natural fixed extents and are only clipped by
|
||||
// the lerping box, so neither layout is ever squeezed mid-morph.
|
||||
return SizedBox(
|
||||
width: lerpDouble(collapsedWidth, expandedContentWidth, expansion),
|
||||
height: lerpDouble(collapsedHeight, expandedHeight, expansion),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: 0,
|
||||
child: Opacity(
|
||||
opacity: 1 - expansion,
|
||||
child: _buildCollapsedLayout(context, t, focused: focused),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: 0,
|
||||
child: Opacity(
|
||||
opacity: expansion,
|
||||
child: SizedBox(
|
||||
width: expandedContentWidth,
|
||||
height: expandedHeight,
|
||||
child: _buildExpandedLayout(t, focused: focused, fixedHeight: true),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final t = tokens(context);
|
||||
final showSelectedBackground = isSelected && !suppressSelectedBackground;
|
||||
|
||||
return ListenableBuilder(
|
||||
listenable: focusNode,
|
||||
builder: (context, _) {
|
||||
final focused = focusNode.hasFocus && InputModeTracker.isKeyboardMode(context);
|
||||
final content = collapsedLabel == null
|
||||
? SizedBox(
|
||||
width: expandedContentWidth,
|
||||
child: _buildExpandedLayout(t, focused: focused, fixedHeight: false),
|
||||
)
|
||||
: TweenAnimationBuilder<double>(
|
||||
tween: Tween(end: isCollapsed ? 0.0 : 1.0),
|
||||
duration: SideNavigationRailState.expandDuration,
|
||||
curve: SideNavigationRailState.expandCurve,
|
||||
builder: (context, expansion, _) =>
|
||||
_buildMorphingLayouts(context, t, focused: focused, expansion: expansion),
|
||||
);
|
||||
return Focus(
|
||||
focusNode: focusNode,
|
||||
autofocus: autofocus,
|
||||
@@ -139,51 +293,12 @@ class NavigationRailItem extends StatelessWidget {
|
||||
child: InkWell(
|
||||
canRequestFocus: false,
|
||||
onTap: onTap,
|
||||
borderRadius: borderRadius,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: () {
|
||||
if (isCollapsed) return focused ? t.text.withValues(alpha: focusAlpha) : null;
|
||||
if (focused) {
|
||||
return t.text.withValues(alpha: showSelectedBackground ? selectedFocusAlpha : focusAlpha);
|
||||
}
|
||||
if (showSelectedBackground) return t.text.withValues(alpha: 0.1);
|
||||
return null;
|
||||
}(),
|
||||
borderRadius: borderRadius,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(MonoTokens.radiusFull),
|
||||
child: UnconstrainedBox(
|
||||
alignment: .centerLeft,
|
||||
constrainedAxis: Axis.vertical,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: UnconstrainedBox(
|
||||
alignment: .centerLeft,
|
||||
constrainedAxis: Axis.vertical,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: SizedBox(
|
||||
width: SideNavigationRailState.expandedWidth - 24,
|
||||
child: Padding(
|
||||
padding: .symmetric(vertical: 12, horizontal: horizontalPadding),
|
||||
child: Row(
|
||||
children: [
|
||||
iconWidget ??
|
||||
AppIcon(
|
||||
isSelected && selectedIcon != null ? selectedIcon! : icon,
|
||||
fill: 1,
|
||||
size: iconSize,
|
||||
color: isSelected ? t.text : t.textMuted,
|
||||
),
|
||||
const SizedBox(width: 11),
|
||||
Expanded(
|
||||
child: () {
|
||||
if (useSimpleLayout) return label;
|
||||
final opacity = isCollapsed ? 0.0 : 1.0;
|
||||
return AnimatedOpacity(opacity: opacity, duration: t.fast, child: label);
|
||||
}(),
|
||||
),
|
||||
?trailing,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -207,12 +322,13 @@ class SideNavigationRail extends StatefulWidget {
|
||||
/// Called when RIGHT arrow is pressed to navigate to content without selecting.
|
||||
final VoidCallback? onNavigateToContent;
|
||||
|
||||
/// Called when hover/touch expansion changes, so the shell can reserve width.
|
||||
final ValueChanged<bool>? onInteractionExpandedChanged;
|
||||
|
||||
/// Called when the user taps the reconnect button in offline mode.
|
||||
final VoidCallback? onReconnect;
|
||||
|
||||
/// Called when hover/touch expansion changes, so the shell can scrim the
|
||||
/// content the modal rail overlays.
|
||||
final ValueChanged<bool>? onInteractionExpandedChanged;
|
||||
|
||||
const SideNavigationRail({
|
||||
super.key,
|
||||
required this.selectedTab,
|
||||
@@ -246,25 +362,27 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
static const double tvCollapsedWidth = 48.0;
|
||||
static const double expandedWidth = 220.0;
|
||||
static const double _horizontalPadding = 12.0;
|
||||
static const double _itemHorizontalPadding = 17.0;
|
||||
static const double _defaultIconSize = 22.0;
|
||||
static const double _collapsedHorizontalPadding = 4.0;
|
||||
static const double _itemGap = 4.0;
|
||||
static const Duration _collapseDelay = Duration(milliseconds: 150);
|
||||
|
||||
/// Trailing corner radius of the floating (hover/touch) overlay panel; the
|
||||
/// docked open rail keeps the regular radiusLg card rounding.
|
||||
static const double overlayCornerRadius = 32.0;
|
||||
|
||||
/// Collapse/expand morph timing, shared by the rail width, every item's
|
||||
/// layout morph, and the shell's content translate + bleed counter
|
||||
/// animations (MainScreen and SideNavigationBleedBuilder) so they all
|
||||
/// track tick for tick.
|
||||
static const Duration expandDuration = Duration(milliseconds: 250);
|
||||
static const Curve expandCurve = Curves.easeInOutCubicEmphasized;
|
||||
|
||||
static double collapsedWidthForContext(BuildContext _) => PlatformDetector.isTV() ? tvCollapsedWidth : collapsedWidth;
|
||||
|
||||
static double itemHorizontalPaddingForContext(BuildContext context, {required bool isCollapsed}) {
|
||||
if (isCollapsed && PlatformDetector.isTV()) {
|
||||
return ((tvCollapsedWidth - _defaultIconSize) / 2).clamp(0.0, _itemHorizontalPadding).toDouble();
|
||||
}
|
||||
return _itemHorizontalPadding;
|
||||
}
|
||||
|
||||
static double horizontalPaddingForContext(BuildContext context, {required bool isCollapsed}) {
|
||||
if (!isCollapsed) return _horizontalPadding;
|
||||
final centeredPadding =
|
||||
((collapsedWidthForContext(context) - _defaultIconSize) / 2) -
|
||||
itemHorizontalPaddingForContext(context, isCollapsed: isCollapsed);
|
||||
return centeredPadding.clamp(0.0, _horizontalPadding).toDouble();
|
||||
/// Edge padding around the item column; collapsed rails center their items
|
||||
/// (72px in the 80px desktop strip, 40px in the 48px TV strip).
|
||||
static double horizontalPaddingForContext(BuildContext _, {required bool isCollapsed}) {
|
||||
return isCollapsed ? _collapsedHorizontalPadding : _horizontalPadding;
|
||||
}
|
||||
|
||||
static const _kHome = 'home';
|
||||
@@ -322,6 +440,8 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
}
|
||||
}
|
||||
|
||||
/// didUpdateWidget runs during build, where notifying the parent would
|
||||
/// setState mid-build; defer that report to the next frame.
|
||||
void _scheduleInteractionExpandedNotification() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
@@ -651,7 +771,6 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
final isCollapsed = !_shouldExpand;
|
||||
final effectiveCollapsedWidth = collapsedWidthForContext(context);
|
||||
final horizontalPadding = horizontalPaddingForContext(context, isCollapsed: isCollapsed);
|
||||
final itemHorizontalPadding = itemHorizontalPaddingForContext(context, isCollapsed: isCollapsed);
|
||||
final hasLiveTv = context.watch<MultiServerProvider>().hasLiveTv;
|
||||
// Nullable watch: rail tests (and any host without the profile session
|
||||
// scope) simply never show the Explore item.
|
||||
@@ -725,19 +844,42 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: isCollapsed ? _expandForTouch : null,
|
||||
child: AnimatedContainer(
|
||||
duration: t.normal,
|
||||
curve: Curves.easeOutCubic,
|
||||
duration: expandDuration,
|
||||
curve: expandCurve,
|
||||
width: isCollapsed ? effectiveCollapsedWidth : expandedWidth,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: const BoxDecoration(),
|
||||
child: Stack(
|
||||
children: [
|
||||
// Desktop surface. Hover/touch expansion is an M3E
|
||||
// modal rail: it overlays the content (the shell keeps
|
||||
// its collapsed offset), so it casts an edge shadow.
|
||||
Positioned.fill(
|
||||
child: AnimatedOpacity(
|
||||
opacity: PlatformDetector.isTV() ? 0.0 : 1.0,
|
||||
duration: t.normal,
|
||||
curve: Curves.easeOutCubic,
|
||||
child: ColoredBox(color: t.surface),
|
||||
child: AnimatedContainer(
|
||||
duration: expandDuration,
|
||||
curve: expandCurve,
|
||||
decoration: BoxDecoration(
|
||||
color: t.surface,
|
||||
// Open rails read as an M3E panel: rounded
|
||||
// trailing corners, extra-rounded plus an edge
|
||||
// shadow while floating over content (modal)
|
||||
// instead of pushing it.
|
||||
borderRadius: isCollapsed
|
||||
? BorderRadius.zero
|
||||
: BorderRadius.horizontal(
|
||||
right: Radius.circular(
|
||||
_interactionExpanded && !widget.alwaysExpanded ? overlayCornerRadius : t.radiusLg,
|
||||
),
|
||||
),
|
||||
boxShadow: _interactionExpanded && !widget.alwaysExpanded
|
||||
? [BoxShadow(color: Colors.black.withValues(alpha: 0.35), blurRadius: 24)]
|
||||
: const [],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
IgnorePointer(
|
||||
@@ -750,103 +892,109 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
children: [
|
||||
SizedBox(height: _getTopPadding(context)),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
child: AnimatedPadding(
|
||||
padding: .symmetric(horizontal: horizontalPadding),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
if (widget.isOfflineMode && widget.onReconnect != null) ...[
|
||||
_buildReconnectItem(isCollapsed: isCollapsed),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
if (!widget.isOfflineMode) ...[
|
||||
_buildNavItem(
|
||||
icon: Symbols.home_rounded,
|
||||
selectedIcon: Symbols.home_rounded,
|
||||
label: Translations.of(context).common.home,
|
||||
isSelected: widget.selectedTab == NavigationTabId.discover,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.discover),
|
||||
focusNode: _focusTracker.get(_kHome),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Now Playing — only while a music session is live.
|
||||
if (nowPlayingTrack != null && musicService != null) ...[
|
||||
_buildNowPlayingItem(nowPlayingTrack, musicService, isCollapsed: isCollapsed),
|
||||
const SizedBox(height: 8),
|
||||
duration: expandDuration,
|
||||
curve: expandCurve,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
if (widget.isOfflineMode && widget.onReconnect != null) ...[
|
||||
_buildReconnectItem(isCollapsed: isCollapsed),
|
||||
const SizedBox(height: _itemGap),
|
||||
],
|
||||
_buildLibrariesSection(
|
||||
visibleRows,
|
||||
hiddenRows,
|
||||
hiddenLibraries.length,
|
||||
t,
|
||||
isCollapsed: isCollapsed,
|
||||
itemHorizontalPadding: itemHorizontalPadding,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
if (context.watch<MultiServerProvider>().hasLiveTv) ...[
|
||||
if (!widget.isOfflineMode) ...[
|
||||
_buildNavItem(
|
||||
icon: Symbols.live_tv_rounded,
|
||||
selectedIcon: Symbols.live_tv_rounded,
|
||||
label: Translations.of(context).navigation.liveTv,
|
||||
isSelected: widget.selectedTab == NavigationTabId.liveTv,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.liveTv),
|
||||
focusNode: _focusTracker.get('liveTv'),
|
||||
icon: Symbols.home_rounded,
|
||||
selectedIcon: Symbols.home_rounded,
|
||||
label: Translations.of(context).common.home,
|
||||
isSelected: widget.selectedTab == NavigationTabId.discover,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.discover),
|
||||
focusNode: _focusTracker.get(_kHome),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
if (hasExplore) ...[
|
||||
_buildNavItem(
|
||||
icon: Symbols.explore_rounded,
|
||||
selectedIcon: Symbols.explore_rounded,
|
||||
label: Translations.of(context).navigation.explore,
|
||||
isSelected: widget.selectedTab == NavigationTabId.explore,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.explore),
|
||||
focusNode: _focusTracker.get(_kExplore),
|
||||
const SizedBox(height: _itemGap),
|
||||
// Now Playing — only while a music session is live.
|
||||
if (nowPlayingTrack != null && musicService != null) ...[
|
||||
_buildNowPlayingItem(nowPlayingTrack, musicService, isCollapsed: isCollapsed),
|
||||
const SizedBox(height: _itemGap),
|
||||
],
|
||||
_buildLibrariesSection(
|
||||
visibleRows,
|
||||
hiddenRows,
|
||||
hiddenLibraries.length,
|
||||
t,
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const SizedBox(height: _itemGap),
|
||||
if (context.watch<MultiServerProvider>().hasLiveTv) ...[
|
||||
_buildNavItem(
|
||||
icon: Symbols.live_tv_rounded,
|
||||
selectedIcon: Symbols.live_tv_rounded,
|
||||
label: Translations.of(context).navigation.liveTv,
|
||||
isSelected: widget.selectedTab == NavigationTabId.liveTv,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.liveTv),
|
||||
focusNode: _focusTracker.get('liveTv'),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: _itemGap),
|
||||
],
|
||||
if (hasExplore) ...[
|
||||
_buildNavItem(
|
||||
icon: Symbols.explore_rounded,
|
||||
selectedIcon: Symbols.explore_rounded,
|
||||
label: Translations.of(context).navigation.explore,
|
||||
isSelected: widget.selectedTab == NavigationTabId.explore,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.explore),
|
||||
focusNode: _focusTracker.get(_kExplore),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: _itemGap),
|
||||
],
|
||||
_buildNavItem(
|
||||
icon: Symbols.search_rounded,
|
||||
selectedIcon: Symbols.search_rounded,
|
||||
label: Translations.of(context).common.search,
|
||||
isSelected: widget.selectedTab == NavigationTabId.search,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.search),
|
||||
focusNode: _focusTracker.get(_kSearch),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: _itemGap),
|
||||
],
|
||||
// Downloads (hidden on Apple TV — no user
|
||||
// file storage)
|
||||
if (_showDownloads) ...[
|
||||
_buildNavItem(
|
||||
icon: Symbols.download_rounded,
|
||||
selectedIcon: Symbols.download_rounded,
|
||||
label: Translations.of(context).navigation.downloads,
|
||||
isSelected: widget.selectedTab == NavigationTabId.downloads,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.downloads),
|
||||
focusNode: _focusTracker.get(_kDownloads),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: _itemGap),
|
||||
],
|
||||
_buildNavItem(
|
||||
icon: Symbols.search_rounded,
|
||||
selectedIcon: Symbols.search_rounded,
|
||||
label: Translations.of(context).common.search,
|
||||
isSelected: widget.selectedTab == NavigationTabId.search,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.search),
|
||||
focusNode: _focusTracker.get(_kSearch),
|
||||
icon: Symbols.settings_rounded,
|
||||
selectedIcon: Symbols.settings_rounded,
|
||||
label: Translations.of(context).common.settings,
|
||||
isSelected: widget.selectedTab == NavigationTabId.settings,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.settings),
|
||||
focusNode: _focusTracker.get(_kSettings),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
// Downloads (hidden on Apple TV — no user
|
||||
// file storage)
|
||||
if (_showDownloads) ...[
|
||||
_buildNavItem(
|
||||
icon: Symbols.download_rounded,
|
||||
selectedIcon: Symbols.download_rounded,
|
||||
label: Translations.of(context).navigation.downloads,
|
||||
isSelected: widget.selectedTab == NavigationTabId.downloads,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.downloads),
|
||||
focusNode: _focusTracker.get(_kDownloads),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
_buildNavItem(
|
||||
icon: Symbols.settings_rounded,
|
||||
selectedIcon: Symbols.settings_rounded,
|
||||
label: Translations.of(context).common.settings,
|
||||
isSelected: widget.selectedTab == NavigationTabId.settings,
|
||||
onTap: () => widget.onDestinationSelected(NavigationTabId.settings),
|
||||
focusNode: _focusTracker.get(_kSettings),
|
||||
isCollapsed: isCollapsed,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_showFullscreenToggle)
|
||||
Padding(
|
||||
AnimatedPadding(
|
||||
padding: .fromLTRB(horizontalPadding, 0, horizontalPadding, 12),
|
||||
duration: expandDuration,
|
||||
curve: expandCurve,
|
||||
child: _buildFullscreenItem(isCollapsed: isCollapsed),
|
||||
),
|
||||
],
|
||||
@@ -874,7 +1022,6 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
bool autofocus = false,
|
||||
}) {
|
||||
final t = tokens(context);
|
||||
final itemHorizontalPadding = itemHorizontalPaddingForContext(context, isCollapsed: isCollapsed);
|
||||
|
||||
return NavigationRailItem(
|
||||
icon: icon,
|
||||
@@ -889,12 +1036,12 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
overflow: .ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
collapsedLabel: label,
|
||||
isSelected: isSelected,
|
||||
isCollapsed: isCollapsed,
|
||||
onTap: onTap,
|
||||
focusNode: focusNode,
|
||||
autofocus: autofocus,
|
||||
horizontalPadding: itemHorizontalPadding,
|
||||
suppressSelectedBackground: widget.isSidebarFocused,
|
||||
onNavigateRight: widget.onNavigateToContent,
|
||||
);
|
||||
@@ -905,7 +1052,6 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
/// opens the now-playing screen.
|
||||
Widget _buildNowPlayingItem(MediaItem track, MusicPlaybackService musicService, {required bool isCollapsed}) {
|
||||
final t = tokens(context);
|
||||
final itemHorizontalPadding = itemHorizontalPaddingForContext(context, isCollapsed: isCollapsed);
|
||||
|
||||
return NavigationRailItem(
|
||||
icon: Symbols.music_note_rounded,
|
||||
@@ -933,19 +1079,17 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
),
|
||||
],
|
||||
),
|
||||
collapsedLabel: Translations.of(context).music.nowPlaying,
|
||||
isSelected: false,
|
||||
isCollapsed: isCollapsed,
|
||||
useSimpleLayout: true,
|
||||
onTap: () => unawaited(openNowPlaying(context)),
|
||||
focusNode: _focusTracker.get(_kNowPlaying),
|
||||
horizontalPadding: itemHorizontalPadding,
|
||||
onNavigateRight: widget.onNavigateToContent,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildReconnectItem({required bool isCollapsed}) {
|
||||
final t = tokens(context);
|
||||
final itemHorizontalPadding = itemHorizontalPaddingForContext(context, isCollapsed: isCollapsed);
|
||||
|
||||
return NavigationRailItem(
|
||||
icon: widget.isReconnecting ? Symbols.sync_rounded : Symbols.wifi_rounded,
|
||||
@@ -957,12 +1101,12 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
overflow: .ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
collapsedLabel: Translations.of(context).common.reconnect,
|
||||
isSelected: false,
|
||||
isCollapsed: isCollapsed,
|
||||
// ignore: no-empty-block - no-op tap handler while reconnecting
|
||||
onTap: widget.isReconnecting ? () {} : () => widget.onReconnect?.call(),
|
||||
focusNode: _focusTracker.get(_kReconnect),
|
||||
horizontalPadding: itemHorizontalPadding,
|
||||
onNavigateRight: widget.onNavigateToContent,
|
||||
);
|
||||
}
|
||||
@@ -970,21 +1114,23 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
Widget _buildFullscreenItem({required bool isCollapsed}) {
|
||||
final t = tokens(context);
|
||||
final isFullscreen = FullscreenStateManager().isFullscreen;
|
||||
final itemHorizontalPadding = itemHorizontalPaddingForContext(context, isCollapsed: isCollapsed);
|
||||
final label = isFullscreen
|
||||
? Translations.of(context).common.exitFullscreen
|
||||
: Translations.of(context).common.fullscreen;
|
||||
|
||||
return NavigationRailItem(
|
||||
icon: isFullscreen ? Symbols.fullscreen_exit_rounded : Symbols.fullscreen_rounded,
|
||||
label: Text(
|
||||
isFullscreen ? Translations.of(context).common.exitFullscreen : Translations.of(context).common.fullscreen,
|
||||
label,
|
||||
style: TextStyle(fontSize: 14, fontWeight: .w400, color: t.textMuted),
|
||||
overflow: .ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
collapsedLabel: label,
|
||||
isSelected: false,
|
||||
isCollapsed: isCollapsed,
|
||||
onTap: () => unawaited(FullscreenStateManager().toggleFullscreen()),
|
||||
focusNode: _focusTracker.get(_kFullscreen),
|
||||
horizontalPadding: itemHorizontalPadding,
|
||||
onNavigateRight: widget.onNavigateToContent,
|
||||
);
|
||||
}
|
||||
@@ -995,7 +1141,6 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
int hiddenLibraryCount,
|
||||
dynamic t, {
|
||||
bool isCollapsed = false,
|
||||
required double itemHorizontalPadding,
|
||||
}) {
|
||||
final librariesProvider = context.watch<LibrariesProvider>();
|
||||
final isLoading = librariesProvider.isLoading;
|
||||
@@ -1005,6 +1150,9 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
return Column(
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
// A destination-sized row like Home/Search — same height, icon and
|
||||
// label metrics — with the chevron as the expand affordance. The
|
||||
// smaller header type is reserved for the nested sub-headers.
|
||||
NavigationRailItem(
|
||||
icon: Symbols.video_library_rounded,
|
||||
label: Text(
|
||||
@@ -1014,24 +1162,21 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
fontWeight: isLibrariesTabSelected ? FontWeight.w600 : FontWeight.w400,
|
||||
color: isLibrariesTabSelected ? t.text : t.textMuted,
|
||||
),
|
||||
overflow: .ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
trailing: AnimatedOpacity(
|
||||
opacity: isCollapsed ? 0.0 : 1.0,
|
||||
duration: tokens(context).fast,
|
||||
child: AppIcon(
|
||||
_librariesExpanded ? Symbols.expand_less_rounded : Symbols.expand_more_rounded,
|
||||
fill: 1,
|
||||
size: 20,
|
||||
color: t.textMuted,
|
||||
),
|
||||
collapsedLabel: Translations.of(context).navigation.libraries,
|
||||
trailing: AppIcon(
|
||||
_librariesExpanded ? Symbols.expand_less_rounded : Symbols.expand_more_rounded,
|
||||
fill: 1,
|
||||
size: 18,
|
||||
color: t.textMuted,
|
||||
),
|
||||
isSelected: isLibrariesTabSelected,
|
||||
isCollapsed: isCollapsed,
|
||||
onTap: () =>
|
||||
unawaited(SettingsService.instance.write(SettingsService.librariesSectionExpanded, !_librariesExpanded)),
|
||||
focusNode: _focusTracker.get(_kLibraries),
|
||||
borderRadius: BorderRadius.circular(tokens(context).radiusMd),
|
||||
horizontalPadding: itemHorizontalPadding,
|
||||
// A selected library owns the highlight; the header only shows it
|
||||
// for the bare Libraries tab.
|
||||
suppressSelectedBackground: widget.isSidebarFocused || widget.selectedLibraryKey != null,
|
||||
@@ -1042,8 +1187,8 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
|
||||
TweenAnimationBuilder<double>(
|
||||
tween: Tween(end: (_librariesExpanded && !isCollapsed) ? 1.0 : 0.0),
|
||||
duration: tokens(context).normal,
|
||||
curve: Curves.easeOutCubic,
|
||||
duration: expandDuration,
|
||||
curve: expandCurve,
|
||||
builder: (context, value, child) {
|
||||
return ClipRect(
|
||||
child: Align(alignment: .topCenter, heightFactor: value, child: child),
|
||||
@@ -1176,53 +1321,51 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
required dynamic t,
|
||||
}) {
|
||||
final focusNode = _focusTracker.get(focusKey);
|
||||
final radius = BorderRadius.circular(tokens(context).radiusSm);
|
||||
// Match library-item indent: outer Padding(left: 12) + inner horizontal 17.
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: ListenableBuilder(
|
||||
listenable: focusNode,
|
||||
builder: (context, _) => Focus(
|
||||
focusNode: focusNode,
|
||||
onKeyEvent: (node, event) =>
|
||||
_handleRailItemKey(event, onSelect: onToggle, onNavigateRight: widget.onNavigateToContent),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
canRequestFocus: false,
|
||||
onTap: onToggle,
|
||||
borderRadius: radius,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: focusNode.hasFocus && InputModeTracker.isKeyboardMode(context)
|
||||
? t.text.withValues(alpha: 0.08)
|
||||
: null,
|
||||
borderRadius: radius,
|
||||
),
|
||||
final radius = BorderRadius.circular(MonoTokens.radiusFull);
|
||||
// Sub-section header at full rail width; the smaller type alone carries
|
||||
// the hierarchy, matching M3E expanded-rail sections.
|
||||
return ListenableBuilder(
|
||||
listenable: focusNode,
|
||||
builder: (context, _) => Focus(
|
||||
focusNode: focusNode,
|
||||
onKeyEvent: (node, event) =>
|
||||
_handleRailItemKey(event, onSelect: onToggle, onNavigateRight: widget.onNavigateToContent),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
canRequestFocus: false,
|
||||
onTap: onToggle,
|
||||
borderRadius: radius,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: focusNode.hasFocus && InputModeTracker.isKeyboardMode(context)
|
||||
? t.text.withValues(alpha: 0.08)
|
||||
: null,
|
||||
borderRadius: radius,
|
||||
),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: UnconstrainedBox(
|
||||
alignment: .centerLeft,
|
||||
constrainedAxis: Axis.vertical,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: UnconstrainedBox(
|
||||
alignment: .centerLeft,
|
||||
constrainedAxis: Axis.vertical,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: SizedBox(
|
||||
width: expandedWidth - 24,
|
||||
child: Padding(
|
||||
padding: .symmetric(vertical: verticalPadding, horizontal: 17),
|
||||
child: Row(
|
||||
children: [
|
||||
leading ?? AppIcon(icon, fill: 1, size: iconSize, color: t.textMuted),
|
||||
const SizedBox(width: 11),
|
||||
Expanded(
|
||||
child: Text(label, style: labelStyle, overflow: .ellipsis),
|
||||
),
|
||||
AppIcon(
|
||||
isExpanded ? Symbols.expand_less_rounded : Symbols.expand_more_rounded,
|
||||
fill: 1,
|
||||
size: 16,
|
||||
color: t.textMuted,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SizedBox(
|
||||
width: expandedWidth - 24,
|
||||
child: Padding(
|
||||
padding: .symmetric(vertical: verticalPadding, horizontal: 17),
|
||||
child: Row(
|
||||
children: [
|
||||
leading ?? AppIcon(icon, fill: 1, size: iconSize, color: t.textMuted),
|
||||
const SizedBox(width: 11),
|
||||
Expanded(
|
||||
child: Text(label, style: labelStyle, overflow: .ellipsis),
|
||||
),
|
||||
AppIcon(
|
||||
isExpanded ? Symbols.expand_less_rounded : Symbols.expand_more_rounded,
|
||||
fill: 1,
|
||||
size: 16,
|
||||
color: t.textMuted,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1240,41 +1383,37 @@ class SideNavigationRailState extends State<SideNavigationRail> with MountedSetS
|
||||
final focusKey = _libraryItemFocusKey(section, library);
|
||||
final focusNode = _focusTracker.get(focusKey);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: NavigationRailItem(
|
||||
icon: ContentTypeHelper.getLibraryIcon(library.kind.id),
|
||||
selectedIcon: ContentTypeHelper.getLibraryIcon(library.kind.id),
|
||||
label: Column(
|
||||
crossAxisAlignment: .start,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
return NavigationRailItem(
|
||||
icon: ContentTypeHelper.getLibraryIcon(library.kind.id),
|
||||
selectedIcon: ContentTypeHelper.getLibraryIcon(library.kind.id),
|
||||
label: Column(
|
||||
crossAxisAlignment: .start,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
Text(
|
||||
library.title,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
|
||||
color: isSelected ? t.text : t.textMuted,
|
||||
),
|
||||
overflow: .ellipsis,
|
||||
),
|
||||
if (showServerName)
|
||||
Text(
|
||||
library.title,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
|
||||
color: isSelected ? t.text : t.textMuted,
|
||||
),
|
||||
library.serverName!,
|
||||
style: TextStyle(fontSize: 9, color: t.textMuted.withValues(alpha: 0.4)),
|
||||
overflow: .ellipsis,
|
||||
),
|
||||
if (showServerName)
|
||||
Text(
|
||||
library.serverName!,
|
||||
style: TextStyle(fontSize: 9, color: t.textMuted.withValues(alpha: 0.4)),
|
||||
overflow: .ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
isSelected: isSelected,
|
||||
useSimpleLayout: true,
|
||||
onTap: () => widget.onLibrarySelected(library.globalKey),
|
||||
focusNode: focusNode,
|
||||
borderRadius: BorderRadius.circular(tokens(context).radiusSm),
|
||||
iconSize: 18,
|
||||
suppressSelectedBackground: widget.isSidebarFocused,
|
||||
onNavigateRight: widget.onNavigateToContent,
|
||||
],
|
||||
),
|
||||
isSelected: isSelected,
|
||||
onTap: () => widget.onLibrarySelected(library.globalKey),
|
||||
focusNode: focusNode,
|
||||
iconSize: 18,
|
||||
expandedHeight: 40,
|
||||
suppressSelectedBackground: widget.isSidebarFocused,
|
||||
onNavigateRight: widget.onNavigateToContent,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,9 +462,11 @@ class TvBrowseRailState extends State<TvBrowseRail> with TickerProviderStateMixi
|
||||
return;
|
||||
}
|
||||
|
||||
final oldActiveHubKey = oldWidget.hubs.isEmpty
|
||||
? null
|
||||
: _hubKey(oldWidget.hubs[_hubIndex.clamp(0, oldWidget.hubs.length - 1)]);
|
||||
final oldActiveHub = oldWidget.hubs.isEmpty ? null : oldWidget.hubs[_hubIndex.clamp(0, oldWidget.hubs.length - 1)];
|
||||
final oldActiveHubKey = oldActiveHub == null ? null : _hubKey(oldActiveHub);
|
||||
final oldFocusedItem = oldActiveHub != null && _itemIndex < oldActiveHub.items.length
|
||||
? oldActiveHub.items[_itemIndex]
|
||||
: null;
|
||||
|
||||
if (widget.hubs.isEmpty) {
|
||||
_hubIndex = 0;
|
||||
@@ -488,6 +490,19 @@ class TvBrowseRailState extends State<TvBrowseRail> with TickerProviderStateMixi
|
||||
|
||||
final hub = _activeHub;
|
||||
if (hub == null) return;
|
||||
var followedFocusedItem = false;
|
||||
if (_hasUserInteracted && oldFocusedItem != null && _hubKey(hub) == oldActiveHubKey) {
|
||||
// Keep the selection on the media it was on when the active hub's items
|
||||
// reorder underneath it — a Continue Watching refresh after playback
|
||||
// moves the just-played item to the front (#1987). When the exact item
|
||||
// left the list, follow its series' replacement entry (finished episode
|
||||
// → next episode); otherwise fall through to the positional clamp.
|
||||
final followedIndex = followItemIndex(hub.items, oldFocusedItem);
|
||||
if (followedIndex != -1 && followedIndex != _itemIndex) {
|
||||
_itemIndex = followedIndex;
|
||||
followedFocusedItem = true;
|
||||
}
|
||||
}
|
||||
_itemIndex = _itemIndex.clamp(0, _totalItemCount(hub) == 0 ? 0 : _totalItemCount(hub) - 1);
|
||||
final selectedInitialItem = _selectInitialItemIfPossible();
|
||||
// notify:false — this runs during the build phase and the enclosing
|
||||
@@ -503,7 +518,7 @@ class TvBrowseRailState extends State<TvBrowseRail> with TickerProviderStateMixi
|
||||
_rememberTrailingStates();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
if (selectedInitialItem) _scrollToItem(animate: false);
|
||||
if (selectedInitialItem || followedFocusedItem) _scrollToItem(animate: false);
|
||||
if (shouldJumpAlignActiveHub) {
|
||||
_scrollActiveHubToTop(animate: false);
|
||||
} else if (shouldAnimateAlignActiveHub) {
|
||||
|
||||
@@ -64,6 +64,7 @@ import '../../utils/codec_utils.dart';
|
||||
import '../../utils/formatters.dart';
|
||||
import '../../utils/platform_detector.dart';
|
||||
import '../../utils/player_utils.dart';
|
||||
import '../../utils/route_visibility.dart';
|
||||
import '../../theme/mono_tokens.dart';
|
||||
import '../../utils/provider_extensions.dart';
|
||||
import '../../utils/snackbar_helper.dart';
|
||||
@@ -1118,9 +1119,10 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
// reclaim re-tests `hasFocus` when it runs, so once the surface holds the
|
||||
// remote the two no longer compete.
|
||||
if (!mounted || _focusNode.hasFocus) return;
|
||||
// A route pushed above the player still leaves these controls mounted;
|
||||
// A route pushed above the player still leaves these controls mounted —
|
||||
// on this navigator or an ancestor one (root-navigator dialogs/picker);
|
||||
// re-activating the window must not pull the remote off the top route.
|
||||
if (ModalRoute.of(context)?.isCurrent != true) return;
|
||||
if (!isRouteChainCurrent(context)) return;
|
||||
_claimPlayerSurfaceFocus();
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ class _PlayerPerformanceOverlayState extends State<PlayerPerformanceOverlay> {
|
||||
]),
|
||||
_buildSection(Symbols.volume_up_rounded, t.fileInfo.audio, [
|
||||
if (_stats.audioCodec != null) _metric(t.fileInfo.codec, _stats.audioCodec!),
|
||||
if (_stats.audioPassthrough) _metric(t.performanceOverlay.passthrough, _stats.audioPassthroughFormatted),
|
||||
_metric(t.performanceOverlay.sampleRate, _stats.sampleRateFormatted),
|
||||
_metric(t.fileInfo.channels, _stats.audioChannels ?? t.common.notAvailable),
|
||||
if (_stats.hasValidAudioBitrate) _metric(t.fileInfo.bitrate, _stats.audioBitrateFormatted),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import '../../../../i18n/strings.g.dart';
|
||||
import '../../../../utils/codec_utils.dart';
|
||||
|
||||
/// Data model for video player performance statistics.
|
||||
///
|
||||
@@ -34,6 +35,10 @@ class PerformanceStats {
|
||||
final int? audioBitrate;
|
||||
final String? audioDecoderName;
|
||||
|
||||
/// mpv `audio-params/format` when it names an IEC 61937 bitstream
|
||||
/// ('spdif-eac3'); null when audio is decoded locally.
|
||||
final String? audioPassthroughFormat;
|
||||
|
||||
final bool tunneledPlayback;
|
||||
final String? tunnelingStatus;
|
||||
|
||||
@@ -87,6 +92,7 @@ class PerformanceStats {
|
||||
this.audioChannels,
|
||||
this.audioBitrate,
|
||||
this.audioDecoderName,
|
||||
this.audioPassthroughFormat,
|
||||
this.tunneledPlayback = false,
|
||||
this.tunnelingStatus,
|
||||
this.actualFps,
|
||||
@@ -138,6 +144,7 @@ class PerformanceStats {
|
||||
audioChannels = null,
|
||||
audioBitrate = null,
|
||||
audioDecoderName = null,
|
||||
audioPassthroughFormat = null,
|
||||
tunneledPlayback = false,
|
||||
tunnelingStatus = null,
|
||||
actualFps = null,
|
||||
@@ -200,6 +207,17 @@ class PerformanceStats {
|
||||
return '${khz.toStringAsFixed(1)} kHz';
|
||||
}
|
||||
|
||||
/// Whether audio is bitstreamed to the device instead of decoded locally.
|
||||
bool get audioPassthrough => audioPassthroughFormat != null;
|
||||
|
||||
/// Format the bitstreamed codec ('spdif-eac3' → 'E-AC3').
|
||||
String get audioPassthroughFormatted {
|
||||
final format = audioPassthroughFormat;
|
||||
if (format == null) return t.common.notAvailable;
|
||||
final codec = format.startsWith('spdif-') ? format.substring('spdif-'.length) : format;
|
||||
return CodecUtils.formatAudioCodec(codec);
|
||||
}
|
||||
|
||||
/// Format FPS with 2 decimal places.
|
||||
String get actualFpsFormatted {
|
||||
if (actualFps == null) return t.common.notAvailable;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user