vendetta / examples / host_chrome / README.md
47 lines · 38 sloc · 2.15 KB · e566477c350a80f9666b93ab0d991ad14f06df91
Raw

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

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.