MCPcopy Create free account
hub / github.com/efogdev/mpris-timer / Start

Method Start

internal/core/core.go:79–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77}
78
79func (p *TimerPlayer) Start() error {
80 id := strconv.Itoa(int(time.Now().UnixMicro()))[8:]
81 conn, err := dbus.SessionBus()
82 if err != nil {
83 return fmt.Errorf("connect to session bus: %w", err)
84 }
85
86 p.conn = conn
87 p.serviceName = fmt.Sprintf("org.mpris.MediaPlayer2.%s.run-%s", AppId, id)
88
89 reply, err := conn.RequestName(p.serviceName, dbus.NameFlagAllowReplacement)
90 if err != nil || reply != dbus.RequestNameReplyPrimaryOwner {
91 return fmt.Errorf("request bus: %v", err)
92 }
93
94 if err = p.exportInterfaces(); err != nil {
95 return fmt.Errorf("export interfaces: %w", err)
96 }
97
98 p.startTime = time.Now()
99 go p.runTicker()
100 go p.emitLoop()
101
102 return nil
103}
104
105func (p *TimerPlayer) Destroy() {
106 defer func() { _ = p.conn.Close() }()

Callers 1

mainFunction · 0.95

Calls 3

exportInterfacesMethod · 0.95
runTickerMethod · 0.95
emitLoopMethod · 0.95

Tested by

no test coverage detected