Popularity
5.1
-
Activity
8.5
-
124
9
28

Description

Provides golang bindings for libvlc version 2.X/3.X/4.X. This is a work in progress and it is not safe for use in a production environment. The current implementation contains only a small portion of libvlc's functionality.

Full documentation can be found at: http://godoc.org/github.com/adrg/libvlc-go

Programming language: Go
Tags: Music     Audio/Music     Bindings     Video     Go     Package     Golang     Vlc     Libvlc     Player    
Latest version: v3.0.3

libvlc-go alternatives and similar packages

Based on the "Video" category

Do you think we are missing an alternative of libvlc-go or a related project?

Add another 'Video' Package

README

libvlc-go

Go bindings for libVLC version 2.X/3.X/4.X.

The package can be useful for adding multimedia capabilities to applications through the provided player interfaces. It relies on Go modules in order to mirror each supported major version of libVLC.

Documentation for v3, which implements bindings for libVLC 3.X, can be found on pkg.go.dev and on GoDoc.
Documentation for v2, which implements bindings for libVLC 2.X, can be found on pkg.go.dev and on GoDoc.

libvlc-go examples

Example applications:

  • [GUI media player](v3/examples/gtk3_player)
  • [GUI screen recorder](v3/examples/gtk3_screen_recorder)

Prerequisites

The libVLC development files are required. Instructions for installing the VLC SDK on multiple operating systems can be found on the wiki pages of this project.

Installation

In order to support multiple versions of libVLC, the package contains a Go module for each major version of the API. Choose an installation option depending on the version of libVLC you want to use.

libVLC v3.X or later

go get github.com/adrg/libvlc-go/v3

libVLC v2.X

go get github.com/adrg/libvlc-go/v2

# Build for libVLC < v2.2.0
go build -tags legacy

All versions above also work for projects which are not using Go modules. However, please consider switching to modules.

Examples

  • [GTK 3 media player](v3/examples/gtk3_player) (using gotk3)
  • [GTK 3 screen recorder](v3/examples/gtk3_screen_recorder) (using gotk3)
  • [GTK 2 media player](v3/examples/gtk_player.go) (using go-gtk)
  • [GTK 2 screen recorder](v3/examples/gtk_screen_recorder.go) (using go-gtk)
  • [Basic player usage](v3/examples/player.go)
  • [Basic list player usage](v3/examples/list_player.go)
  • [Handling events](v3/examples/event_handling.go)
  • [Retrieve media information](v3/examples/media_information.go)
  • [Display screen as player media](v3/examples/display_screen_media.go)

Examples for the older version of the API can be found in [v2/examples](v2/examples).

Usage

package main

import (
    "log"

    vlc "github.com/adrg/libvlc-go/v3"
)

func main() {
    // Initialize libVLC. Additional command line arguments can be passed in
    // to libVLC by specifying them in the Init function.
    if err := vlc.Init("--no-video", "--quiet"); err != nil {
        log.Fatal(err)
    }
    defer vlc.Release()

    // Create a new player.
    player, err := vlc.NewPlayer()
    if err != nil {
        log.Fatal(err)
    }
    defer func() {
        player.Stop()
        player.Release()
    }()

    // Add a media file from path or from URL.
    // Set player media from path:
    // media, err := player.LoadMediaFromPath("localpath/test.mp4")
    // Set player media from URL:
    media, err := player.LoadMediaFromURL("http://stream-uk1.radioparadise.com/mp3-32")
    if err != nil {
        log.Fatal(err)
    }
    defer media.Release()

    // Start playing the media.
    err = player.Play()
    if err != nil {
        log.Fatal(err)
    }

    // Retrieve player event manager.
    manager, err := player.EventManager()
    if err != nil {
        log.Fatal(err)
    }

    // Register the media end reached event with the event manager.
    quit := make(chan struct{})
    eventCallback := func(event vlc.Event, userData interface{}) {
        close(quit)
    }

    eventID, err := manager.Attach(vlc.MediaPlayerEndReached, eventCallback, nil)
    if err != nil {
        log.Fatal(err)
    }
    defer manager.Detach(eventID)

    <-quit
}

Stargazers over time

Stargazers over time

Contributing

Contributions in the form of pull requests, issues or just general feedback, are always welcome. See [CONTRIBUTING.MD](CONTRIBUTING.md).

Contributors: adrg, fenimore, tarrsalah, danielpellon, patknight, sndnvaps.

Buy me a coffee

If you found this project useful and want to support it, consider buying me a coffee.

References

For more information see the libVLC documentation.

License

Copyright (c) 2018 Adrian-George Bostan.

This project is licensed under the MIT license. See [LICENSE](LICENSE) for more details.


*Note that all licence references and agreements mentioned in the libvlc-go README section above are relevant to that project's source code only.