-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstd.go
More file actions
36 lines (32 loc) · 696 Bytes
/
std.go
File metadata and controls
36 lines (32 loc) · 696 Bytes
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
package onair
import (
"fmt"
)
// StdOut is a TrackSink that logs plays to the stdout optionally printing a
// newline when a playback stop event occurs.
type StdOut struct {
ShowAlbum bool
ShowPlaybackStop bool
}
func (me *StdOut) printTrack(t Track) {
if me.ShowAlbum {
fmt.Printf("%s - %s - %s\n", t.Artist, t.Album, t.Name)
} else {
fmt.Printf("%s - %s\n", t.Artist, t.Name)
}
}
// RegisterTrackInChan satisfies the TrackSink interface.
func (me *StdOut) RegisterTrackInChan(ts <-chan Track) {
go func() {
for t := range ts {
blank := Track{}
if t == blank {
if me.ShowPlaybackStop {
fmt.Println()
}
continue
}
me.printTrack(t)
}
}()
}