Derived from src/cocos/video/video-player.ts, src/cocos/video/video-player-enums.ts, src/cocos/video/video-player-impl-web.ts, src/cocos/video/video-player-impl.ts, src/cocos/video/video-downloader.ts, src/cocos/video/assets/video-clip.ts, src/cocos/core/platform/macro.ts, examples/video-basic/main.js, docs/manual/audio-video-webview.md, docs/notes/video-notes.md, build/cocosair.module.js (as of 2026-10-10).
What VideoPlayer is on Web
VideoPlayer (src/cocos/video/video-player.ts:51) requires a UITransform (:49) and, on Web, appends a real <video class="cocosVideo"> element to game.container (src/cocos/video/video-player-impl-web.ts:258-278) - the pixels never enter the WebGL frame buffer, and each frame the component pushes its node world matrix through the UI camera into a CSS matrix() transform on the element (src/cocos/video/video-player.ts:435-439, src/cocos/video/video-player-impl-web.ts:331-422). Codec support, autoplay behavior and end-of-file quirks belong to the browser: webkit keeps readyState at 3 in the measured matrix and pauses small videos at the end (docs/notes/video-notes.md:89-100, docs/notes/video-notes.md:120-139). VideoPlayer and VideoClip are on the bundle export list (build/cocosair.module.js, currently :161574).
Resource selection and source switching
resourceType is VideoPlayer.ResourceType.REMOTE (0) or LOCAL (1) (src/cocos/video/video-player-enums.ts:31-46, statics on the component src/cocos/video/video-player.ts:291); setting remoteURL or clip re-runs syncSource (:94-134, :374-393), which removes the old element and rebuilds it - syncClip/syncURL both call removeVideoPlayer first (src/cocos/video/video-player-impl-web.ts:114-124), and LOCAL uses clip.nativeUrl (:117). The LOCAL branch loads through VideoClip (src/cocos/video/assets/video-clip.ts) with the video downloader registered in src/cocos/video/video-downloader.ts. play/resume/pause/stop forward to the element wrapper (src/cocos/video/video-player.ts:492-533, src/cocos/video/video-player-impl-web.ts:73-112); stop sets currentTime = 0, pauses, and dispatches stopped on the next tick (:101-112).
Event surface
VideoPlayer.EventType (src/cocos/video/video-player.ts:290) is the string enum none, playing, paused, stopped, completed, meta-loaded, ready-to-play, error, clicked (src/cocos/video/video-player-enums.ts:48-95). __preload binds the DOM element events (loadedmetadata, canplay, play, playing, pause, click, ended, error - src/cocos/video/video-player-impl-web.ts:280-291) to those names and re-emits them on the node and through the serialized videoPlayerEvent handler list (src/cocos/video/video-player.ts:395-414, per-event emitters :441-480, handler array :303). state returns the last dispatched event name (:358-361), so ready-to-play is the load gate the example waits on before trusting duration (docs/manual/audio-video-webview.md:77). playOnAwake fires play() from ready-to-play (src/cocos/video/video-player.ts:142-148, :411-413, :446-450), and the element play() promise rejection on an ungestured page is caught silently - the head simply does not advance (src/cocos/video/video-player-impl-web.ts:73-88).
Playback evidence
Use currentTime (src/cocos/video/video-player.ts:321-339, backed by the element property src/cocos/video/video-player-impl-web.ts:161-166) plus isPlaying (src/cocos/video/video-player.ts:369-372), and wait for settled state rather than wall-clock: a paused seek also moves the head, so frame-decode proof needs drawImage pixel statistics with isPlaying confirmed first (docs/notes/video-notes.md:83-87). Seeking beyond duration clamps and pauses without emitting completed (docs/notes/video-notes.md:111-118); a seek near the file end combined with loop can race the loop restart on webkit and park the element paused (docs/notes/video-notes.md:120-139), so wait for nativeVideo.seeking === false before asserting wrap-around.
Transparent video (stayOnBottom)
stayOnBottom is Web-only and depends on canvas translucency (src/cocos/video/video-player.ts:266-288). It does two things: pushes the element to z-index: -32768 (src/cocos/video/video-player-impl-web.ts:228-234) and, on the next syncMatrix, sets the alpha of the scene-side batcher camera clear color to 0 and forces a full clear (:340-353; that camera is not the component's camera - docs/notes/video-notes.md:20-31). For this to show anything, macro.ENABLE_TRANSPARENT_CANVAS = true must be set before createAirApp, because the swapchain reads it once (src/cocos/core/platform/macro.ts:984, examples/video-basic/main.js:64, docs/notes/video-notes.md:34-35). Proof is a document.elementFromPoint hit flipping from VIDEO to CANVAS plus the scene-side clear alpha reading 0 (docs/notes/video-notes.md:28-33).
Fullscreen honesty
fullScreenOnAwake set before the clip is assigned takes the geometric path - syncMatrix stretches the element to visibleRect without any requestFullscreen (src/cocos/video/video-player.ts:247-264, docs/notes/video-notes.md:72-74, docs/manual/audio-video-webview.md:80-82). Setting it after load routes into canFullScreen, which early-exits unless readyState === 4 (src/cocos/video/video-player-impl-web.ts:175-226), passes the target element to a chain that ultimately requests fullscreen on document.body (measured fullscreenElement === BODY, docs/notes/video-notes.md:43-48), and has a registered defect chain (F-103) including a shadowed-document callback that logs a console error (docs/notes/video-notes.md:49-60). The reliable interactive path is calling await screen.requestFullScreen() / await screen.exitFullScreen() yourself inside a gesture (docs/notes/video-notes.md:66-71).
Lifecycle and leak counting
removeVideoPlayer detaches the element only when it is actually a child of game.container and clears listeners there (src/cocos/video/video-player-impl-web.ts:243-256), so the count of <video class="cocosVideo"> nodes in the DOM is the real leak counter: after node.destroy() the count must drop (docs/notes/video-notes.md:78-80). onDestroy releases the impl (src/cocos/video/video-player.ts:428-433); disabling the component pauses and hides the element (src/cocos/video/video-player-impl-web.ts:318-329). keepAspectRatio toggles object-fit intent but the engine positions by matrix, and the measured element always reports none across engines (docs/notes/video-notes.md:102-104).