https://github.com/xaionaro-go/player
A media (audio/video) player for Go. Few choices of the backend: libvlc, mpv, libav
https://github.com/xaionaro-go/player
audio av go golang libav libvlc media mpv player video vlc
Last synced: 13 days ago
JSON representation
A media (audio/video) player for Go. Few choices of the backend: libvlc, mpv, libav
- Host: GitHub
- URL: https://github.com/xaionaro-go/player
- Owner: xaionaro-go
- License: cc0-1.0
- Created: 2025-01-11T15:39:09.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-11-27T20:49:36.000Z (about 1 month ago)
- Last Synced: 2025-11-30T10:52:22.386Z (about 1 month ago)
- Topics: audio, av, go, golang, libav, libvlc, media, mpv, player, video, vlc
- Language: Go
- Homepage:
- Size: 2.13 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `player`
[](http://creativecommons.org/publicdomain/zero/1.0/)
This is a package that allows to play media files/stream in Go. See demo in [`./cmd/player`](./cmd/player/).
A minimal example to play a media file/stream would be:
```go
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 `BackendLibVLC` one must build with tag `with_libvlc`.
* To have the support of `BackendLibAVFyne` one must build with tags `with_libav,with_fyne`.
An example how to run the demo:
```sh
go run -tags with_libvlc ./cmd/player/ --backend libvlc MY_MEDIA_FILE_HERE
```
Or:
```sh
go run -tags with_libav,with_fyne ./cmd/player/ --backend libav_fyne MY_MEDIA_FILE_HERE
```
Expected result:

# Installing dependencies
## Ubuntu
```sh
# 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
```
## Fedora
```sh
# 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
```