2 branches
Tree Top files
Code
Clone with HTTPS:
Clone with SSH:
diviocity fix findings: frame leak, option replies, hit-tests e566477c350a80f9666b93ab0d991ad14f06df91 last Oct 31
..
README.md 2.15 KB
main.v 6.57 KB

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.load and player.stop directly.
    • The labels mirror vendetta's playback state (position, volume, mode) and update every frame because view() just re-reads the player.
  • 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

  1. Build: fold player.build(frame) into your element tree.
  2. Render: register one ui2.set_gl_surface_renderer and route by id — vendetta only answers for libvendetta.video_surface_id.
  3. Input: forward pointer_moved, mouse_button, wheel and key.
  4. Events: in your event callback, forward any event id starting with vd_ to player.handle; handle everything else yourself.
  5. 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.