Skip to content

Commit

Permalink
Status duration is in min:sec instead of millisec. Dropped PlayID, wh…
Browse files Browse the repository at this point in the history
…atever that was
  • Loading branch information
hilli committed Feb 10, 2024
1 parent 399e534 commit 8fa6e3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/kefw2/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ var statusCmd = &cobra.Command{
fmt.Println("Artist:", pd.TrackRoles.MediaData.MetaData.Artist)
fmt.Println("Album:", pd.TrackRoles.MediaData.MetaData.Album)
fmt.Println("Track:", pd.TrackRoles.Title)
fmt.Println("Duration:", pd.Status.Duration)
fmt.Println("PlayID:", pd.PlayID.TimeStamp)
fmt.Println("Duration:", pd.Status)
// fmt.Println("PlayID:", pd.PlayID.TimeStamp)
fmt.Println(imageArt2ASCII(pd.TrackRoles.Icon))
} else {
fmt.Println("Audio Transport: stopped")
Expand All @@ -60,8 +60,8 @@ func init() {
func imageArt2ASCII(imageURL string) string {
// Create convert options
convertOptions := convert.DefaultOptions
convertOptions.FixedWidth = 80
convertOptions.FixedHeight = 40
// convertOptions.FixedWidth = 80
// convertOptions.FixedHeight = 40

// Create the image converter
converter := convert.NewImageConverter()
Expand Down
10 changes: 10 additions & 0 deletions kefw2/player_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ func (s *KEFSpeaker) PlayerData() (PlayerData, error) {
// fmt.Printf("jsonData: %+v\n", string(playersJson))
return PlayerData{}, fmt.Errorf("error unmarshaling player data: %s", err)
}
fmt.Printf("playersData: %+v\n", playersData)
playerData := playersData[0]
return playerData, nil
}

// String returns the duration in minutes:seconds format instead of milliseconds
func (p PlayerResource) String() string {
inSeconds := p.Duration / 1000
minutes := inSeconds / 60
seconds := inSeconds % 60
str := fmt.Sprintf("%d:%d", minutes, seconds)
return str
}

0 comments on commit 8fa6e3e

Please sign in to comment.