This is a package that allows to play media files/stream in Go. See demo in ./cmd/player
.
A minimal example to play a media file/stream would be:
m := player.NewManager(types.OptionPathToMPV(*mpvPath))
p, err := m.NewPlayer(ctx, "player demonstration", player.BackendBuiltinLibAV) // available values: player.BackendLibVLC, player.BackendMPV, player.BackendBuiltinLibAV
if err != nil {
return fmt.Errorf("unable to open a media player: %w", err)
}
err = p.OpenURL(ctx, mediaPath)
if err != nil {
return fmt.Errorf("unable to open the url '%s': %v", mediaPath, err)
}
- To have the support of
BackendLibVLC
one must build with tagwith_libvlc
. - To have the support of
BackendBuiltinLibAV
one must build with tagwith_libav
.
An example how to run the demo:
go run -tags with_libvlc ./cmd/player/ --backend libvlc MY_MEDIA_FILE_HERE
Or:
go run -tags with_libav ./cmd/player/ --backend builtin_libav MY_MEDIA_FILE_HERE