Skip to content

Player

Status: works on both engines, phone and TV. As of 2026-11-29. Trickplay previews: the player part of #860 is done; the original report (no previews on ExoPlayer on one phone) was never reproduced.

  • The player is one PlayerViewModel in player/local (phone and TV share it). The engine is behind PlayerEngine in engine/: engine/exo/ExoEngine.kt and engine/mpv/MpvEngine.kt. Both give a media3 Player, so shared code never names an engine (rule R6).
  • The queue is PlayQueue, a service in application since step 17 of #970: what is queued, which item plays, previous and next, the next season, shuffle and where the first item starts. It hands out items; PlaylistManager makes the PlayerItem of each, and the local player and Cast both go through it. How an item is asked for is ResolvePlayback (a use case in application since step 15 of #970: it reads the settings through PlayerSettings and gives a ResolvedStream, which PlaylistManager.toPlayerItem turns into the PlayerItem), quality and transcode-audio switches are StreamSwitches (a service in application since step 18 of #970, which also stores a quality pick for the network in use and decides when an item asked for on the other network has the queue asked for again), which tracks play and what a pick by hand is remembered as is TrackPreferences, and the audio a transcode is asked for is TranscodeAudio (both services in application since step 16 of #970: see subtitles-and-tracks.md), trickplay is TrickplayLoader (phone) and TrickplayRegionLoader (TV).
  • Reports to the server are PlaybackReporter (a service in application since step 13 of #970; the view model hands it each PlayerItem as a ReportedStream, presentation/ReportedStreams.kt) and PlaybackStartGate: see playback-reporting.md. Resume position and played: user-data.md. Tracks and subtitles: subtitles-and-tracks.md.
  • Test fast: ./gradlew :player:local:testDebugUnitTest, and ./gradlew :domain:test for the rules in domain/.../playback/rule/ (segments, up next, still watching, the sleep timer, the end of an item, the start gate, the reported pause, autoplay, the stop report, the series tracks). Player PRs also run docs/mpv-checklist.md on both backends, with the adb steps and the report of the player-verify skill (.claude/skills/player-verify/SKILL.md).
  • Trickplay (#860): the loaders are built with the played version (PlayerItem.mediaSourceId) and ask for that version’s sheets; a sheet that failed is left alone for 30 s (TrickplaySheetFailures), and TrickplayLoader samples a sheet larger than MAX_SHEET_PIXELS down instead of running out of memory.
  • onMediaItemTransition in PlayerViewModel.kt takes the item before it waits for the previous item’s stop, and hands it with its ItemTransition to PlaybackReporter.onTransitionHandled, which drops it when a switch came meanwhile (#890).
  • What plays now (#1016): the phone’s quality dialog has a line such as “Converted by the server · 720p · up to 4 Mbps”. NowPlaying.of decides it from the PlayerItem (isTranscoded, streamCap, sourceBitrate, transcodeBitrate) and the decoded video size (player.videoSize: ExoPlayer’s, mpv’s width/height), read by PlayerViewModel.nowPlaying(); the dialog reads it again every second.

ExoPlayer is the default engine, mpv the other (AppPreferences.playerBackend, which PlayerViewModel reads through PlayerSettings.backend, #969); EngineModule binds both. PlayQueue builds the queue of a movie or an episode series, PlaylistManager turns its items into PlayerItems, and NeighbourLoader adds the neighbours to the player’s playlist once the item is ready. ResolvePlayback asks the server how to play (direct, a transcode under the chosen cap, or a finished download). A version, quality or audio switch asks for the whole queue again and swaps it in (StreamSwitches, rebuildQueue; the latest switch wins, #726). PlaybackService keeps the media session; with background audio on, PlaybackSessionStore keeps the view model alive without the activity. NetworkRecovery waits for the network when a stream breaks (#450); DisplayRefreshRateManager votes for a refresh rate (#338).

Paths are under player/local/src/main/java/dev/jdtech/jellyfin/player/local/ unless they start with app/, server/ or another module.

Path What
presentation/PlayerViewModel.kt The player: initializePlayer, onMediaItemTransition, onPlaybackStateChanged, onPlayerError, the switches, getTrickplay / getTvTrickplay, releasePlayer. Very large: search by name
engine/PlayerEngine.kt, EngineDefaults.kt PlayerEngine, EnginePlayer (transitionsOnReplacedPlaylist, onItemReady, setZoomMode), the shared defaults
engine/exo/ ExoEngine, MediaSourceFactory, AudioDecoderFallback, TunnelingFallback, TunneledFrameRateRenderer, subtitle sources. ExoPlayer keeps its default frame rate strategy
engine/mpv/ MpvEngine, MPVPlayer (media3 BasePlayer over libmpv), and one small file per mpv rule: MpvCallQueue, MpvStallWatch, MpvLoadState (whether an END_FILE is a failed load), MpvStreamBreak, MpvErrorRecovery, MpvItemTransitions, SelectedVideoFrameRate, and MpvDeviceRules (a setting that is broken on some devices and what plays instead, #1073)
application/…/PlayQueue.kt The queue (step 17 of #970): start (a movie, an episode, a season, a series from next up, a shuffle; the first item’s sources asked for next to it, a QueueStart), loadQueue, previous/next with the next season, jumpTo, again, forget, setCurrent, upcomingItems, and startPositionMs, where the player starts. Each operation takes the conversion of the caller; an item counts as handed out once it succeeded, and is not handed out again until it is forgotten or a jump starts over
domain/PlaylistManager.kt The queue as the player’s items: getInitialItem, getNextPlayerItem, jumpTo, recreatePlayerItem call PlayQueue with toPlayerItem, which resolves the stream and reads the trickplay layout of the played source. Cast takes it too (CastPlayerControllerImpl, FakeCast)
application/…/ResolvePlayback.kt, ResolvedStream.kt resolve (one request and the pick), sources (TranscodeAudio asks it again for the audio of a transcode): the playback target, engine and cap (#766), the cap per network (#837, qualityNetwork, storeMaxBitrate). Settings through PlayerSettings (maxBitrate(network), preferredAudioLanguage), no AppPreferences. player/local provides it in di/ResolvePlaybackModule.kt, with the phone or TV choice of the cap per network
application/…/TrackPreferences.kt, TranscodeAudio.kt Which tracks play (onTracks: the reset alone or with the picks, now or once the series’ choice is read), what a pick by hand is remembered as, and the audio index a transcode is asked for. The view model builds its TrackPreferences with its own scope; PlaylistManager builds its TranscodeAudio. Details in subtitles-and-tracks.md
domain/NowPlaying.kt The quality dialog’s line (#1016): original, converted or download, the resolution name of the decoded size, the bitrate. The dialog is QualitySelectionDialogFragment.kt
application/…/StreamSwitches.kt, QueueRebuild.kt The switches (step 18 of #970): selectBitrate (stored for the network in use, undone in that network’s setting when it fails), selectAudio, itemPlays (#837), rebuildQueue. Generic over the player’s item: the view model’s Host makes each PlayerItem (PlaylistManager.recreatePlayerItem) and reloads the player (swapInQueue). The toast’s text is switchFailureText in domain/SwitchFailureText.kt. Cast’s audio switch does not use it (see cast.md)
domain/TrickplayLoader.kt, TrickplayRegionLoader.kt, TrickplayTiles.kt Sheet loads (sheetLoad, decodeSheet, tileAt), the TV region loader, the tile arithmetic; TrickplaySheetFailures.kt: how long a failed sheet is left alone
domain/ NeighbourLoader, segmentTrackerFrom (builds a SegmentTracker from the settings), NetworkRecovery, isNewEndOfItem (#477, EndOfItem.kt), DisplayRefreshRateManager, DebugSegments. No media3 here (R27)
mapping/ media3’s values to ours and back (since step 18 of #970): isNewEndOfItemReport (EndOfItem.kt, which reads the reason and state for domain/EndOfItem.kt’s rule of #477), the track names (Extensions.kt), TrackChoices and TrackKind.trackType (TrackPicks.kt), SubtitleFiles.kt, and NETWORK_ERROR_CODES (PlaybackErrors.kt), which the view model hands NetworkRecovery
domain/…/playback/rule/ The player’s pure rules, in domain since step 9 of ADR 0003: UpNextCountdown, SegmentTracker (Cast applies the same rule through CastSegmentSkipper, #851), SleepTimer, StillWatchingTracker, PlaybackStartGate, ReportedPause; since step 10 AutoPlayNext (over the AutoPlayNextSetting that PlayerSettings returns), PlaybackStopReport and the series track matching; and EndOfItemSteps (step 11), the order at the end of an item (the sleep timer first, then a cancelled card, the autoplay wait and still watching; the card and the outro skip). Since step 12 PlayerViewModel calls its steps (onPlayWhenReadyChanged, advanceOrAskStillWatching, updateUpNext, autoSkip, acknowledgeStillWatching, continueAfterSleepTimerEnd) and only carries out what each returns. Their tests run in :domain:test
PlaybackService.kt, PlaybackSessionStore.kt The media session service; the owner of the view model for the phone player
presentation/PlayerMediaSessions.kt, PlayerTexts.kt, PlayerDevice.kt What PlayerViewModel (and Cast’s, for the debug segments) asks Android for instead of taking a Context (#969, R23): the media session and PlaybackService, the track and message texts, the debug flag, density, files and fake segments. Its settings come through PlayerSettings, StillWatchingSettings and MediaSegmentSettings
PlayerActivity.kt The phone player screen (Views); PreviewScrubListener.kt shows the seek preview; dialogs in presentation/player/
TV ce/presentation/player/ TvPlayerScreen, TvPlayerKeyHandler, TvTrickplayThumbnail, TvSeekBar, TvUpNextCard, TvResumeOnReturn (ADR 0004)
http/…/MediaHttpClient.kt The API’s own OkHttp client, provided by server/jellyfin. ExoPlayer streams media over it (MediaSourceFactory derives its client with newBuilder(), so media shares the API’s connection pool, #296); mpv uses it only for subtitle files, and libmpv fetches the media itself, with its own TLS. A module of its own so domain names no library (#964)
JellyfinDeviceProfiles.kt, device/…/CodecHelpers.kt The device profile that decides direct play or transcode: ExoPlayer gets the one built from the probed decoders (DeviceCodecProbe, CodecHelpers maps their profiles and levels), mpv the permissive one. About → Export device profile shows both
JellyfinPlayback.kt trickplayTile and trickplayVersion (the mediaSourceId of a tile request)
PlaybackInfoMappers.kt toItemTrickplayInfo, preferredTrickplayInfo: the width the player gets
PlaybackMedia.kt getTrickplayData(itemId, width, sheetIndex, mediaSourceId)
player/core/…/models/ PlayerItem, Trickplay, TrickplayInfo
  • R6: engine/exo and engine/mpv use neither each other, and shared code uses neither; only engine.di binds both. A feature of one engine goes behind EnginePlayer.
  • R1, R2, R3: no Jellyfin SDK in the player. The adapter maps SDK types.
  • R10: ids are ItemId and MediaSourceId; no UUID, no String id in a signature.
  • R27: no file of player/local outside engine, mapping, presentation and di names media3 (PlayerRulesMedia3Test). A rule takes our own types; the view model or mapping turns media3’s values into them. The media session’s service (PlaybackService.kt, named in the manifest) is listed in architecture/baseline/player-media3.txt. R27 checks names, not use: a rule could still use a media3 type a mapping function returns without naming it, so keep mapping to mappers.
  • R24: PlayerViewModel, CastPlayerControllerImpl and CastViewModel may not grow past their line ceilings in architecture/size-ceilings.txt (ADR 0003). Move a rule out instead of adding to them.
  • R12: ticks only through Ticks. R5, R19: domain and application stay pure Kotlin, with no library but kotlinx; an OkHttp type goes through http, not a port.
  • Player PRs: docs/mpv-checklist.md on both backends. Do not fix mpv by touching the ExoPlayer path.
  • PlayerInvariantsTest fails the build when ExoPlayer loses its default frame rate strategy, when mpv stops hinting the surface with the frame rate (#338), and for other mpv invariants (no calls on the main thread, a network timeout, replaced playlists reported). It also fails when PlayerViewModel decides the end of an item itself (reads sleepTimer.stopsAtEndOfItem, upNextCountdown.isCancelled, stillWatchingTracker.onAutoAdvance, …) instead of calling EndOfItemSteps: a change to that order goes in the rule and a row of EndOfItemStepsTest.
  • New strings: translate-strings skill, all 36 languages.

Unit tests, no device:

Terminal window
./gradlew :player:local:testDebugUnitTest
./gradlew :domain:test # the rules in domain/.../playback/rule/
./gradlew :application:test --tests '*ResolvePlayback*' --tests '*TrackPreferences*' --tests '*TranscodeAudio*' --tests '*PlayQueue*' --tests '*StreamSwitches*' --tests '*RebuildQueue*'
./gradlew :server:jellyfin:testDebugUnitTest --tests '*Trickplay*' --tests '*PlaybackSourceMappingTest'
./gradlew :architecture:test

Useful classes: PlayerInvariantsTest, AudioDecoderFallbackTest, TunnelingFallbackTest, StreamSwitchesTest and RebuildQueueTest (in application), QueueRebuildTest (the rebuild with the neighbour lookup), ResolvePlaybackTest, TrackPreferencesTest and TranscodeAudioTest (in application), PlaylistManagerResolvedStreamTest (what the queue asks for and carries), ResolvePlaybackModuleTest, PlayQueueTest, PlayQueueNextSeasonTest, PlayQueueShuffleTest and PlayQueueNextUpTest (in application), PlaylistManagerQueueTest (the player’s part: start positions, a stream that fails), NeighbourLoaderTest, TrickplayTilesTest, TrickplayLoaderTest, TrickplaySheetFailuresTest, NetworkRecoveryTest, PlaybackStartGateTest, MpvItemTransitionsTest, MpvStartPositionsTest, MpvStallWatchTest, MpvDeviceRulesTest, NowPlayingTest, PlaylistManagerStreamBitrateTest, PlaylistManagerFrameRateTest, TunneledFrameRateTest. In the adapter: TrickplayTileRequestTest, TrickplaySheetTimeoutTest, TrickplayWidthTest, TranscodeBitrateTest.

On a device, on the test server (docs/dev-environment.md, test-server and test-devices skills):

  • Plain Movie, Short Movie (ends at once), Long Movie, Resume Show (4 episodes, resume positions).
  • Versions Movie: two versions (360p, 720p), for version and trickplay questions (#860).
  • Hevc Movie, Hdr Ten Movie for decoders; Av1 Movie, Av1 Ten Movie (8-bit and 10-bit AV1) for the AV1 conditions of the device profile; Level Six Movie, Hevc Level Six Movie (level 6.0) for the level cap: on ExoPlayer they transcode when the decoder’s level is below 6.0 (videoCodecLevels in About → Export device profile under 60 for H.264, 180 for HEVC; the emulators stop at 5.2) and direct-play when it reaches it; on mpv the level never stops direct play (a quality cap below the file’s bitrate still transcodes, as for any file).
  • Quality switch: a cap below the file’s bitrate. q837 Low, Mid and High Movie are 1080p at about 1.2, 5 and 12 Mbps (#837, #1016): (H.264 and AAC, so the cap alone decides) a cap above a file plays the original, below it the server transcodes and picks the size itself (High at 4 Mbps is 1280x720, at 8 Mbps 1920x1080, at 720 kbps 960x540; the newest FFmpeg.Transcode-*.log in the container’s /config/log says what it sends). The clips last a minute, and the player closes at the end. Slow link: emulator at 3G (#860). A held request (#890): see playback-reporting.md.
  • A real device for refresh rate, HDR and Dolby Vision. mpv needs software rendering on an emulator. Mute first.

docs/mpv-checklist.md is the list: resume, from 0, seek, media session, refresh rate vote (dumpsys SurfaceFlinger), back out; plus playlist, autoplay, quality switch and slow link when the PR touches them. The player-verify skill has the test item, the commands and the pass condition for each, and its scripts/pv.sh opens the player on an item from adb (adb root, then am start of PlayerActivity with the item id in UUID form), switches the backend, and reads the states, reports, media session and vote back.

Terminal window
./gradlew ktfmtCheck
./gradlew :architecture:test
./gradlew :player:local:testDebugUnitTest :server:jellyfin:testDebugUnitTest
./gradlew :app:phone:compileLibreDebugKotlin :app:tv:compileLibreDebugKotlin

Add :app:phone:compileProprietaryDebugKotlin when Cast code or the player/core models change. Then the mpv checklist on both backends. When no review bot ran, a player PR gets an independent review (CLAUDE.md).

  • #126, #134: the TV player on the shared view model (ADR 0004).
  • #267, #284, #305: a faster start left mpv in BUFFERING; the reason the checklist exists.
  • #338: the refresh rate vote, pinned by PlayerInvariantsTest. #450: wait for the network, then reload; the callback comes from NetworkSignals in device since #998 (R28).
  • #657: neighbours load when the item is ready. #723, #726: switches on mpv; the latest switch wins. #837: a default quality per network. #1016: the quality dialog says what plays now; options that change nothing stay (a pick is saved as the network’s default), and no height limit is sent (it would force transcodes and touch the device profile). The TV player has no quality picker.
  • #764, #765, #766: PlayerEngine, PlaybackReporter and ResolvePlayback out of PlayerViewModel. Proposed next: ADR 0003 (#970), the rest of the flows (the end of an item, the track choice, the queue, the switches) as rules in domain and services in application, one per PR, shared with Cast. #870 / #889: mpv reports a replaced playlist itself.
  • #1073: the first device rule for mpv, copy-back decoding on the Pixel 11 family, taken from Findroid 20bf6f536. Findroid’s table also turns aaudio into audiotrack on Samsung; Ephyra’s audio output is audiotrack on every device already (#52), so that rule was not taken. The rule and the read of Build are in engine/mpv, not behind a port in the device module: only mpv asks, the answer is two constants, and the rule is tested by passing them in.
  • #860 / #878: the adapter sends the version, compares widths as numbers and gives sheets 30 s. The player part: the played version in the tile request, no new try of a failed sheet for 30 s, sheets sampled down above 3200x5760 pixels (every 320-wide 10x10 sheet up to portrait 9:16 stays whole) and an out-of-memory error caught. The width choice of #878 compares the sheet’s width (at most 3200) before its pixels, so 4:3 and portrait items keep width 320 over 160; 16:9 items on a square grid get the same width as before.
  • Trickplay previews that do not show (#860). A sheet that failed is not asked for again for 30 s, also when the server is back: scrub again after that before calling it a bug. To stage a failing or slow sheet, put a proxy that answers /Trickplay/ with an error between the emulator and the server and log in through it; the request carries mediaSourceId only for a version other than the item’s own (the adapter leaves it out otherwise). Tiles of a sheet sampled down come out smaller (half size above 3200x5760, such as a 10x10 sheet of 640 wide). The test server only has 16:9 sheets at 320: a 4:3 or portrait case is in the unit tests (TrickplayLoaderTest, TrickplayWidthTest), not on the server.
  • A switch during a stop (#890). onMediaItemTransition finds item in items, waits for the previous item’s stop, then calls onTransitionHandled(item, ..., transition); a switch that lands in that wait makes item stale, and the reporter drops it by the transition’s number. Details: playback-reporting.md. Both backends.
  • A quality switch is a new playlist. ExoPlayer reports a transition to the same item; mpv reports none (transitionsOnReplacedPlaylist). Code keyed on transitions must handle both (#870).
  • mpv keeps an entry’s start option on Previous (#1146). A resume, quality switch or retry can load a playlist entry with start=. mpv uses that option again when Previous reopens the entry. MpvStartPositions remembers it per media item, so the first playback restart seeks to the requested position (0 on Previous) when it differs from where mpv opened. Keep the option after that restart: consuming it once makes the next visit start at the old resume or switch position. Inserting a neighbour must not move this association. Check both a resumed item and an item reloaded by a quality switch: Next, then Previous twice must return it to 0; paused stays paused. If mpv rejects that corrective seek and sends no second playback restart, MpvSeekCompletion reports an error after the existing stall give-up interval, also while paused. A completed restart, new load or playback error cancels that wait; ordinary resume and quality-switch seeks keep their existing handling. After a corrective-seek timeout, Retry opens the same media item at 0 without changing the position reported for the failed playback. It finds that item again in the current playlist, so inserting or removing earlier neighbours cannot send its retry target to another entry; a removed target is not retried. Stop discards both the corrective target and its numeric recovery record; ordinary error recovery keeps its existing stop behavior. An explicit seek while errored overrides that retry target. A same-item seek while the correction is still pending replaces its deadline and retry target; ordinary seeks do not acquire a correction deadline. Moving to another item while an initial resume is still loading drops that pending resume: the destination uses its own requested position, or 0 by default.
  • A move to another item keeps the pause (#1121). On both engines, Next and Previous leave playWhenReady as it was, as media3 does: paused stays paused. mpv used to call play() in seekTo for another item. Code that should play after the move calls play() itself (autoAdvanceToNextItem, playUpNextNow); so does a tap in the queue, which replaces the playlist (jumpToQueued) and plays.
  • Find an item by id, not by index. Indexes shift when neighbours load (#869).
  • The queue hands out each neighbour once (#657). PlayQueue.previous and next return null for an item it handed out already, also when the caller lost it. A caller that drops a neighbour calls forget, a jump starts over with jumpTo, and Cast keeps the answers it got in CastPlaylistOrder. A new PlayQueue (a new PlaylistManager) for every new thing the user starts, or the next playlist gets no neighbours.
  • Cancelled queue lookups propagate (#1141). PlayQueue rethrows CancellationException before handling other failures, including neighbour conversion and the next-season lookup. Cancellation writes no error log and leaves the item available for a later lookup. PlayQueueTest covers both neighbours and the next season.
  • Queued downloads stay on disk (#1143). PlayerViewModel publishes the local files of its resolved playlist through PlaybackEvents.queuedDownloadIds, using PlayerItem.streamCap == null as the existing download marker. Smart Downloads protects these files even after the player moves to Previous. The playlist retains earlier items so the user can return to them. Published local files stay protected until player release, even across a jump or a failed replacement: assignment of the new list does not mean the engine has relinquished the old one. A later Smart Downloads check can remove them after release.
  • mpv can stand on its last frame without eof-reached (#1116). Play from a paused seek to the very end (a paused outro skip on the last item) and mpv stays at the last frame and reports nothing. The stall watch treats standing still within MpvStallWatch.END_TOLERANCE_MS of the duration as the end and calls onEndOfFile(), the same path as eof-reached, so the item ends a few seconds after Play (6.5 s on the emulator: STALL_MS of standing still, counted from the first check after the seek).
  • mpv is not called on the main thread after init (MpvCallQueue), and its state can drift from media3’s: read the log, not the picture (checklist).
  • A failed load on mpv is decided in MpvLoadState (#446, #576, #786). libmpv calls eventEndFile(reason, error) just before event(MPV_EVENT_END_FILE), and MPVPlayer posts both on one handler, so the reason is there when the END_FILE branch runs (PlayerInvariantsTest pins it). An end with a reason other than ERROR (a redirect, EOF, a stop) is no failure; one with ERROR keeps mpv’s error code (mpv could not open the file: … (mpv error -13) in the log). Error lines can still come after END_FILE (the hold); on the test server’s Broken Movie, “Failed to recognize file format” arrives after the report, so MPV_ERROR_UNKNOWN_FORMAT (-17) is what makes it ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED. A refused connection (ffmpeg: tcp:) and a connection failure while reading the HTTP response (ffmpeg: http: / ffmpeg: https:, #996) are classified by their error lines, since mpv reports them as a plain loading failure (-13), while an HTTP status from the server (HTTP error 404) keeps its plain error. To stage a redirect (reason REDIRECT), answer the stream URL with an m3u playlist that points back at it.
  • The refresh rate vote differs per engine: ExoPlayer keeps its default strategy, mpv hints the surface itself. An mpv change that loses the hint passes every other test (#338).
  • A codec without a profile mapping is direct-played at any profile (#1029). generateCodecProfile adds the VIDEO_PROFILE condition only when the probe found profiles, so a codec that CodecHelpers does not map (AV1 until #1029) went to ExoPlayer whatever the stream. The server names AV1 8-bit and 10-bit both Main, so AV1 is held by a VIDEO_BIT_DEPTH cap from the decoder’s profiles (AV1_PROFILE_BIT_DEPTHS).
  • Levels are capped per codec, and only for H.264, HEVC and AV1 (#1061). Until #1061 the probe read the levels and dropped them, so the server direct-played a stream above every decoder’s level; ExoPlayer logs Format exceeds selected codec's capabilities and tries anyway. Now each codec gets a VIDEO_LEVEL LESS_THAN_EQUAL condition with the highest level any of its decoders advertises in any profile (ProbedCodecs.videoCodecLevels; also in the device report as videoCodecLevels). Per codec, not per profile: a decoder lists the highest level for each profile, these are nearly always the same, and one limit per codec needs no apply conditions on the server’s profile names. The numbers are the server’s: H.264 level_idc (5.1 is 51), HEVC 30 times the level (5.1 is 153), AV1 seq_level_idx (5.1 is 13). Other codecs get no level, because the server has none for them or counts the other way (MPEG-2). A Dolby Vision decoder counts as HEVC but its levels do not: they are Dolby Vision levels, held by dolbyVisionProfiles. The condition is not required, so a stream without a known level is not held back by it (the other conditions still apply). The cap also holds in the HLS transcode: the server copies H.264 into the segments when it can, so H.264 gets a ts codec profile with only the level (the profile names would also choose the profile of the server’s own encode); without it the server sent a level 6.0 file to a transcode for its level (the reason VideoLevelNotSupported) and then copied the video as it was.
  • A platform audio decoder that fails mid-stream is dropped for ffmpeg (AudioDecoderFallback), per OS build.
  • Tunneling refuses some audio formats (#924). EngineDefaults asks ExoPlayer for tunneling, and a tunneled AudioTrack needs the device’s HW A/V sync output, which may not take every channel mask (the Xiaomi TV box: no mono). The track then fails to open (ERROR_CODE_AUDIO_TRACK_INIT_FAILED, getOutputForAttr() return error -38); TunnelingFallback turns tunneling off and the player prepares again at the same position, once per item (Tunneling failed to open an audio track, retrying without tunneling). It comes back on when another media id plays (Tunneling back on for the next item), not after a switch on the same item. Emulators do not tunnel: only a TV device shows it.
  • Tunneled, ExoPlayer votes only with the format’s frame rate (#1024). ExoPlayer’s vote comes from its frame rate estimator, which starts at the video Format.frameRate and learns the real rate from the frames it releases; tunneled, the codec renders the frames and the estimator never sees one. MatroskaExtractor sets no frame rate, so a tunneled mkv sent no vote (SIDEBAND layer, empty “Frame Rate (Explicit)”). TunneledFrameRateRenderer fills in the server’s rate of the video stream (PlayerItem.videoFrameRate, the MediaItem’s ServerFrameRate tag; a direct stream only) when the stream is tunneled and the format has no rate. The log line Video stream: tunneling=…, format frame rate=[…], server's=… says what it had. Without tunneling nothing changes; a download has no server rate. The track formats keep no rate, so DisplayRefreshRateManager still sees none for an mkv.
  • A proxy that asks for a client certificate (#960). mpv reads https through FFmpeg on mbedTLS, and FFmpeg’s tls_mbedtls.c configured an own certificate and key also when none was given, empty. A server that asks for a client certificate, also one that only asks (Caddy client_auth mode verify_if_given), then broke the handshake: ffmpeg: tls: TLS handshake failed. (TLS 1.3) or mbedtls_ssl_handshake returned -0x3e80 (TLS 1.2; -0x6600 with mbedTLS 3.6.6). Seen in every release from 2.5.0 up to libmpv 1.3.0; ExoPlayer is not affected. libmpv 1.4.0 patches FFmpeg to register a certificate only when one was loaded (midasvo/libmpv-android#56); the app has no workaround of its own. The same lines have other causes too (any failed handshake, such as no common TLS 1.3 group), so they alone do not prove the patch is gone: if mpv fails on the site that asks for a certificate and plays on the same site without client_auth, check whether a libmpv bump dropped the patch. Stage it with tools/test-server/caddy-tls.sh (dev-environment.md): port 8443 asks for a certificate, 8444 is the same site without client_auth.
  • A quality option is only a bitrate cap (#1016). The cap alone never makes the server convert a file under it, and above it the server picks the resolution; a file under the cap can still be converted for another reason (a codec the device profile does not take), and the line then says “Converted by the server”. The dialog’s line says which: the size is the one decoded, never the label’s. For a transcode the bitrate is a limit (“up to”): the least of the cap and the VideoBitrate + AudioBitrate of the server’s transcoding URL, left out when it is not below the file’s own bitrate (a transcode for the codec alone carries a limit of 1 Gbps). A download says “Playing the download”, not “the original”: a download made at a download quality cap is a transcode too, and the model does not say which. mpv logs mpv_get_property(width) … property unavailable when the size is asked for before a file is loaded; that is no failure.
  • The hardware decoding setting is not always what mpv gets (#1073). MpvDeviceRules replaces a mode that is known to be broken on a device: on the Pixel 11 family (Build.MANUFACTURER Google, Build.MODEL Pixel 11, Pixel 11 Pro, Pixel 11 Pro XL, Pixel 11 Pro Fold) mediacodec becomes mediacodec-copy, because switching the subtitle track froze playback for good there (Findroid 20bf6f536, seen on a Pixel 11 Pro with the Android 17 DP11 beta; not reproduced here, nobody has the device). Settings → Player → mpv options still shows mediacodec: the setting is not rewritten, so the rule can be removed without leaving a changed setting behind. no and mediacodec-copy are passed as chosen, and hwdec= in mpv.conf overrides what the app passes, also on these devices. A debug build logs when a rule applied (mpv: hwdec 'mediacodec' is known to be broken on Google Pixel 11 Pro, using 'mediacodec-copy'), once per player. That line is in debug builds only: it is logged at info level, the phone’s release build plants no log tree and the TV’s keeps warnings and up (BaseApplication of each app), so its absence in a release build’s log says nothing. MpvEngine reads Build and hands it to the rule, which is plain Kotlin (MpvDeviceRulesTest). On a release build the app has no way to show which mode plays: nothing reads mpv’s hwdec-current, there is no stats overlay, and the device report under About does not have the mpv settings. What is left is logcat over adb: FFmpeg prints h264_mediacodec: Both surface and native_window are NULL when it opens a decoder for copy-back and nothing for mediacodec, and that line comes from libmpv’s own logging (tag mpv), not from the app’s log tree; it was seen on a debug build only, not checked on a release build. Test again on stable Android 17 and remove the rule when the freeze is gone.
  • Emulators: host GPU rendering crashes mpv; on Android 17 images ExoPlayer cannot decode H.264 (docs/dev-environment.md).

Source: docs/areas/player.md · raw Markdown