Skip to content

Commit dff1ba2

Browse files
committed
update readme and various bug fixes
1 parent 5cbb1df commit dff1ba2

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,96 @@ Supported Media formats:
1717

1818
If an unknown file is found, it will use `ffmpeg` to transcode it to MP4, and stream it to the chromecast.
1919

20+
## Play Local Media Files
21+
22+
We are able to play local media files by creating a http server that will stream the media file to the cast device.
23+
2024
## Cast DNS Lookup
2125

2226
A DNS multicast is used to determine the Chromecast and Google Home devices.
2327

2428
The cast DNS entry is also cached, this means that if you pass through the device name, `-n <name>`, or the
2529
device uuid, `-u <uuid>`, the results will be cached and it will connect to the chromecast device instanly.
2630

31+
## Usage
32+
```
33+
# View available cast devices.
34+
$ go-chromecast ls
35+
Found 2 cast devices
36+
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
37+
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
38+
39+
# Status of a cast device.
40+
go-chromecast status
41+
Found 2 cast dns entries, select one:
42+
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
43+
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
44+
Enter selection: 1
45+
Idle (Backdrop), volume=1.00 muted=false
46+
47+
# Specify a cast device name.
48+
$ go-chromecast status -n "Living Room Speaker"
49+
Idle, volume=0.17 muted=false
50+
51+
# Specify a cast device uuid.
52+
$ go-chromecast status -u b87d86bed423a6feb8b91a7d2778b55c
53+
Idle (Default Media Receiver), volume=0.17 muted=false
54+
55+
# Load a local media file (can play both audio and video).
56+
$ go-chromecast load ~/Downloads/SampleAudio_0.4mb.mp3
57+
Found 2 cast dns entries, select one:
58+
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
59+
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
60+
Enter selection: 2
61+
62+
# Status of cast device running an audio file.
63+
$ go-chromecast status
64+
Found 2 cast dns entries, select one:
65+
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
66+
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="Default Media Receiver" uuid="b87d86bed423a6feb8b91a7d2778b55c"
67+
Enter selection: 2
68+
Default Media Receiver (PLAYING), unknown, time remaining=8s/28s, volume=1.00, muted=false
69+
70+
# Play a playlist of media files.
71+
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker"
72+
Attemping to play the following media:
73+
- /home/jonathan/playlist_test/SampleAudio_0.4mb.mp3
74+
- /home/jonathan/playlist_test/sample_1.mp3
75+
76+
# Select where to start a playlist from.
77+
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker" --select
78+
Will play the following items, select where to start from:
79+
1) /home/jonathan/playlist_test/SampleAudio_0.4mb.mp3: last played "2018-11-25 11:17:25 +0000 GMT"
80+
2) /home/jonathan/playlist_test/sample_1.mp3: last played "2018-11-25 11:17:28 +0000 GMT"
81+
Enter selection: 2
82+
Attemping to play the following media:
83+
- /home/jonathan/playlist_test/sample_1.mp3
84+
85+
# Start a playlist from the start, ignoring if you have previously played that playlist.
86+
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker" --continue=false
87+
88+
# Pause the playing media.
89+
$ go-chromecast pause
90+
91+
# Continue playing the currently playing media.
92+
$ go-chromecast play
93+
94+
# Play the next item in a playlist.
95+
$ go-chromecast next
96+
97+
# Play the previous item in a playlist.
98+
$ go-chromecast previous
99+
100+
# Rewind the currently playing media by x seconds.
101+
$ go-chromecast rewind 30
102+
103+
# Go forward in the currently playing media by x seconds.
104+
$ go-chromecast seek 30
105+
106+
# View what a cast device is sending out.
107+
$ go-chromecast watch
108+
```
109+
27110
## Playlist
28111

29112
There is support for playing media items as a playlist.

application/application.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ func (a *Application) recvMessages() {
121121
// is an item being loaded to play next.
122122
if status.IdleReason == "FINISHED" && status.LoadingItemId == 0 {
123123
a.mediaFinished <- true
124+
} else if status.IdleReason == "INTERRUPTED" && status.Media.ContentId == "" {
125+
// This can happen when we go "next" in a playlist when it
126+
// is playing the last track.
127+
a.mediaFinished <- true
124128
}
125129
}
126130
}

cmd/playlist.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ that ffmpeg is installed.`,
192192
indexToPlayFrom = lastPlayedIndex
193193
}
194194

195+
fmt.Println("Attemping to play the following media:")
196+
for _, f := range filenames[indexToPlayFrom:] {
197+
fmt.Printf("- %s\n", f)
198+
}
199+
195200
if err := app.QueueLoad(filenames[indexToPlayFrom:], contentType, transcode); err != nil {
196201
fmt.Printf("unable to play playlist on cast application: %v\n", err)
197202
return nil

cmd/status.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ var statusCmd = &cobra.Command{
3434
fmt.Printf("Idle, volume=%0.2f muted=%t\n", castVolume.Level, castVolume.Muted)
3535
} else if castApplication.IsIdleScreen {
3636
fmt.Printf("Idle (%s), volume=%0.2f muted=%t\n", castApplication.DisplayName, castVolume.Level, castVolume.Muted)
37+
} else if castMedia == nil {
38+
fmt.Printf("Idle (%s), volume=%0.2f muted=%t\n", castApplication.DisplayName, castVolume.Level, castVolume.Muted)
3739
} else {
3840
metadata := "unknown"
3941
if castMedia.Media.Metadata.Title != "" {

0 commit comments

Comments
 (0)