安卓媒体播放可靠性审计
核查播放器生命周期、切源回调与后台恢复,生成包含复现时序和修复方向的播放缺陷报告。
完整提示词
I want you to perform a maximally deep, systematic, evidence-first, and production-oriented analysis of the complete media playback system of an Android application.
Main objective:
> Determine whether audio and video playback operates reliably across Android lifecycle transitions, background/foreground shifts, source changes, buffering states, seeking operations, audio focus changes, Bluetooth and headset disconnections, Picture-in-Picture (PiP), MediaSession management, media notification controls, process death, network disruptions, and playback exceptions without resource leaks, duplicate player instances, corrupted playback states, or lost user continuity.
This is not:
- a generic ExoPlayer checklist
- a recommendation to simply "upgrade to Media3"
- a superficial verification that a video starts playing
- automatically slapping background playback onto every screen
- automatically registering a MediaSession everywhere
- a shallow review of a single `PlayerView`
- randomly adjusting buffering parameters
- a recommendation to shove the player into a global singleton without understanding lifecycle
The focus is on the real-world operational playback system.
Priority hierarchy:
**playback correctness > lifecycle/resource ownership > state continuity > audio focus > recovery > background behavior > performance > UX refinements**
Finding 6 genuine playback lifecycle and concurrency defects is infinitely more valuable than writing 100 generic ExoPlayer tips.
---
# 1. IDENTIFY THE MEDIA STACK
Before formulating findings, establish:
- Media3 library version
- ExoPlayer version if legacy packages are still used
- `Player` interface usage
- `ExoPlayer` implementation specifics
- `MediaSession` configuration
- `MediaSessionService` architecture
- `MediaLibraryService` tree if present
- `PlayerView` bindings
- Jetpack Compose media integrations
- Custom UI playback controls
- Audio-only vs video playback paths
- Live streaming pipelines
- HLS integration
- DASH integration
- Progressive media download/streaming
- DRM implementations (Widevine, ClearKey)
- Subtitles and closed caption tracks
- Google Cast / remote media routing
- Picture-in-Picture (PiP)
- Background audio playback
- System notification controls
- Download managers and offline media playback
- Analytics and telemetry listeners
If the project uses an alternative media playback engine, adapt the audit to the actual stack in use.
---
# 2. MAP THE PLAYBACK ARCHITECTURE
Construct the real execution flow:
```text
UI
↓
Playback controller
↓
Player
↓
MediaSource
↓
Network / Local file
↓
Decoder
↓
Audio / Video output
```
If background playback is supported:
```text
UI
↓
MediaController
↓
MediaSession
↓
MediaSessionService
↓
Player
```
If Android TV is supported:
```text
D-pad / remote control
↓
UI action
↓
Player / Session
↓
Playback state
```
---
# 3. IDENTIFY PLAYER OWNERSHIP
The most critical architectural question:
> Who creates the player instance, and who is responsible for releasing it?
Potential owners:
- Activity
- Fragment
- Composable function
- ViewModel
- Android Service
- Application singleton
- Dedicated playback manager component
Evaluate whether the player's lifetime strictly matches business and product requirements.
---
# 4. PREMATURE PLAYER LIFETIME TERMINATION
Scenario:
```text
player owned by UI screen
↓
user navigates away or switches tabs
↓
player released immediately
```
If playback was supposed to continue in the background or during screen transitions, the owner lifetime is too short.
---
# 5. EXCESSIVE PLAYER LIFETIME RETENTION
The opposite problem:
```text
player held in global singleton
↓
media feature closed by user
↓
player remains allocated
↓
hardware decoders, network buffers, and listeners retained
```
If background playback is not an active feature, this creates a severe hardware resource and memory leak.
---
# 6. UNCONTROLLED PLAYER CREATION
Look for player instances instantiated:
- On every Compose recomposition
- Inside every `onResume()` invocation
- Inside adapter item binding loops
- On transient screen redraws
without architectural justification.
---
# 7. DUPLICATE PLAYER INSTANCES
Scenario:
```text
media screen opened
↓
player A created
↓
device rotation occurs
↓
player B created
↓
player A not released
```
Consequences:
- Two simultaneous active streams
- Dual overlapping audio outputs
- Native memory leaks
- Hardware codec/decoder exhaustion
---
# 8. PLAYER RELEASE SYMMETRY
For every creation code path, identify the exact corresponding release path.
Verify strict lifecycle symmetry:
```text
create -> release
addListener -> removeListener
attachSurface -> clearSurface
```
---
# 9. PLAYER LISTENERS LIFECYCLE
Catalog:
- `Player.Listener`
- Analytics and diagnostic listeners
- Custom playback event observers
Verify:
- Registration timing
- Duplicate registration guards
- Timely unregistration
- Avoidance of stale UI or Activity references
---
# 10. LISTENER ACCUMULATION AND DUPLICATION
Scenario:
```text
onStart
↓
addListener
↓
onStop
↓
listener remains attached
↓
onStart
↓
second identical listener attached
```
Every subsequent playback event is processed twice, distorting state and analytics.
---
# 11. LISTENER THREADING CONTRACTS
Identify the exact thread on which player callbacks are delivered.
Never manipulate UI state from non-main threads unless explicitly handled by the framework contract.
---
# 12. MEDIA ITEM LIFECYCLE
Trace the pipeline:
```text
content ID
↓
URL resolved
↓
MediaItem constructed
↓
prepare
↓
play
```
Inspect for stale URLs, obsolete tokens, or mismatched metadata.
---
# 13. SOURCE RESOLUTION TIMING
If stream URLs:
- Expire after short TTLs
- Are cryptographic signed URLs
- Depend on dynamic auth tokens
- Are computed asynchronously
Inspect precisely when resolution occurs relative to playback initiation.
---
# 14. EXPIRED STREAM URLS
Scenario:
```text
stream URL resolved
↓
user pauses app for 30 minutes
↓
signed URL expires
↓
user clicks resume playback
```
Determine whether the player:
- Refreshes the URL automatically
- Encounters an HTTP 403 failure
- Renders an unrecoverable terminal error
---
# 15. RE-RESOLUTION RETRY STRATEGY
When stream URLs expire, verify that retry routines trigger a fresh source resolution rather than futilely repeating the stale, expired URL.
---
# 16. MEDIA ITEM IDENTITY INTEGRITY
When a user rapidly switches media items:
```text
channel A selected
↓
channel B selected
```
Verify that a delayed callback from source A does not corrupt the active UI state of source B.
---
# 17. RAPID CHANNEL ZAPPING
Particularly critical for Live TV applications.
Simulate rapid switching:
```text
Channel A
↓
Channel B
↓
Channel C
↓
Channel D
```
within a brief interval.
Audit for:
- Stale playback callbacks applying out of order
- Mismatched metadata displayed on screen
- Subtitles from previous channels lingering
- Previous streams continuing to download in background
- Hardware decoder accumulation
---
# 18. GENERATION AND SESSION CORRELATION
For rapid source switching, verify whether callbacks carry a generation or request ID to confirm they belong to the currently active selection before updating state.
---
# 19. PREPARATION DISPATCH
Trace invocations of:
```text
setMediaItem
prepare
play
```
Verify that redundant or circular calls to `prepare()` are avoided.
---
# 20. AUTOPLAY POLICIES
Inspect:
- `playWhenReady`
- `play()`
- Business autoplay requirements
Do not classify autoplay as a defect without evaluating product intent.
---
# 21. PLAYBACK STATE MACHINE
Map the core states:
```text
IDLE
BUFFERING
READY
ENDED
```
along with custom wrapper states.
Ensure the UI never conflates:
```text
BUFFERING
```
with:
```text
PAUSED
```
or:
```text
FAILED
```
---
# 22. `isPlaying` PRECISION
Verify that UI logic correctly differentiates between:
- `playbackState`
- `playWhenReady`
- `playbackSuppressionReason`
Never derive UI presentation purely from a single boolean when domain semantics require compound state evaluation.
---
# 23. BUFFERING INDICATOR INTEGRITY
Audit loading spinner behavior:
- When does it appear?
- When does it dismiss?
- Can it become permanently stuck on screen?
---
# 24. BUFFERING POST-SEEK
Seeking inevitably triggers a momentary buffering phase.
Verify that the UI transitions smoothly without flickering to an error or paused state.
---
# 25. BUFFERING WHILE PAUSED
If a player is paused while buffering or preparing initial segments, ensure the UI does not falsely depict an active "playing" state.
---
# 26. INDEFINITE BUFFERING STALLS
Scenario:
```text
network throughput degrades or stalls
↓
player enters BUFFERING indefinitely
```
Verify:
- Socket timeouts
- Read timeout handlers
- Error transitions
- User-facing retry mechanisms
---
# 27. NETWORK DISCONNECTION MID-PLAYBACK
Simulate:
```text
media actively playing
↓
network connection drops
```
Evaluate:
- How long playback continues on cached buffer
- What state the UI renders when buffer runs dry
- How long until an error is raised
- Whether automatic reconnection recovery exists
---
# 28. NETWORK RESTORATION HANDLING
Scenario:
```text
network connectivity restores
```
Determine whether:
- The player resumes automatically
- Manual user interaction is required
- The player remains trapped in a terminal error state
---
# 29. NETWORK FLAPPING UNDER PLAYBACK
Simulate rapid cycling between online and offline states.
Verify that retry routines do not create:
- Duplicate player instances
- Redundant overlapping MediaSources
- Uncontrolled retry storms
---
# 30. ERROR CLASSIFICATION
Differentiate failure modes semantically:
- Source / network connectivity
- HTTP status codes
- Manifest / format parsing
- Codec / hardware decoders
- DRM licensing
- Local file missing / inaccessible
- Security and permission rejections
Never present a single uniform recovery action for fundamentally distinct error types.
---
# 31. PLAYBACK EXCEPTION HANDLING
Inspect the handling of `PlaybackException`.
Determine:
> Which specific error codes are retryable, and which are terminal?
---
# 32. HTTP 401 AND 403 AUTHENTICATION FAILURES
When media streaming endpoints reject credentials:
- Token refresh flow
- Stream URL re-resolution
- Bounded retry execution
---
# 33. HTTP 404 NOT FOUND
Do not execute unbounded retries against resources that have been permanently removed from the server.
---
# 34. HTTP 5XX SERVER FAILURES
Candidates for transient retry, provided requests use bounded attempts with exponential backoff.
---
# 35. DECODER AND CODEC FAILURES
Retrying the identical media stream without transcoding or quality adaptation will fail repeatedly if the physical device lacks the required hardware codec.
---
# 36. UNSUPPORTED FORMAT FEEDBACK
The UI must explicitly inform users when a media format is incompatible rather than masquerading the issue as a generic network timeout.
---
# 37. STREAM QUALITY FALLBACK
If multi-bitrate streams or alternate CDN source endpoints are configured, verify automatic fallback paths.
Do not suggest fallback logic if the streaming infrastructure does not provide alternative variants.
---
# 38. ADAPTIVE BITRATE STREAMING
When utilizing HLS or DASH:
- Adaptive track switching responsiveness
- Manifest refresh cadence
- Live window tracking
- Seekability boundaries
---
# 39. HLS STREAMING BEHAVIOR
For live HLS streams, specifically evaluate:
- Playlist / manifest refresh intervals
- Discontinuity tag handling
- Expired segment requests
- Live edge drift and tracking
---
# 40. DASH STREAMING BEHAVIOR
Where DASH is utilized, audit timeline tracking and dynamic adaptation sets.
---
# 41. LIVE STREAMING VS VOD DYNAMICS
Live streaming is architecturally distinct from Video-on-Demand (VOD).
Map:
- Live playback edge
- DVR / timeshift seek window
- Dynamic stream duration
- Recovery when playback falls behind the live window
---
# 42. FALLING BEHIND THE LIVE WINDOW
If a player falls behind the server's rolling DVR buffer:
Verify the recovery strategy (e.g., seeking directly to the live edge rather than crashing).
---
# 43. GO LIVE ACTION
When timeshifting is supported, audit the "Go Live" control:
- Action execution
- Transition to live edge
- Updated seekbar status
---
# 44. LIVE OFFSET ACCURACY
If displaying time elapsed from live edge (e.g., "-01:25"), audit how that offset is computed and updated.
---
# 45. INDEFINITE LIVE DURATION
Live streams exhibit indefinite or unbounded durations.
Ensure UI components do not assume finite VOD durations, preventing progress bar calculation crashes.
---
# 46. SEEK OPERATIONS
For seek mechanics, audit:
- Seekable time range validation
- Player readiness before seeking
- Live window vs VOD seek boundaries
- Rapid repeated seek handling
- UI seekbar synchronization
---
# 47. RAPID SCRUBBING AND SEEKING
Scenario:
```text
user scrubs to 10%
↓
scrubs to 70%
↓
scrubs to 30%
```
in rapid succession.
Verify that delayed intermediate position callbacks do not cause the scrub thumb or video frame to jump backward erratically.
---
# 48. SEEKING PRIOR TO READY STATE
If a user initiates a seek before the player reaches `STATE_READY`, verify that the pending position is cached and honored upon preparation without throwing exceptions.
---
# 49. SEEKING AFTER PLAYBACK ENDED
Define explicit, deterministic behavior when seeking occurs after reaching `STATE_ENDED`.
---
# 50. PLAYBACK POSITION PERSISTENCE
When remembering resume positions:
- Trigger point (interval, pause, stop)
- Target storage (Room, DataStore)
- Write frequency
- Restoration lifecycle
---
# 51. EXCESSIVE POSITION PERSISTENCE WRITES
Never write playback positions to disk on every decoded frame or every second.
Throttle and batch disk writes.
---
# 52. POSITION LOSS UPON SUDDEN PROCESS DEATH
If playback position is persisted exclusively in `onStop()`, an OS process termination while playing will lose all recent progress.
Evaluate the impact against user expectations.
---
# 53. RESUME POSITION IDENTITY INTEGRITY
Verify that a persisted playback position is bound strictly to:
- The exact content / episode ID
- The active user account
- The active media revision
---
# 54. RESUME POSITION UPON CONTENT COMPLETION
When playback reaches the end, ensure the stored position is reset to the beginning or flagged as completed according to product specifications.
---
# 55. PLAYLIST AND QUEUE MANAGEMENT
Where queues exist:
- Active playlist index
- Current MediaItem resolution
- Repeat mode synchronization
- Shuffle mode ordering
- Skip to next / previous operations
---
# 56. CONCURRENT PLAYLIST MUTATIONS
Scenario:
```text
currently playing item index 5
↓
playlist items inserted or deleted ahead of index 5
```
Does the active playback item continue playing uninterrupted with an updated index?
---
# 57. REMOVAL OF CURRENTLY PLAYING ITEM
What occurs if the currently playing media item is dynamically removed from the active playlist?
---
# 58. PLAYLIST QUEUE PERSISTENCE
If background playback must survive service or process recreation, verify whether the playlist queue can be cleanly reconstructed from persistent storage.
---
# 59. SHUFFLE STABILITY
Ensure randomized shuffle orders remain stable during a single playback session rather than re-shuffling on every track transition.
---
# 60. REPEAT MODE SYNCHRONIZATION
Ensure the repeat mode toggle (Off, One, All) in the UI remains bidirectionally synchronized with the player's internal state.
---
# 61. RAPID NEXT AND PREVIOUS INVOCATIONS
Rapidly spamming skip buttons must not cause race conditions in source loading or surface allocation.
---
# 62. MEDIASESSION INTEGRATION
If the app supports background audio, lockscreen controls, or system media buttons, audit the `MediaSession` integration.
---
# 63. MEDIASESSION OWNERSHIP
Who instantiates and releases the `MediaSession`?
It must generally match the lifetime of the playback service or manager, not transient Activity UI components.
---
# 64. MEDIASESSION METADATA SYNCHRONIZATION
Verify:
- Track title
- Artist / channel name
- Album artwork bitmap / URI
- Content ID
- Total track duration
Ensure stale metadata from preceding tracks never persists onto newly playing items.
---
# 65. STALE METADATA HAZARD
Scenario:
```text
MediaItem A playing
↓
user skips to MediaItem B
↓
MediaItem B audio plays
↓
system lockscreen / notification continues showing MediaItem A artwork
```
---
# 66. MEDIA BUTTON HANDLING
Verify system and hardware control mappings:
- Play / Pause / PlayPause toggle
- Skip to Next
- Skip to Previous
- Fast Forward / Rewind
- Stop
---
# 67. WIRED HEADSET BUTTON CONTROLS
External media buttons must manipulate the canonical playback state in the exact same manner as in-app UI buttons.
---
# 68. BLUETOOTH AVRCP CONTROLS
Verify that Bluetooth car head units and wireless headphones receive accurate playback status and can issue commands reliably.
---
# 69. MEDIACONTROLLER LIFECYCLE
When UI components connect via `MediaController`, audit the asynchronous connection and token lifecycle.
---
# 70. ASYNCHRONOUS CONTROLLER RESOLUTION
Scenario:
```text
controller connection future initiated
↓
screen destroyed before future resolves
↓
future completes and calls back
```
Ensure listeners and controllers are safely released without leaking the destroyed Activity context.
---
# 71. MULTIPLE CONCURRENT MEDIACONTROLLERS
Multiple screens or fragments may bind controllers to the same active `MediaSession`.
Ensure clean listener registration and teardown per screen.
---
# 72. MEDIASESSIONSERVICE LIFECYCLE
For background playback, inspect:
- Service lifecycle (`onCreate`, `onStartCommand`, `onDestroy`)
- Session factory and cleanup
- `onTaskRemoved` handling
- Service stopping criteria
- Player release sequence
---
# 73. SERVICE RECREATION AFTER PROCESS DEATH
Scenario:
```text
background playback active
↓
OS kills process under memory pressure
↓
system attempts service recreation
```
Determine what state can be safely restored.
Never assume the in-memory player instance survives process termination.
---
# 74. `onTaskRemoved()` BEHAVIOR
Evaluate whether playback is expected to pause, stop, or continue when the user swipes away the task from the recent apps list.
---
# 75. TASK SWIPE-AWAY POLICY
Must be an explicit, deliberate product decision:
- Continue playing in background (e.g., music streaming)
- Terminate playback and release resources (e.g., standard video viewing)
---
# 76. FOREGROUND SERVICE (FGS) COMPLIANCE
When playback requires an active Foreground Service:
- Timely call to `startForeground()`
- Appropriate FGS type declarations (`mediaPlayback`)
- Notification posting requirements
- Timely `stopForeground()` upon stopping
---
# 77. MEDIA NOTIFICATION SYNCHRONIZATION
Audit:
- Realtime playback status (playing vs paused icons)
- Metadata display
- Progress seekbar support (Android 10+)
- PendingIntent targets
---
# 78. NOTIFICATION PLAY/PAUSE SYNC
The notification play/pause button state must immediately reflect reality, including when playback pauses due to buffering, system events, or errors.
---
# 79. NOTIFICATION INTENT TARGETING
Tapping the media notification must launch the application directly into the currently playing media item and player screen.
---
# 80. STALE PENDINGINTENTS
Notification actions must not retain stale item IDs or expired user session tokens.
---
# 81. AUDIO FOCUS MANAGEMENT
Map how the application handles:
- `AUDIOFOCUS_GAIN`
- `AUDIOFOCUS_LOSS_TRANSIENT`
- `AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK`
- `AUDIOFOCUS_LOSS`
tailored to the media content type.
---
# 82. AUDIO FOCUS LOSS SCENARIOS
Scenario:
```text
music or video actively playing
↓
secondary application initiates audio playback
```
Verify that the app responds appropriately according to focus rules.
---
# 83. TRANSIENT FOCUS LOSS RESTORATION
When playback auto-pauses due to transient focus loss (e.g., incoming notification chime), verify that it resumes automatically only if it was playing prior to the interruption.
---
# 84. USER PAUSE VS SYSTEM PAUSE INTEGRITY
Critical state flag:
```text
wasPlayingBeforeFocusLoss
```
Without this distinction, an app will un-pause itself following a notification sound even if the user deliberately paused the audio earlier.
---
# 85. DUCKING BEHAVIOR
If the media type permits ducking:
Verify that volume lowers smoothly and restores to normal when the transient event concludes.
---
# 86. AUDIO FOCUS ABANDONMENT
When media playback stops or the player is released, verify that audio focus is explicitly abandoned so other applications can reclaim it.
---
# 87. INCOMING PHONE CALL INTERRUPTIONS
Simulate an incoming phone call across audio and video playback paths.
---
# 88. HEADPHONE UNPLUGGING
Standard mobile media requirement:
```text
audio playing through wired headphones
↓
headphones disconnected
```
Verify that playback pauses immediately to prevent sudden loud blasting through device speakers.
---
# 89. `ACTION_AUDIO_BECOMING_NOISY`
Verify proper registration and handling of `AudioManager.ACTION_AUDIO_BECOMING_NOISY` (or automated Media3 handling).
---
# 90. BLUETOOTH AUDIO DISCONNECTION
Ensure disconnection of Bluetooth headsets or car audio triggers the same defensive pause behavior as unplugging wired headphones.
---
# 91. AUDIO ROUTING CHANGES
Switching between headphones, Bluetooth, and internal speakers must not reset playback progress or crash the player.
---
# 92. DEVICE VOLUME OVERRIDES
Never overwrite the global Android system volume programmatically without explicit, justifiable user settings.
---
# 93. IN-APP MUTE SYNCHRONIZATION
If the app provides an internal mute toggle, verify that mute state is synchronized across UI controls and audio renderers.
---
# 94. VIDEO SURFACE OWNERSHIP
Explicitly map ownership of the `SurfaceView`, `TextureView`, or `PlayerView`.
---
# 95. SURFACE DESTRUCTION
Scenario:
```text
video playing
↓
screen / View destroyed
↓
underlying Surface destroyed
```
The player must immediately detach from the destroyed surface to avoid rendering into an invalid native handle.
---
# 96. SURFACE REATTACHMENT
When navigating back to a playing video, a newly created View must attach to the existing player without instantiating an unnecessary duplicate player.
---
# 97. BLACK FRAME MITIGATION
During source changes and surface reattachment, verify that placeholder posters or loading overlays mask black frames until the first video frame is decoded.
---
# 98. PLAYERVIEW TRANSITIONS
When transferring a single active player between an embedded inline view and a fullscreen container, audit surface transfer continuity.
---
# 99. FULLSCREEN TRANSITIONS
Audit:
- Screen orientation locking / unlocking
- System bars visibility (immersive mode)
- View hierarchy transfers
- Back press handling
- Surface stability
---
# 100. FULLSCREEN ACTIVITY RECREATION
If fullscreen toggles trigger Activity recreation due to orientation changes, audit playback continuity.
---
# 101. ORIENTATION CHANGES
Playback must not restart from the beginning or glitch simply because the device was rotated, provided continuity is expected.
---
# 102. CONFIGURATION CHANGE AUDIT
Re-verify across configuration changes:
- Player instance survival
- Surface reattachment
- Playback position
- Custom controls state
- Selected subtitle tracks
---
# 103. JETPACK COMPOSE INTEGRATION
If the player UI is built with Compose:
Never instantiate the player directly inside a Composable function body.
Inspect:
- `remember` usage
- `DisposableEffect` cleanup
- ViewModel or Service ownership models
---
# 104. `AndroidView(factory = { PlayerView(...) })`
Audit:
- Factory block instantiation
- Update block assignments
- Player attachment and detachment
- Release on disposal
---
# 105. COMPOSE DISPOSAL SEMANTICS
When a media Composable leaves the composition:
Should it detach the surface only, or release the entire player?
The answer depends strictly on player ownership.
---
# 106. CONTROL STATE CANONICALITY
Custom Compose playback controls must read from canonical player and session state.
Never maintain a detached parallel state like:
```text
var isPlayingLocal by remember { mutableStateOf(false) }
```
when the underlying player can be toggled by notifications, Bluetooth, or headphones.
---
# 107. REACTING TO EXTERNAL CONTROL EVENTS
Playback state can mutate via:
- Lockscreen notifications
- Headset hardware buttons
- Bluetooth controls
- Automatic track completion
The in-app UI must react reactively to all external state shifts.
---
# 108. PROGRESS SEEKBAR INTEGRITY
Audit:
- Periodic player position polling
- User scrub gestures
- Asynchronous seek execution
- Live window boundaries
- Unknown duration handling
---
# 109. SEEKBAR UPDATE FREQUENCY
Avoid updating Compose or View state hundreds of times per second.
Maintain a balanced cadence (e.g., 200-500ms intervals) for smooth UI without battery drain.
---
# 110. SCRUBBING CONCURRENCY RACE
Scenario:
```text
user drags seekbar thumb to position 00:45
↓
periodic player position update arrives for 00:10
↓
seekbar thumb snaps backward against user touch
```
Verify that user scrubbing temporarily suppresses external position polling updates.
---
# 111. SUBTITLE AND CLOSED CAPTION TRACKS
Where subtitles exist:
- Track selection mechanics
- Enable / disable toggle
- Language preference mapping
- Custom text styling
- User preference persistence
---
# 112. SUBTITLE TRACK IDENTITY ACROSS ITEMS
A newly loaded media item must not blindly apply track index integers from the previous item if track layouts differ.
---
# 113. SUBTITLE PREFERENCES VS SPECIFIC TRACKS
User language preferences may be global, but concrete track selection must be resolved per media item.
---
# 114. SIDELOADED EXTERNAL SUBTITLES
Audit cache paths, file permissions, and download lifecycles for external subtitle files.
---
# 115. MISSING EXTERNAL SUBTITLE TOLERANCE
If an optional external subtitle file fails to load or 404s, media playback must proceed rather than failing completely.
---
# 116. ALTERNATIVE AUDIO TRACKS
Apply the same rigor to multi-language and descriptive audio track selections.
---
# 117. TRACK SELECTION POLICIES
Verify:
- Default audio language selection
- Default subtitle language selection
- Forced subtitles for foreign-language dialogue
- Explicit disabled states
---
# 118. VIDEO QUALITY SELECTION
When users manually select video resolution (e.g., Auto, 720p, 1080p):
Ensure the UI does not offer resolution options that the active stream does not provide.
---
# 119. STALE TRACK OVERRIDES
Track overrides applied to an older source must not break or distort subsequent sources in the queue.
---
# 120. DIGITAL RIGHTS MANAGEMENT (DRM)
If DRM is utilized, conduct a dedicated security and reliability pass.
If not:
**NOT APPLICABLE**
---
# 121. DRM SESSION LIFECYCLE
Inspect:
- License acquisition flows
- License renewal timing
- Expiration handling
- Offline license storage if supported
---
# 122. DRM ERROR RECOGNITION
Differentiate DRM authorization rejections from generic network socket drops.
---
# 123. AUTHENTICATION AND DRM RACE CONDITIONS
Token refresh calls and DRM license requests can race concurrently against media segment authentication.
---
# 124. OFFLINE MEDIA PLAYBACK
Where downloaded media is supported:
```text
download
↓
integrity verification
↓
local file reference
↓
playback
```
---
# 125. PARTIAL DOWNLOAD CONTAMINATION
The player must not attempt to play an incomplete download as a finished file unless progressive playback is explicitly architected.
---
# 126. DOWNLOAD INVALIDATION AND EXPIRY
When content licenses expire or user entitlements are revoked, define what occurs to local downloaded assets.
---
# 127. DELETED LOCAL FILE RECOVERY
If the user or operating system removes a cached media file, the UI must handle the missing asset gracefully without crashing.
---
# 128. CACHE SEGREGATION
Distinguish between:
- Short-term media segment cache
- Durable downloaded assets
- Temporary buffering memory
Never treat volatile cache as durable offline storage.
---
# 129. CACHE SIZE AND EVICTION POLICIES
If using `SimpleCache` or custom cache singletons:
Verify eviction rules, max cache size bounds, and directory locations.
---
# 130. CACHE KEYS FOR DYNAMIC URLS
If stream URLs contain expiring query signatures, identical media will produce duplicate cache entries unless a stable cache key provider is configured.
---
# 131. CROSS-USER MEDIA CACHE ISOLATION
If media access requires user authentication, verify that cached media segments belonging to User A cannot be accessed by User B.
---
# 132. LOGOUT CLEANUP
Upon user logout:
- Active playback stopped
- `MediaSession` cleared
- Media notification dismissed
- In-memory playlist purged
- Access to private offline media revoked
- Cache eviction policies enforced
---
# 133. USER SWITCHING PLAYBACK CONTINUITY
Scenario:
```text
User A starts private audio stream
↓
User A logs out
↓
User B logs in
```
Verify that:
- User A's stream does not continue playing
- User A's metadata does not linger on lockscreen
- User B cannot resume User A's private playback
---
# 134. AUTHENTICATION EXPIRY DURING PLAYBACK
When a user's session expires mid-stream:
- Currently buffered segments may continue briefly
- Next segment or license fetch will return HTTP 401
Verify recovery or clean termination.
---
# 135. TOKEN REFRESH CONCURRENCY UNDER PLAYBACK
Multiple concurrent media chunk requests can receive HTTP 401 at the same moment.
Verify single-flight token refresh to prevent redundant re-auth calls.
---
# 136. GOOGLE CAST INTEGRATION
When Google Cast is supported:
**The local player is no longer the sole source of truth.**
Map the remote Cast session state.
---
# 137. LOCAL TO CAST HANDOFF
Verify transfer of:
- Active content ID
- Playback position
- Play / pause status
- Queue items and metadata
---
# 138. CAST TO LOCAL HANDOFF
Verify seamless return when disconnecting from a Cast device.
---
# 139. ABRUPT CAST DISCONNECTION
If the remote Cast receiver drops unexpectedly:
Determine whether local playback resumes automatically, pauses, or prompts the user.
---
# 140. MULTI-CONTROLLER CONFLICTS
Cast, system notifications, headsets, and in-app buttons can all dispatch commands.
Ensure a single authoritative state reconciles all inputs.
---
# 141. PICTURE-IN-PICTURE (PIP) TRANSITIONS
If PiP is supported, audit the entry sequence:
```text
fullscreen / standard playback
↓
user presses Home or enters PiP
```
---
# 142. PIP ACTION CONTROLS
Verify that play, pause, and skip actions rendered inside the PiP window manipulate the active player state accurately.
---
# 143. EXITING PIP MODE
Returning to the full application must not spawn a duplicate player or re-prepare the stream from scratch.
---
# 144. PIP CONFIGURATION STABILITY
PiP transitions trigger multi-window lifecycle events.
Ensure the player remains stable across PiP transitions.
---
# 145. UNINTENDED AUTO-ENTER PIP
If using `setAutoEnterEnabled(true)`, ensure the app does not enter PiP when playback is paused or completed.
---
# 146. BACK NAVIGATION BEHAVIOR
Pressing Back during playback can:
- Dismiss custom controls overlay
- Exit fullscreen mode
- Navigate to the previous screen
- Collapse into mini-player / background audio
Define clear, consistent product navigation semantics.
---
# 147. MOVING TO APP BACKGROUND
Scenario:
```text
video or audio playing
↓
user presses Home
```
Evaluate:
- Should playback continue or pause?
- Should the video surface detach cleanly?
- Should audio continue under a Foreground Service?
- Is a media notification displayed?
---
# 148. SCREEN OFF / DEVICE LOCK
Audio streaming should typically continue playing when the screen turns off.
For video apps, behavior must align with product specifications.
---
# 149. RETURNING TO FOREGROUND
Foregrounding the application must not:
- Restart the stream from the beginning
- Reset playback progress
- Re-instantiate the player instance
---
# 150. SYSTEM PROCESS DEATH
When background playback is not configured:
System process termination will destroy the player.
Verify what state is restored when the user re-opens the app.
---
# 151. DURABLE PLAYBACK STATE ATTRIBUTES
Classify which attributes should survive process termination:
- Media ID
- Active playlist
- Resume position
- Playback speed
- Subtitle preference
- Audio track preference
---
# 152. PLAYBACK SPEED PERSISTENCE
If custom playback speed (e.g., 1.5x) is supported:
- Persistence rules
- Scope (per item vs global)
- UI state synchronization
---
# 153. AUTOPLAY RESTORATION DISTINCTIONS
Restoring playback position from disk does not mean the player should automatically begin playing unprompted upon cold startup.
Separate state restoration from autoplay decisions.
---
# 154. MEDIA BUTTON WAKEUP AFTER PROCESS DEATH
If the system delivers a media button event to revive a terminated audio session, verify the recreation pathway where supported.
---
# 155. ANDROID AUTO AND EXTERNAL MEDIA BROWSING
If implementing `MediaLibraryService`:
Audit content hierarchy browsing, authorization checks, and playback commands.
If not:
**NOT APPLICABLE**
---
# 156. ANDROID TV SPECIFICS
If targeting Android TV, execute a dedicated pass covering:
- D-pad directional navigation
- Focus management and visibility
- Fast channel zapping
- Remote media button keys
- Back button behavior
- On-screen control overlays
- Electronic Program Guide (EPG) interactions
---
# 157. TV CHANNEL ZAPPING PERFORMANCE
For Live TV applications, measure or analyze the critical path:
```text
remote click
↓
channel resolution
↓
source prepare
↓
first audio / video frame rendered
```
If not measured in runtime:
**ZAP TIME: NOT MEASURED**
---
# 158. STALE STREAM OVERWRITE UPON RAPID ZAP
Critical race condition:
```text
Channel A source resolution begins
↓
user selects Channel B
↓
Channel B prepares and starts playing
↓
Channel A resolution completes late
↓
stale callback sets Channel A source
↓
player reverts to wrong channel
```
---
# 159. MULTIVIEW PLAYBACK CONCURRENCY
If rendering multiple video players simultaneously:
- Hardware decoder limits
- Audio focus assignment
- Active audio tile selection
- Cleanup of unmounted tiles
- Off-screen player suspension
---
# 160. HARDWARE DECODER CONSTRAINTS
Many mobile and TV chipsets can only decode a limited number of high-resolution video streams concurrently.
Do not assert exact hardware limits without physical device testing.
---
# 161. AUDIO ROUTING IN MULTIVIEW
In multi-player layouts, ensure only the user-selected active tile outputs audio.
---
# 162. OFF-SCREEN VIDEO PLAYERS
Players scrolled out of viewport view must not continue decoding video frames in the background unless explicitly required.
---
# 163. PRELOADING TRADEOFFS
Preloading adjacent channels or videos accelerates startup but consumes:
- Network bandwidth
- RAM buffers
- Available hardware decoders
Classify as an architectural tradeoff.
---
# 164. GAPLESS AUDIO PLAYBACK
If the audio player promises gapless playback, verify track preparation and queue transitions.
---
# 165. AUDIO CROSSFADE
If crossfading tracks, verify behavior during manual track skipping and audio focus interruptions.
---
# 166. AUDIO SESSION AND EQUALIZER EFFECTS
If using system audio effects or equalizers, verify lifecycle binding to the player's active audio session ID.
---
# 167. AUDIO VISUALIZERS
High-frequency visualizer data callbacks must never perform heavy CPU or UI operations on the audio thread.
---
# 168. PLAYBACK THREAD STARVATION
Never block the player's internal playback thread with heavy disk I/O, database writes, or synchronous networking inside listeners.
---
# 169. MAIN THREAD CALLBACK HAZARDS
When player listeners deliver events on the Main thread, do not execute:
- Database transactions
- File operations
- Heavy JSON parsing
directly within the callback body.
---
# 170. HIGH-FREQUENCY EVENT FLOODING
The player emits frequent timeline and position updates.
Do not write every position tick into persistent databases or telemetry pipelines.
---
# 171. PLAYBACK TELEMETRY AND ANALYTICS
Audit telemetry events:
- Playback start / play request
- Time to first frame
- Buffering start / end
- Rebuffer events
- Seek events
- Playback errors
- Playback completion
Verify that duplicate events are not emitted due to listener re-registration.
---
# 172. ACCURATE WATCH-TIME ACCOUNTING
When measuring total watch duration, ensure paused, buffering, and background states are segregated accurately from active playback.
---
# 173. SENSITIVE DATA IN CRASH REPORTS
Never log signed streaming URLs, user authentication headers, or license tokens into crash reporting breadcrumbs.
---
# 174. LOGGING HYGIENE
Mask and sanitize:
- Authentication headers
- Signed stream URLs
- DRM license payloads
- Personally identifiable media IDs
---
# 175. PLAYBACK PERFORMANCE ANALYSIS
For media performance, analyze:
- Startup latency
- Rebuffering frequency and duration
- Dropped video frames
- Hardware vs software decoder selection
- CPU utilization
- Memory footprint
If not empirically benchmarked:
**NOT MEASURED**
---
# 176. TIME TO FIRST VIDEO FRAME
Where profiling tools allow, evaluate:
```text
user click play
↓
first video frame rendered on screen
```
---
# 177. TIME TO FIRST AUDIO
For live TV and audio apps, measure time to first audio output separately from video.
Do not invent fabricated numbers.
---
# 178. REBUFFER RATIO
Do not assert specific rebuffering percentages without production telemetry data.
---
# 179. DROPPED VIDEO FRAMES
Do not declare a dropped-frame bug purely from code inspection.
Flag as:
**CODE-LEVEL RISK**
if obvious Main thread bottlenecks or unthrottled redraw loops exist.
---
# 180. CUSTOM LOAD CONTROL TUNING
If the app configures custom buffer sizes (`DefaultLoadControl`):
Evaluate the technical rationale.
Do not recommend custom buffer tuning unless a concrete operational failure requires it.
---
# 181. PREBUFFERING TRADEOFFS
Balancing:
```text
lower initial startup latency
vs
excessive bandwidth and memory consumption
```
---
# 182. LOW BANDWIDTH CONDITIONS
Audit player behavior under restricted bandwidth:
- Adaptive bitrate stepping
- Buffering notifications
- Retry mechanics
- User feedback
---
# 183. HIGH LATENCY IN LIVE STREAMS
High end-to-end stream latency is distinct from local buffering.
If low-latency live streaming is required, verify LL-HLS or chunked DASH configuration.
---
# 184. LOW-LATENCY HLS/DASH PREREQUISITES
Do not demand low-latency protocols unless supported by backend encoders and required by product scope.
---
# 185. ACCESSIBILITY IN PLAYBACK
Inspect:
- Subtitle and closed caption accessibility
- Screen reader focus navigation across controls
- TalkBack content descriptions
- Contrast and touch target sizing
---
# 186. PLAYBACK CONTROL CONTENT DESCRIPTIONS
Every icon-only control button must supply an informative, localized `contentDescription`.
---
# 187. DYNAMIC PLAY/PAUSE ACCESSIBLE LABELS
The accessible description must dynamically reflect the action that will occur when tapped:
```text
Play
```
or:
```text
Pause
```
rather than a generic static label like "Playback".
---
# 188. SUBTITLE READABILITY AND SCALING
Ensure subtitle overlays respect system font scaling and caption styling preferences.
---
# 189. FULLSCREEN ACCESSIBILITY TRAPS
Ensure controls do not become inaccessible or unreachable to screen readers upon entering fullscreen or changing orientation.
---
# 190. AUTOMATED TEST SUITE AUDIT
Inspect the existing media test coverage:
- Player unit tests
- Fake player state machine tests
- MediaSession integration tests
- Instrumented UI tests
- Network streaming mocks
- Edge case simulations
---
# 191. FAKE PLAYER LIMITATIONS
A fake player is effective for verifying UI state machines, but cannot prove real hardware decoder or streaming network resilience.
---
# 192. MEDIA3 TEST UTILITIES
Verify whether the project utilizes official Media3 testing libraries where applicable.
---
# 193. CORE PLAYBACK STATE TESTS
Test transitions across:
```text
IDLE
BUFFERING
READY
ENDED
ERROR
```
---
# 194. SOURCE SWITCHING CONCURRENCY TESTS
Control timing:
```text
Source A requested
↓
Source B requested before A reaches READY
```
Assert that final player and UI state belongs strictly to Source B.
---
# 195. PLAYBACK ERROR RECOVERY TESTS
Simulate:
- Connection timeout
- HTTP 403
- HTTP 404
- HTTP 500
- Hardware decoder failure
---
# 196. AUDIO FOCUS CONCURRENCY TESTS
Test:
```text
playing
↓
transient focus loss
↓
focus restored
```
alongside:
```text
user explicitly pauses while focus was lost
```
---
# 197. HEADSET DISCONNECTION TESTS
Test:
```text
playing through headphones
↓
disconnect headphones
```
Assert that playback pauses immediately.
---
# 198. BACKGROUND TRANSITION TESTS
Test:
```text
playing
↓
user presses Home
↓
wait
↓
user returns to app
```
Assert continuity of state, position, and notification.
---
# 199. ROTATION INTEGRITY TESTS
Test:
```text
video playing
↓
rotate device
```
Assert:
- No duplicate player created
- Playback position preserved
- No visual restarting of stream
---
# 200. PIP TRANSITION TESTS
If supported:
```text
play
↓
enter PiP
↓
toggle play/pause in PiP
↓
expand back to fullscreen
```
---
# 201. MEDIA NOTIFICATION ACTION TESTS
Assert that notification action clicks directly manipulate the canonical player and UI.
---
# 202. PROCESS DEATH RESTORATION TESTS
Where state restoration is supported:
Seed content ID, position, and queue.
Simulate process kill, relaunch, and verify expected resume behavior.
---
# 203. LIVE STREAMING RESILIENCE TESTS
For live media:
- Initial startup
- Network drops and reconnects
- Behind-live-window recovery
- Go-live execution
- Channel switching
---
# 204. RAPID ZAPPING SIMULATION TESTS
For Live TV:
```text
Channel A -> B -> C -> D
```
with artificially delayed source resolution responses.
Assert that Channel D remains the final active stream.
---
# 205. LOGOUT MID-PLAYBACK TEST
Scenario:
```text
authenticated stream playing
↓
user logs out
```
Assert:
- Playback halts immediately
- Notification and session cleared
- Protected media cannot be played by subsequent accounts
---
# 206. AUTHENTICATION EXPIRY TEST
Inject HTTP 401 on media chunk or license requests mid-stream.
Verify graceful error handling or re-authentication recovery.
---
# 207. MULTIVIEW CONCURRENCY TESTS
Where multiple players are shown:
- Add and remove player tiles
- Switch active audio focus tile
- Background and foreground app
- Verify total player releases
---
# 208. EXTENDED DURATION STABILITY TESTS
Media apps run continuously for hours.
Audit:
- Native memory growth
- Listener accumulation
- Disk cache expansion
- Hardware decoder leaks over hundreds of source transitions
---
# 209. SUBSTANTIVE FINDING REPORTING TEMPLATE
Every substantive finding must be documented using this exact structure:
```text
ID:
Severity:
Category:
Confidence:
Status:
Feature:
Media type:
Playback mode:
Screen:
Player owner:
Session owner:
File/Class:
Relevant code:
Source:
Lifecycle state:
Problem:
Evidence:
Playback Timeline:
T0:
T1:
T2:
T3:
Expected player state:
Actual/Possible player state:
User impact:
Resource impact:
Data/Privacy impact:
Root cause:
Recommended remediation:
Regression test:
Runtime verification:
Complexity:
XS / S / M / L / XL
```
---
# 210. SEVERITY RATING SYSTEM
Apply strict severity definitions:
## P0 - CRITICAL
- Private media exposure across user accounts
- Critical security vulnerabilities through media sessions or caches
- Catastrophic, irreversible actions triggered through playback features
## P1 - HIGH
- Primary playback flow fails routinely
- Player or codec leaks causing app crashes or device instability
- Background playback and MediaSession completely desynchronized
- Rapid source switching plays wrong content or plays overlapping streams
- User logout leaves private streams actively playing
## P2 - MEDIUM
- Substantial buffering, recovery, or lifecycle defects
- Audio focus violations causing significant user disturbance
- Playback position or track selections lost during standard workflows
## P3 - LOW
- Bounded media edge cases
- Minor metadata or cosmetic control indicator discrepancies
## P4 - IMPROVEMENT
- Playback UX or performance enhancements without verified functional failure
---
# 211. CONFIDENCE RATINGS
Use:
```text
HIGH
MEDIUM
LOW
```
HIGH:
Empirically reproduced at runtime or directly proven via lifecycle and concurrency code paths.
MEDIUM:
Strong code-level evidence, but untested against live streaming infrastructure or physical devices.
LOW:
Dependent upon OEM-specific codecs, streaming CDN behaviors, or unverified runtime configurations.
---
# 212. VERIFICATION STATUS
Use:
```text
CONFIRMED
LIKELY
THEORETICAL
NOT VERIFIED
```
---
# 213. MEDIA VERIFICATION FLAGS
Include where applicable:
```text
STREAM VERIFIED:
YES
NO
DEVICE VERIFIED:
YES
NO
BACKGROUND VERIFIED:
YES
NO
```
---
# 214. PERFORMANCE VERIFICATION FLAGS
For performance findings:
```text
MEASURED
CODE-LEVEL RISK
NOT MEASURED
```
---
# 215. STREAM AND SERVER CONTRACT STATUS
When behavior depends upon server policies:
```text
STREAM/SERVER CONTRACT:
VERIFIED
INFERRED
NOT VERIFIED
```
---
# 216. FALSE POSITIVE PREVENTION RULES
Before asserting P1 or P2 findings, inspect:
1. Exact player owner
2. MediaSession owner
3. Service boundaries
4. UI lifecycle scopes
5. Player listener callbacks
6. Underlying MediaSource configuration
7. Network and authentication layers
8. Library implementation contracts
9. Target Android SDK levels
10. Existing automated tests
Never conclude a leak exists simply because the player is not released within the local UI file.
---
# 217. AVOID DEFAULTING PLAYER TO VIEWMODEL
A ViewModel is not a universal owner for Android media players.
Ownership must be dictated by playback lifetime requirements and system architecture.
---
# 218. AVOID DEFAULTING PLAYER TO SINGLETON
A global singleton solves one lifetime challenge while introducing:
- Memory leaks
- Stale MediaSessions
- Cross-screen state bleed
- Cross-account playback contamination
---
# 219. DO NOT RETRY ALL PLAYBACK FAILURES
Transient network timeouts differ fundamentally from:
- Unsupported video codecs
- HTTP 404 missing assets
- Malformed manifests
- DRM permission rejections
---
# 220. AVOID FULL PLAYER RE-CREATION ON MINOR ERRORS
Recreating the entire player instance from scratch loses:
- Playback position
- Selected track preferences
- Active playlist queue
- Session connection state
Apply the minimal necessary recovery action.
---
# 221. DO NOT TUNE BUFFER SIZES WITHOUT BENCHMARKS
Increasing buffer sizes:
- Consumes more memory
- Can increase startup latency
- Consumes user bandwidth
Decreasing buffer sizes:
- Increases rebuffering risks
Never tune without documented evidence.
---
# 222. DO NOT MODIFY CODE DURING THE AUDIT
Throughout the audit:
- Do not change player ownership
- Do not add services
- Do not tweak buffer parameters
- Do not rewrite retry policies
- Do not introduce PiP
- Do not modify MediaSession configurations
- Do not alter source resolution logic
Complete the investigation first.
---
# 223. OUTPUT REPORT STRUCTURE - ANDROID_MEDIA_PLAYBACK_AUDIT.md
Structure the audit report:
## 1. Executive Summary
- Media technology stack
- Supported media formats
- Player ownership model
- Background playback architecture
- Principal playback risks
## 2. Playback Architecture Map
## 3. Player Lifecycle Audit
## 4. Media Source Audit
## 5. Playback State Audit
## 6. Buffering Audit
## 7. Error / Recovery Audit
## 8. Network Failure Audit
## 9. Live Playback Audit
## 10. Seek / Position Audit
## 11. Playlist / Queue Audit
## 12. MediaSession Audit
## 13. MediaSessionService Audit
## 14. Notification Controls Audit
## 15. Audio Focus Audit
## 16. Headset / Bluetooth Audit
## 17. Video Surface Audit
## 18. Compose / View Integration Audit
## 19. Subtitle / Track Selection Audit
## 20. Offline / Cache Audit
## 21. PiP Audit
## 22. Cast Audit
## 23. Android TV / Multiview Audit
## 24. Auth / Logout / Account Isolation
## 25. Media Performance
## 26. Accessibility
## 27. Test Coverage
## 28. Findings Summary
| ID | Severity | Playback Area | Problem | Confidence | Status |
|---|---|---|---|---|---|
## 29. P0 Findings
## 30. P1 Findings
## 31. P2 Findings
## 32. P3 Findings
## 33. P4 Improvements
## 34. Things Done Well
## 35. Unknown / Not Verified
## 36. Remediation Roadmap
---
# 224. PLAYER LIFETIME MATRIX
Construct:
| Resource | Owner | Created | Released | Expected Lifetime | Risk |
|---|---|---|---|---|---|
Covering:
- Player
- MediaSession
- MediaController
- PlayerView
- Video Surfaces
- Listeners
---
# 225. PLAYBACK STATE MATRIX
| Scenario | Expected State | Actual Code Path | Verified |
|---|---|---|---|
Covering:
- Open
- Buffering
- Ready
- Pause
- Seek
- Error
- Ended
- Background transition
- Foreground resume
---
# 226. PLAYBACK ERROR MATRIX
| Failure Type | Retryable | Re-resolve Source | User Action Required | Terminal State |
|---|---|---|---|---|
---
# 227. AUDIO FOCUS MATRIX
| Event | State Prior | Expected Action | Auto-Resume Permitted |
|---|---|---|---|
---
# 228. SOURCE SWITCHING MATRIX
| Transition | Old Source Cancelled | Stale Callback Guarded | State Reset | Risk |
|---|---|---|---|---|
---
# 229. BACKGROUND PLAYBACK MATRIX
| Scenario | Player State | Session State | Notification Status | Expected Behavior |
|---|---|---|---|---|
---
# 230. SECOND PASS - RAPID SOURCE ATTACK SCENARIO
For every feature supporting source changes:
```text
Source A begins resolving
↓
Source B selected
↓
Source C selected
↓
Source C begins playback
↓
Source A resolves late
```
Evaluate:
> Can Source A's delayed callback overwrite the player that should remain on Source C?
---
# 231. SECOND PASS - PLAYER LIFECYCLE REPEAT ATTACK
Simulate:
```text
play media
↓
rotate device
↓
background app
↓
foreground app
↓
navigate away
↓
return to screen
```
The count of active players and hardware decoders must match the architectural specification.
---
# 232. SECOND PASS - AUDIO INTERRUPTION AND MANUAL PAUSE
Simulate:
```text
playing media
↓
transient audio focus loss occurs
↓
user manually presses Pause during the interruption
↓
transient focus returns
```
The player must not resume automatically against the user's explicit manual pause.
---
# 233. SECOND PASS - DEGRADED AND RECONNECTING NETWORK
Simulate:
```text
actively playing
↓
network throttles to near-zero
↓
network disconnects
↓
network reconnects
↓
auth token expires during interruption
```
Trace state recovery and error handling.
---
# 234. SECOND PASS - EXPIRED STREAM URL RECOVERY
If media URLs expire:
```text
resolve stream URL
↓
wait until URL expires
↓
initiate playback or retry
```
Verify that the recovery path requests a fresh URL rather than retrying the dead link.
---
# 235. SECOND PASS - PROCESS DEATH ON ACTIVE SCREEN
Simulate process termination while viewing media.
Evaluate:
- Which content ID persists
- Which playback position is saved
- Which queue survives
- Whether autoplay resumes appropriately upon return
---
# 236. SECOND PASS - USER LOGOUT MID-PLAYBACK
Scenario:
```text
private authenticated stream playing
↓
user logs out
```
Audit:
- Player state
- Service destruction
- Notification dismissal
- MediaSession cleanup
- Local cache security
- Controller detachment
---
# 237. SECOND PASS - MULTI-CONTROLLER CONCURRENT COMMANDS
Simultaneously issue playback commands from:
- In-app UI
- System notification
- Headset / Bluetooth hardware button
Evaluate:
> Do all controllers observe and manipulate a single canonical state?
---
# 238. SECOND PASS - EXTENDED PLAYBACK SESSION STABILITY
Simulate hours of continuous playback across dozens of track transitions.
Evaluate:
- Native memory growth
- Listener accumulation
- Disk cache inflation
- Hardware decoder releases
- Surface recycling
---
# 239. SECOND PASS - LOW-END HARDWARE CONSTRAINTS
For video and multiview applications:
Evaluate:
- Active decoder count
- Memory footprint
- Dropped frame hazards
If not tested on physical hardware:
**NOT MEASURED**
---
# 240. SECOND PASS - ROLLING LIVE WINDOW EXPIRATION
For live streams with DVR:
```text
pause live playback
↓
wait until paused point drops behind the rolling DVR window
↓
press resume
```
Verify recovery behavior when the requested segment no longer exists on the server.
---
# 241. SECOND PASS - PICTURE-IN-PICTURE INTERACTION
If PiP is supported:
```text
play video
↓
enter PiP
↓
pause from PiP controls
↓
expand back to fullscreen UI
```
Verify canonical UI state synchronization.
---
# 242. FINAL QUALITY GATE
Before finalizing the audit report, verify:
- Player owner is explicitly identified
- Player lifecycle matches product requirements
- Duplicate player instance risks are evaluated
- Listener unregistration and cleanup are verified
- UI state does not maintain detached duplicate states
- Rapid source switching handles stale callbacks safely
- Network retries differentiate permanent from transient failures
- Expiring signed URLs trigger re-resolution upon retry
- Audio focus differentiates user pause from system interruption pause
- Headset and Bluetooth disconnection behavior is audited
- MediaSession metadata updates synchronously
- Notification controls manipulate the canonical player
- Video surface destruction and reattachment are analyzed
- Screen rotation does not create duplicate players
- User logout immediately terminates private playback
- Multi-account isolation is enforced across cache, storage, and sessions
- Process death is not conflated with simple configuration changes
- Performance metrics are not fabricated
- Buffer tuning is not recommended without empirical data
- Live streams and VOD are analyzed with distinct criteria
- PiP, Cast, DRM, and TV sections are marked NOT APPLICABLE if absent
- Every P1 and P2 finding includes a concrete playback timeline
- Architectural improvements (P4) are strictly separated from correctness bugs
---
# FINAL RULE
Do not deliver a report stating:
> Use Media3, implement MediaSession, handle audio focus, and release the player.
That is not a media playback audit.
Seek concrete systemic failures such as:
```text
Channel A source resolution starts
↓
user immediately chooses Channel B
↓
Channel B resolves and starts playing
↓
Channel A resolves later
↓
old callback calls setMediaItem(A)
↓
player reverts to wrong channel
```
or:
```text
player created directly in Composable function
↓
recomposition triggers
↓
second player instance created
↓
old player retains hardware decoder and listeners
↓
memory and native media resources accumulate
```
or:
```text
audio focus transiently lost
↓
player auto-pauses
↓
user manually pauses while interrupted
↓
audio focus returns
↓
app blindly resumes playback
↓
audio blasts against user's explicit intent
```
or:
```text
signed stream URL resolved
↓
app backgrounds for 30 minutes
↓
signed URL expires
↓
user returns to app
↓
player retries same expired URL
↓
HTTP 403 Forbidden
↓
retry loop can never recover
```
or:
```text
User A plays private authenticated content
↓
User A logs out
↓
MediaSessionService remains running
↓
notification and player remain active
↓
User B logs in
↓
User A's content continues playing under User B's session
```
or:
```text
live stream paused
↓
user remains paused longer than server DVR window
↓
old media segment disappears from server
↓
user resumes
↓
player hits behind-live-window exception
↓
UI provides no recovery to current live edge
```
These are the media playback failures you must uncover.
Think through:
- Player ownership
- Media source identity
- Android lifecycle
- Callback ordering
- Buffering dynamics
- Error recovery
- Audio focus
- MediaSession ownership
- Background playback
- Process death
- User and account boundaries
- Long-running resource stability
For every substantive finding, you must answer:
> Who owns the player?
> Which media item is currently canonical?
> What happens if source resolution returns late?
> What happens when network connectivity drops?
> What happens when the user navigates to the background?
> What happens when another application takes audio focus?
> What happens upon user logout?
> What happens if Android terminates the process?
If the answer cannot be proven:
**NOT VERIFIED.**
If behavior depends upon live streaming provider contracts:
**STREAM/SERVER CONTRACT NOT VERIFIED.**
If it represents only a UX or performance enhancement without verified functional failure:
**P4 - IMPROVEMENT.**
Uncovering 6 genuine playback lifecycle and concurrency defects with precise timelines is infinitely superior to writing 100 generic Media3 recommendations.
The goal is a forensically precise media playback audit from which every substantive finding translates directly into:
- a deterministic reproduction scenario
- a player lifecycle fix
- a stale-source guard
- a MediaSession correction
- an error recovery test
- an audio focus test
- a background/PiP test
- a production-verified playback architecture分类与标签
编程开发、安卓开发、媒体播放器、生命周期、后台播放、异常恢复