video

package
v0.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package video plays video files and streams with the system's own media framework, for ui.Video to show: AVFoundation on macOS, Media Foundation on Windows, GStreamer on Linux and the video element in browsers. The system decodes the video, in hardware where it can, and plays its sound in sync with the picture; its frames reach the window's renderer where the decoder left them, on the GPU, without a copy through memory where the system allows it.

//go:embed trailer.mp4
var trailer []byte

app.trailer, err = video.OpenData(trailer)
...
ui.Video(c, app.trailer).Fill().Fit(ui.Contain)

A video opens at once and loads in the background: the player is not Ready, and its Size is 0×0, until its first picture came, which builds a frame of the window that shows it, as a change of its state does. What formats play is the system's: H.264 and AAC in MP4 or MOV play on all of them; HEVC, VP9 and AV1 where the system has their decoders, and HLS streams on macOS, Windows and browsers.

Apps that do not import the package link none of it. GIFs and animated PNGs play without it, decoded in Go (ui.NewGIFDecoder, ui.NewAPNGDecoder), on every system.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("video: the system has no media framework that plays video")

ErrUnsupported reports a system without a media framework that plays video: a Linux without GStreamer 1.x and its base plugins, or an OS of none. An app may show a GIF in its place.

Functions

func Open

func Open(path string) (*ui.VideoPlayer, error)

Open opens a video file, playing once a Video shows it.

func OpenData

func OpenData(data []byte) (*ui.VideoPlayer, error)

OpenData opens a video in memory, as one embedded in the app, without writing it to a file: the system reads it from data, which must stay as it is while the player is open. It plays once a Video shows it.

func OpenURL

func OpenURL(url string) (*ui.VideoPlayer, error)

OpenURL opens a video at a URL: a file:, http: or https: URL, or an HLS playlist (.m3u8) where the system streams them. It plays once a Video shows it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL