Video
Install libmpv 0.37 or later, then run:
go run ./examples/video -danmaku /path/to/video.mp4
go run ./examples/video 'https://example.org/stream.m3u8'
The window accepts a local path or URL and has a file picker, pause control,
position readout and danmaku toggle. The overlay reuses outlined text sprites
at the window's physical scale.
Create the player with video.Options{Video: true}. Use
ui.Video(c, player, layout.Grow(1)).Radius(c.Theme.RadiusLG).Body(fn)
to place custom controls and overlays over it. Call player.Close() when
its window closes. A player belongs to one video view. On Windows and
Linux, an initial Open can be queued while the GPU surface starts.
Check video.Event errors from OnEvent and rendering failures from
player.VideoError().
The time readout follows video.Progress. Ordinary progress updates are
coalesced at a 250 ms interval by default. Use video.Changed for playback
state such as pause and dimensions. ui.Video schedules picture updates
independently of either event.
macOS uses Metal to sample the IOSurface produced by libmpv's CGL context.
The default window switches to Metal when it first receives a video frame.
Linux uses GtkGLArea OpenGL. With a software GL driver, run the example
with TANGO_RENDERER=gpu to enable Tango's OpenGL window.
Windows tries native D3D11 first and falls back to software rendering
and BGRA upload when needed. -software selects the software path explicitly.
Pass -libmpv to load a library from another location. The Windows loader
checks alongside the executable and the macOS loader checks the app bundle
and Homebrew. Linux uses the system's libmpv.so.2.
Use -diagnostics to print playback and submission counters. A submission
counts a new video generation sent through the UI presentation path.