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.BackendLibAVFyne) // available values: player.BackendLibVLC, player.BackendMPV, player.BackendLibAVFyne and others
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
BackendLibVLCone must build with tagwith_libvlc. - To have the support of
BackendLibAVFyneone must build with tagswith_libav,with_fyne.
An example how to run the demo:
go run -tags with_libvlc ./cmd/player/ --backend libvlc MY_MEDIA_FILE_HEREOr:
go run -tags with_libav,with_fyne ./cmd/player/ --backend libav_fyne MY_MEDIA_FILE_HERE# fyne
sudo apt install -y libgl-dev libx11-dev libxrandr-dev libxcursor-dev libxinerama-dev libxi-dev libxxf86vm-dev
# audio
sudo apt install -y libasound2-dev
# libav
sudo apt install -y libavcodec-dev libavdevice-dev
# libvlc
sudo apt install -y libvlc-dev
# mpv
sudo apt install -y mpv# fyne
sudo dnf install -y libglvnd-devel libX11-devel libXrandr-devel libXcursor-devel libXinerama-devel libXi-devel libXxf86vm-devel
# audio
sudo dnf install -y alsa-lib-devel
# libav
sudo dnf install -y libavcodec-free-devel libavdevice-free-devel libavfilter-free-devel libavformat-free-devel libavutil-free-devel
# libvlc
sudo dnf install -y vlc-devel
# mpv
sudo dnf install -y mpv