forked from 3mdeb/omxplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_helpers.go
62 lines (55 loc) · 1.89 KB
/
player_helpers.go
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
59
60
61
62
package omxplayer
import (
dbus "github.com/guelfey/go.dbus"
log "github.com/sirupsen/logrus"
)
// dbusCall calls a D-Bus method that has no return value.
func dbusCall(bus *dbus.Object, path string) error {
log.WithFields(log.Fields{"path": path}).Debug("omxplayer: dbus call")
return bus.Call(path, 0).Err
}
// dbusGetBool calls a D-Bus method that will return a boolean value.
func dbusGetBool(bus *dbus.Object, path string) (bool, error) {
log.WithFields(log.Fields{"path": path}).Debug("omxplayer: dbus call")
call := bus.Call(path, 0)
if call.Err != nil {
return false, call.Err
}
return call.Body[0].(bool), nil
}
// dbusGetFloat64 calls a D-Bus method that will return an int64 value.
func dbusGetFloat64(bus *dbus.Object, path string) (float64, error) {
log.WithFields(log.Fields{"path": path}).Debug("omxplayer: dbus call")
call := bus.Call(path, 0)
if call.Err != nil {
return 0, call.Err
}
return call.Body[0].(float64), nil
}
// dbusGetInt64 calls a D-Bus method that will return an int64 value.
func dbusGetInt64(bus *dbus.Object, path string) (int64, error) {
log.WithFields(log.Fields{"path": path}).Debug("omxplayer: dbus call")
call := bus.Call(path, 0)
if call.Err != nil {
return 0, call.Err
}
return call.Body[0].(int64), nil
}
// dbusGetString calls a D-Bus method that will return a string value.
func dbusGetString(bus *dbus.Object, path string) (string, error) {
log.WithFields(log.Fields{"path": path}).Debug("omxplayer: dbus call")
call := bus.Call(path, 0)
if call.Err != nil {
return "", call.Err
}
return call.Body[0].(string), nil
}
// dbusGetStringArray calls a D-Bus method that will return a string array.
func dbusGetStringArray(bus *dbus.Object, path string) ([]string, error) {
log.WithFields(log.Fields{"path": path}).Debug("omxplayer: dbus call")
call := bus.Call(path, 0)
if call.Err != nil {
return nil, call.Err
}
return call.Body[0].([]string), nil
}