-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.c
38 lines (31 loc) · 1.19 KB
/
demo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// video player
// - rlyeh, public domain
#include "engine.h"
int main() {
// 75% window, msaa x2
app_create( 75, APP_MSAA2 );
// load video
int do_rgb = flag("--rgb") ? 1 : 0;
video_t *v = video( "pexels-pachon-in-motion-17486489.mp4", VIDEO_LOOP | (do_rgb ? VIDEO_RGB : VIDEO_YCBCR) );
while( app_swap() && !input(KEY_ESC) ) {
// decode video frame and get associated textures (audio is automatically sent to audiomixer)
texture_t *textures = video_decode( v );
// present decoded textures as a fullscreen composed quad
blit(textures, 0, do_rgb ? BLIT_RGB : BLIT_YCBCR);
// ui video
if( ui_panel("Video", 0) ) {
if( ui_button("Rewind") ) video_seek(v, video_position(v) - 3);
if( ui_button("Pause") ) video_pause(v, video_is_paused(v) ^ 1);
if( ui_button("Forward") ) video_seek(v, video_position(v) + 3);
ui_panel_end();
}
#if HAS_AUDIO
// audio
if( ui_panel("Audio", 0)) {
static float master = 1;
if( ui_slider2("Master", &master, va("%.2f", master))) audio_volume_master(master);
ui_panel_end();
}
#endif
}
}