File: README.md

package info (click to toggle)
golang-github-pauloo27-go-mpris 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 108 kB
  • sloc: makefile: 4
file content (58 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# GO-MPRIS

A Go library for MPRIS.

## Install

> $ go get github.com/Pauloo27/go-mpris

_the dependency github.com/godbus/dbus/v5 is going to be installed as well._


## Example
Printing the current playback status and then changing it:
```go
import (
	"log"

	"github.com/Pauloo27/go-mpris"
	"github.com/godbus/dbus/v5"
)

func main() {
	conn, err := dbus.SessionBus()
	if err != nil {
		panic(err)
	}
	names, err := mpris.List(conn)
	if err != nil {
		panic(err)
	}
	if len(names) == 0 {
		log.Fatal("No player found")
	}

	name := names[0]
	player := mpris.New(conn, name)

	status, err := player.GetPlaybackStatus()
	if err != nil {
		log.Fatal("Could not get current playback status")
	}

	log.Printf("The player was %s...", status)
	err = player.PlayPause()
	if err != nil {
		log.Fatal("Could not play/pause player")
	}
}
```

**For more examples, see the [examples folder](./examples).**

## Go Docs
Read the docs at https://pkg.go.dev/github.com/Pauloo27/go-mpris.

## Credits
[emersion](https://github.com/emersion/go-mpris) for the original code.