host_chrome — the embed with host chrome
A complete host application that embeds vendetta as a ui2 widget. The host owns the window, the layout and the event loop; vendetta is a guest element plus a set of methods the host calls.
Run
# from the vendetta repo root
v examples/host_chrome/main.v
The example looks for assets/video/test.mp4 next to the executable and in the
working directory, so it runs from either. The repository does not ship that
clip: put any video there first, or the example exits with a message. It queues
the clip at startup.
What to try
- Watch: the video plays on the left pane; the floating control strip appears over it and auto-hides after 2.5 s of pointer rest.
- Hover / wheel / right-click: all forwarded. The wheel steps volume while over the widget; right-click on the video pauses.
- Host sidebar (right pane): every control here is host chrome.
- Floating controls checkbox — switches vendetta between the floating strip
and a docked strip through
player.set_overlay. - Replay video / Stop — host buttons that call
player.loadandplayer.stopdirectly. - The labels mirror vendetta's playback state (position, volume, mode) and
update every frame because
view()just re-reads the player.
- Floating controls checkbox — switches vendetta between the floating strip
and a docked strip through
- q — toggles the sidebar, which resizes vendetta's frame. The widget relayouts on the next build, so nothing special is needed from the host.
The host's responsibilities
- Build: fold
player.build(frame)into your element tree. - Render: register one
ui2.set_gl_surface_rendererand route by id — vendetta only answers forlibvendetta.video_surface_id. - Input: forward
pointer_moved,mouse_button,wheelandkey. - Events: in your event callback, forward any event id starting with
vd_toplayer.handle; handle everything else yourself. - Lifecycle: call
player.destroy()after the window is closed.
Multiple players in one process are possible: each libvendetta.Player keeps
its own mpv context and surface; only the per-window input hooks are shared,
so those routes must fan out to whichever player the pointer is over.