Skip to content

Commit

Permalink
Pass start timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
altfoxie committed Jul 11, 2022
1 parent 8024864 commit 76d8edc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const AppID = "991335093878673448"
//go:embed assets/tray.png
var icon []byte

var firstSecond = time.Unix(1, 0)

func main() {
systray.Run(onReady, nil)
}
Expand Down Expand Up @@ -73,6 +75,10 @@ func onReady() {
activity := drpc.Activity{
Details: result.name,
State: result.artist,
Timestamps: &drpc.Timestamps{
Start: time.Now().Add(-time.Duration(result.position) * time.Second),
End: firstSecond,
},
Assets: &drpc.Assets{
LargeImage: "music",
SmallImage: "pause",
Expand All @@ -89,9 +95,9 @@ func onReady() {
if result.state == StatePlaying {
activity.Assets.SmallImage = "play"
activity.Timestamps = &drpc.Timestamps{
Start: time.Now().Add(-time.Duration(result.position) * time.Second),
End: time.Now().
Add(time.Duration(result.duration * float64(time.Second))).
Add(-time.Duration(result.position * float64(time.Second))),
Add(time.Duration((result.duration - result.position) * float64(time.Second))),
}
}

Expand Down

0 comments on commit 76d8edc

Please sign in to comment.