Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-audio-video

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Play media with AudioService, VideoPlayer and WebView. Use for silent autoplay, advancing currentTime, BGM/SFX channels or DOM video and iframe overlays.

  • 9 files
  • 40.4 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-audio-video

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescontracts.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Derived from the cocosair-audio-video skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.

Contracts

  • AudioService surface is exactly: load (src/air/audio-service.ts:67, assetManager.loadRemote at :71), playBgm (:108, throws for an unloaded id :110, pauses other channels :111-113), pauseBgm (:120), stopBgm (:126, zeroes the head, keeps the id), setBgmVolume (:132, RangeError code AIR_E_AUDIO_VOLUME :134-136), resumeBgm (:145, continues from the preserved head), playSfx (:155), setMusicEnabled (:185, pauses BGM when off), setSfxEnabled (:191), bgmState (:199), dispose (:207), plus getters bgmId/musicEnabled/sfxEnabled/sfxActive (:97-101).
  • The SFX cap is real: option maxSfxVoices defaults to 5 (src/air/audio-service.ts:61), overflow fires increment sfxDropped and are dropped, never queued (:159); a voice frees its slot on AudioSource.EventType.ENDED (:175) with a bounded setTimeout fallback because autoplay rejection may emit no event (:177-179).
  • bgmState() returns { id, playing, currentTime, loop, volume } and currentTime is the measured clock (src/air/audio-service.ts:23-32, :199-204); the header comment records the discipline "playing=true alone does not prove the clock advances" (:8).
  • Gesture unlock is a browser+PAL contract: the engine resumes the AudioContext on the first touchend/mouseup capture (src/pal/audio/web/player-web.js:104-111, DOM-audio path src/pal/audio/web/player-dom.js:46-54); AudioSource.play() documents that pre-gesture plays may be queued or rejected (src/cocos/audio/audio-source.ts:351-354), and pending ops are held until the clip loads (:367-370).
  • AudioSource events are STARTED='started' and ENDED='ended' on the node (src/cocos/audio/audio-source.ts:36-39, :69, emitted :165-167, :380-381); currentTime get/set (:480-500), duration (:508), state (:518), playing (:528), playOneShot (:430).
  • VideoPlayer events are meta-loaded, ready-to-play, playing, paused, stopped, completed, error, clicked (src/cocos/video/video-player-enums.ts:48-95), bridged from the <video> element in __preload (src/cocos/video/video-player.ts:395-414); ResourceType.REMOTE|LOCAL (src/cocos/video/video-player-enums.ts:31-46) with play/resume/pause/stop (src/cocos/video/video-player.ts:492-533) and currentTime/duration/state/isPlaying/nativeVideo (:311-372).
  • Video is a DOM overlay: <video class="cocosVideo"> is appended to game.container (src/cocos/video/video-player-impl-web.ts:258-278) and positioned by a CSS matrix each frame (src/cocos/video/video-player.ts:435-439); transparent layering via stayOnBottom (src/cocos/video/video-player.ts:277-288) sets z-index:-32768 (src/cocos/video/video-player-impl-web.ts:228-234) and zeroes the scene-side camera clear alpha (:340-353), which requires macro.ENABLE_TRANSPARENT_CANVAS before createAirApp (src/cocos/core/platform/macro.ts:984, example usage examples/video-basic/main.js:64).
  • WebView events are loading, loaded, error (src/cocos/web-view/web-view-enums.ts:25-46), nativeWebView is the HTMLIFrameElement (src/cocos/web-view/web-view.ts:99-101), evaluateJS runs contentWindow.eval (:162-166, src/cocos/web-view/web-view-impl-web.ts:116-128); setJavascriptInterfaceScheme and setOnJSCallback are no-ops that warn on Web (src/cocos/web-view/web-view-impl-web.ts:130-136).
  • All six symbols (AudioService, AudioSource, AudioClip, VideoPlayer, VideoClip, WebView) are in the single export block of build/cocosair.module.js (currently :161574); AudioService reaches it through src/air/index.ts:27. Video and WebView capabilities remain browser-limited: codecs are the browser's, the iframe never enters the WebGL frame buffer, and webkit may pause small videos at the end (docs/notes/video-notes.md:89-98).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Edit Write Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "audio starts silently before a user gesture",
  "control BGM and SFX channels or volume",
  "prove playback time actually advances",
  "place video above or below the canvas",
  "WebView mounts the wrong URL"
]
owns
[
  "audio-service",
  "autoplay-unlock",
  "playback-time",
  "video-player",
  "webview"
]
not_for
[
  "shared remote-file caching -> cocosair-assets",
  "DOM input geometry or HTML textures -> cocosair-graphics-and-dom",
  "keyboard and action focus -> cocosair-input-action"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "管理音频通道、用户手势解锁、播放证据、VideoPlayer 和 WebView。用于媒体加载、播放、平台限制或资源清理。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-audio-video