|
2 | 2 |
|
3 | 3 | An advanced animation builder for orchestrating scenes, keyframes, and media playback. |
4 | 4 |
|
5 | | -- `NewCinemaBuilder(sel)` creates a builder rooted at a DOM element. |
6 | | -- `AddScene(sel, opts)` sets up a new scene with keyframes and timing. |
7 | | -- `AddKeyFrame(frame, offset)` appends a keyframe to the current scene using a `KeyFrameMap`. |
8 | | -- `AddKeyFrameMap(frame, offset)` appends a raw map for advanced cases. |
9 | | -- `NewKeyFrame()` creates an empty `KeyFrameMap` with chainable `Add` and `Delete` helpers. |
10 | | -- `AddTransition(props, duration)` generates keyframes for property transitions. |
11 | | -- `AddSequence(fn)` runs a sequence of builder operations. |
12 | | -- `AddParallel(fn)` executes builder operations in a goroutine. |
13 | | -- `AddPause(d)` inserts pauses between steps. |
14 | | -- `AddLoop(count)` repeats the whole script. |
15 | | -- `AddVideo(sel)` binds a video element for playback control. |
16 | | -- `PlayVideo()` starts the bound video. |
17 | | -- `PauseVideo()` pauses the video. |
18 | | -- `StopVideo()` stops and rewinds the video. |
19 | | -- `SeekVideo(t)` jumps to a timestamp. |
20 | | -- `SetPlaybackRate(rate)` adjusts video speed. |
21 | | -- `SetVolume(v)` updates volume. |
22 | | -- `MuteVideo()` silences the audio. |
23 | | -- `UnmuteVideo()` restores audio. |
24 | | -- `AddSubtitle(kind, label, srcLang, src)` appends a subtitle track. |
25 | | -- `AddAudio(src)` injects an audio element. |
26 | | -- `PlayAudio()` starts the bound audio from the beginning. |
27 | | -- `PauseAudio()` pauses the audio. |
28 | | -- `StopAudio()` pauses and rewinds the audio. |
29 | | -- `SetAudioVolume(v)` updates audio volume. |
30 | | -- `MuteAudio()` silences the audio. |
31 | | -- `UnmuteAudio()` restores audio. |
32 | | -- `AddScripted(fn)` runs custom scripts. |
33 | | -- `OnStart(fn)` and `OnEnd(fn)` register lifecycle callbacks. |
34 | | - |
35 | | -## Usage |
36 | | - |
37 | | -Build sequences with keyframes and media controls for rich presentations. |
38 | | - |
39 | | -@include:ExampleFrame:{code:"/examples/components/cinema_component.go", uri:"/examples/cinema"} |
40 | | - |
41 | | -## Audio playback |
42 | | - |
43 | | -### Why |
44 | | -Supplement animations with sound effects or music cues. |
45 | | - |
46 | | -### When |
47 | | -Use for lightweight audio playback without building a full Web Audio graph. |
48 | | - |
49 | | -### How |
50 | | -1. Call `AddAudio(src)` to attach an audio element. |
51 | | -2. Trigger `PlayAudio()` when a sound should play. |
52 | | -3. Adjust output via `SetAudioVolume`, `MuteAudio` or `UnmuteAudio`. |
53 | | - |
54 | | -### Example: RTS unit selection |
55 | | - |
56 | | -```go |
57 | | -cinema := animation.NewCinemaBuilder("#root").AddAudio("/sounds/select.mp3") |
58 | | -dom.RegisterHandlerFunc("selectUnit", func() { |
59 | | - cinema.PlayAudio() |
60 | | -}) |
61 | | -``` |
62 | | - |
63 | | -### Limitations |
64 | | -- only a single audio element is tracked; call `AddAudio` with a new source for different sounds |
65 | | - |
66 | | -### Related |
67 | | -[animation](animation), [dom](dom) |
| 5 | +| Function | Description | |
| 6 | +| --- | --- | |
| 7 | +| `NewCinemaBuilder(sel)` | Create a builder rooted at a DOM element. | |
| 8 | +| `AddScene(sel, opts)` | Set up a new scene with keyframes and timing. | |
| 9 | +| `AddKeyFrame(frame, offset)` | Append a keyframe to the current scene using a `KeyFrameMap`. | |
| 10 | +| `AddKeyFrameMap(frame, offset)` | Append a raw map for advanced cases. | |
| 11 | +| `NewKeyFrame()` | Create an empty `KeyFrameMap` with chainable `Add` and `Delete` helpers. | |
| 12 | +| `AddTransition(props, duration)` | Generate keyframes for property transitions. | |
| 13 | +| `AddSequence(fn)` | Run a sequence of builder operations. | |
| 14 | +| `AddParallel(fn)` | Execute builder operations in a goroutine. | |
| 15 | +| `AddPause(d)` | Insert pauses between steps. | |
| 16 | +| `AddLoop(count)` | Repeat the whole script. | |
| 17 | +| `AddVideo(sel)` | Bind a video element for playback control. | |
| 18 | +| `PlayVideo()` | Start the bound video. | |
| 19 | +| `PauseVideo()` | Pause the video. | |
| 20 | +| `StopVideo()` | Stop and rewind the video. | |
| 21 | +| `SeekVideo(t)` | Jump to a timestamp. | |
| 22 | +| `SetPlaybackRate(rate)` | Adjust video speed. | |
| 23 | +| `SetVolume(v)` | Update volume. | |
| 24 | +| `MuteVideo()` | Silence the audio. | |
| 25 | +| `UnmuteVideo()` | Restore audio. | |
| 26 | +| `AddSubtitle(kind, label, srcLang, src)` | Append a subtitle track. | |
| 27 | +| `AddAudio(src)` | Inject an audio element. | |
| 28 | +| `PlayAudio()` | Start the bound audio from the beginning. | |
| 29 | +| `PauseAudio()` | Pause the audio. | |
| 30 | +| `StopAudio()` | Pause and rewind the audio. | |
| 31 | +| `SetAudioVolume(v)` | Update audio volume. | |
| 32 | +| `MuteAudio()` | Silence the audio. | |
| 33 | +| `UnmuteAudio()` | Restore audio. | |
| 34 | +| `AddScripted(fn)` | Run custom scripts. | |
| 35 | +| `OnStart(fn)` | Register a start callback. | |
| 36 | +| `OnEnd(fn)` | Register an end callback. | |
68 | 37 |
|
0 commit comments