feat: make everything threads-safe.
feat: complete `uninstall.sh` logic to make everything synced. feat: complete basic play logic to handle background, music, lyric play.
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
#include <string>
|
||||
#include <atomic>
|
||||
|
||||
#include "timeline.h"
|
||||
|
||||
namespace bd {
|
||||
|
||||
struct TermSize {
|
||||
@@ -62,15 +64,21 @@ struct PlayVideoOptions {
|
||||
bool loop = false; // repeat the video until stop
|
||||
float intensity = 1.0f; // brightness multiplier for fg/bg
|
||||
bool tryResize = true; // false => force the "not adjustable" fit path
|
||||
int bottomRows = 0; // leave this many rows at the bottom for other content
|
||||
int topRows = 0; // reserve this many rows ABOVE the video (e.g. lyrics)
|
||||
int bottomRows = 0; // reserve this many rows BELOW the video
|
||||
GridSize* outGrid = nullptr; // receives the computed video grid (optional)
|
||||
int* outOffsetX = nullptr; // receives the video's horizontal offset in cols
|
||||
std::atomic<bool>* gridReady = nullptr; // set true once the layout is reported
|
||||
std::atomic<bool>* stop = nullptr; // set to true to end playback early
|
||||
};
|
||||
|
||||
// Play `path` as ASCII art. Blocks until the video ends (or `stop` is set).
|
||||
// Play `path` as ASCII art, paced by `timeline` (may be null for an
|
||||
// independent local clock). Blocks until the video ends (or `stop` is set).
|
||||
// Returns:
|
||||
// 0 playback finished (or stopped) cleanly
|
||||
// 1 failed to open/decode the video
|
||||
// 2 stdout is not a tty (nothing was written)
|
||||
int playVideo(const std::string& path, const PlayVideoOptions& opts = {});
|
||||
int playVideo(const std::string& path, Timeline* timeline,
|
||||
const PlayVideoOptions& opts = {});
|
||||
|
||||
} // namespace bd
|
||||
|
||||
Reference in New Issue
Block a user