@@ -143,21 +143,87 @@ The built-in 3×5 pixel font supports:
143143
144144Configuration class for media rendering with builder pattern.
145145
146- | Method | Default | Description |
147- | -------------------------- | ------------------------ | ------------------------ |
148- | ` set_type(Type) ` | ` Type::auto_detect ` | Media type hint |
149- | ` set_mode(Mode) ` | ` Mode::bw_dot ` | Rendering style |
150- | ` set_parser(Parser) ` | ` Parser::default_parser ` | Backend (FFmpeg/OpenCV) |
151- | ` set_max_width(int) ` | ` 80 ` | Terminal width |
152- | ` set_threshold(int) ` | ` 128 ` | B&W threshold (0-255) |
153- | ` set_dithering(Dithering) ` | ` Dithering::none ` | Dithering algorithm |
154- | ` set_fps(int) ` | ` 0 ` (original) | Target FPS |
155- | ` set_start_time(double) ` | ` -1.0 ` (beginning) | Video start (seconds) |
156- | ` set_end_time(double) ` | ` -1.0 ` (end) | Video end (seconds) |
157- | ` set_audio(Audio) ` | ` Audio::off ` | Audio playback |
158- | ` set_shell(Shell) ` | ` Shell::noninteractive ` | Keyboard controls |
159- | ` with_audio() ` | — | Shorthand for Audio::on |
160- | ` interactive() ` | — | Enable keyboard controls |
146+ | Method | Default | Description |
147+ | ------------------------------- | ------------------------ | ----------------------------- |
148+ | ` set_type(Type) ` | ` Type::auto_detect ` | Media type hint |
149+ | ` set_mode(Mode) ` | ` Mode::bw_dot ` | Rendering style |
150+ | ` set_parser(Parser) ` | ` Parser::default_parser ` | Backend (FFmpeg/OpenCV) |
151+ | ` set_max_width(int) ` | ` 80 ` | Terminal width |
152+ | ` set_threshold(int) ` | ` 128 ` | B&W threshold (0-255) |
153+ | ` set_dithering(Dithering) ` | ` Dithering::none ` | Dithering algorithm |
154+ | ` set_fps(int) ` | ` 0 ` (original) | Target FPS |
155+ | ` set_start_time(double) ` | ` -1.0 ` (beginning) | Video start (seconds) |
156+ | ` set_end_time(double) ` | ` -1.0 ` (end) | Video end (seconds) |
157+ | ` set_audio(Audio) ` | ` Audio::off ` | Audio playback |
158+ | ` set_shell(Shell) ` | ` Shell::noninteractive ` | Keyboard controls |
159+ | ` with_audio() ` | — | Shorthand for Audio::on |
160+ | ` interactive() ` | — | Enable keyboard controls |
161+ | ` set_volume(int) ` | ` 100 ` | Initial volume (0-100%) |
162+ | ` set_volume_step(int) ` | ` 10 ` | Volume change per key (1-100) |
163+ | ` set_seek_frames(int) ` | ` 90 ` | Frames to seek per press |
164+ | ` set_buffer_ahead_frames(int) ` | ` 60 ` | Frames to preload ahead |
165+ | ` set_buffer_behind_frames(int) ` | ` 90 ` | Frames to keep behind |
166+
167+ ---
168+
169+ ## Interactive Video Playback
170+
171+ When ` interactive() ` is enabled, video playback runs in a multithreaded mode with non-blocking keyboard controls. This works with or without audio.
172+ ** Note** Interactive mode is not supported for opencv.
173+
174+ ### Keyboard Controls
175+
176+ | Key | Action |
177+ | --------- | -------------------------------------------- |
178+ | ↑ (Up) | Increase volume (default: 10%, configurable) |
179+ | ↓ (Down) | Decrease volume (default: 10%, configurable) |
180+ | ← (Left) | Seek backward (default: 90 frames) |
181+ | → (Right) | Seek forward (default: 90 frames) |
182+ | ` p ` | Pause / Resume playback |
183+ | ` s ` | Stop playback |
184+
185+ ### On-Screen Display
186+
187+ When interactive mode is enabled, the player shows:
188+
189+ 1 . ** Progress Bar** (bottom): Shows playback position with time labels
190+ - White blocks: Played portion
191+ - Gray blocks: Remaining portion
192+ - Time format: ` MM:SS ` for start, current, and end times
193+
194+ 2 . ** Volume Bar** (right side): 10-segment bar with braille patterns
195+ - Green (⣿): Low volume (0-40%)
196+ - Yellow (⣿): Medium volume (41-70%)
197+ - Red (⣿): High volume (71-100%)
198+ - Gray (⣀): Empty segments
199+ - Smooth gradient with partial braille characters
200+
201+ ### Frame Buffering
202+
203+ The player uses a frame buffer for smooth seeking:
204+
205+ - ** buffer_ahead_frames** : Preloaded frames for smooth playback (default: 60)
206+ - ** buffer_behind_frames** : Cached frames for backward seeking (default: 90)
207+
208+ ### Example
209+
210+ ``` cpp
211+ // Full-featured interactive video playback
212+ print (Media, "movie.mp4", RenderConfig()
213+ .set_mode(Mode::colored_dot)
214+ .with_audio()
215+ .interactive()
216+ .set_volume(80) // Start at 80% volume
217+ .set_volume_step(5) // 5% volume change per keypress
218+ .set_seek_frames(120) // Seek 4 seconds per keypress (at 30fps)
219+ .set_buffer_ahead_frames(90)
220+ .set_buffer_behind_frames(120));
221+
222+ // Interactive without audio (controls still work)
223+ print(Media, "video.mp4", RenderConfig()
224+ .set_mode(Mode::colored)
225+ .interactive()); // Volume bar hidden when no audio
226+ ```
161227
162228---
163229
@@ -243,18 +309,31 @@ print(Media, "video.mp4");
243309// Video with audio
244310print(Media, "video.mp4", RenderConfig().with_audio());
245311
246- // Interactive with controls
312+ // Interactive with keyboard controls (see Interactive Video Playback section)
247313print(Media, "movie.mp4", RenderConfig()
248314 .set_mode(Mode::colored)
249315 .with_audio()
250- .interactive()
251- .set_pause_key('p')
252- .set_stop_key('s'));
316+ .interactive());
317+
318+ // Interactive without audio (volume controls hidden)
319+ print(Media, "video.mp4", RenderConfig()
320+ .set_mode(Mode::colored_dot)
321+ .interactive());
253322
254323// Play video segment (1:00 to 2:00)
255324print(Media, "movie.mp4", RenderConfig()
256325 .set_start_time(60)
257326 .set_end_time(120));
327+
328+ // Full interactive setup with custom controls
329+ print(Media, "movie.mp4", RenderConfig()
330+ .set_mode(Mode::colored_dot)
331+ .with_audio()
332+ .interactive()
333+ .set_volume(70) // 70% initial volume
334+ .set_seek_frames(60) // Seek 2 seconds at 30fps
335+ .set_pause_key('p')
336+ .set_stop_key('s'));
258337```
259338
260339### Webcam Capture
0 commit comments