From 957af8151ec4ce1732f5f03acb41d41b9ff5ad71 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 2 Dec 2019 03:39:40 -0500 Subject: [PATCH] view-demo: add video element --- include/notcurses.h | 4 ++++ src/demo/view.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/notcurses.h b/include/notcurses.h index 93a885be6..9a39a9c7b 100644 --- a/include/notcurses.h +++ b/include/notcurses.h @@ -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 diff --git a/src/demo/view.c b/src/demo/view.c index 179e52ce7..1850b4ce0 100644 --- a/src/demo/view.c +++ b/src/demo/view.c @@ -1,6 +1,19 @@ #include #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; }