view-demo: add video element

This commit is contained in:
nick black 2019-12-02 03:39:40 -05:00 committed by Nick Black
parent 94e52d4acc
commit 957af8151e
2 changed files with 20 additions and 0 deletions

View File

@ -640,6 +640,10 @@ API struct AVFrame* ncvisual_decode(struct ncvisual* nc, int* averr);
// to the size of the ncplane at ncplane_visual_open() time.
API int ncvisual_render(const struct ncvisual* ncv);
// stream the entirety of the media, according to its own timing.
// blocking, obviously. pretty raw; beware.
API int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv, int* averr);
// A panelreel is an notcurses region devoted to displaying zero or more
// line-oriented, contained panels between which the user may navigate. If at
// least one panel exists, there is an active panel. As much of the active

View File

@ -1,6 +1,19 @@
#include <notcurses.h>
#include "demo.h"
static int
view_video_demo(struct notcurses* nc){
struct ncplane* ncp = notcurses_stdplane(nc);
int dimy, dimx;
ncplane_dim_yx(ncp, &dimy, &dimx);
int averr;
struct ncvisual* ncv = ncplane_visual_open(ncp, "../tests/atliens.mkv", &averr);
if(ncvisual_stream(nc, ncv, &averr)){
return -1;
}
return 0;
}
int view_demo(struct notcurses* nc){
struct ncplane* ncp = notcurses_stdplane(nc);
int dimy, dimx;
@ -49,5 +62,8 @@ int view_demo(struct notcurses* nc){
return -1;
}
nanosleep(&demodelay, NULL);
if(view_video_demo(nc)){
return -1;
}
return 0;
}