Menerapkan sejumlah kecil perintah google chromecast. Selain perintah dasar, ini juga memungkinkan Anda memutar file media dari komputer Anda baik secara individual atau dalam daftar putar; perintah playlist
akan melihat semua file dalam folder dan memutarnya diurutkan berdasarkan numerik. Ini juga memungkinkan Anda memutar tayangan slide gambar dengan perintah slideshow
.
Dapat memuat file media lokal atau file yang dihosting di internet di chromecast Anda dengan format berikut:
Supported Media formats:
- MP3
- AVI
- MKV
- MP4
- WebM
- FLAC
- WAV
Jika file video yang tidak dikenal ditemukan, ffmpeg
akan digunakan untuk mentranskodenya ke MP4 dan mengalirkannya ke chromecast.
Kami dapat memutar file media lokal dengan membuat server http yang akan mengalirkan file media ke perangkat transmisi.
Multicast DNS digunakan untuk menentukan perangkat Chromecast dan Google Home.
Entri DNS cast juga di-cache, ini berarti jika Anda memasukkan nama perangkat, -n <name>
, atau uuid perangkat -u <uuid>
, hasilnya akan di-cache dan akan terhubung ke perangkat chromecast secara instan .
https://github.com/vishen/go-chromecast/releases
tar -xzf go-chromecast.tar.gz
, dan instal menggunakan sudo install ./go-chromecast /usr/bin/
$ go install github.com/vishen/go-chromecast@latest
$ go get -u github.com/vishen/go-chromecast
Control your Google Chromecast or Google Home Mini from the
command line.
Usage:
go-chromecast [flags]
go-chromecast [command]
Available Commands:
help Help about any command
httpserver Start the HTTP server
load Load and play media on the chromecast
load-app Load and play content on a chromecast app
ls List devices
mute Mute the chromecast
next Play the next available media
pause Pause the currently playing media on the chromecast
playlist Load and play media on the chromecast
previous Play the previous available media
restart Restart the currently playing media
rewind Rewind by seconds the currently playing media
seek Seek by seconds into the currently playing media
seek-to Seek to the <timestamp_in_seconds> in the currently playing media
slideshow Play a slideshow of photos
status Current chromecast status
stop Stop casting
transcode Transcode and play media on the chromecast
tts text-to-speech
ui Run the UI
unmute Unmute the chromecast
unpause Unpause the currently playing media on the chromecast
volume Get or set volume
watch Watch all events sent from a chromecast device
Flags:
-a, --addr string Address of the chromecast device
-v, --debug debug logging
-d, --device string chromecast device, ie: 'Chromecast' or 'Google Home Mini'
-n, --device-name string chromecast device name
--disable-cache disable the cache
--dns-timeout int Multicast DNS timeout in seconds when searching for chromecast DNS entries (default 3)
--first Use first cast device found
-h, --help help for go-chromecast
-i, --iface string Network interface to use when looking for a local address to use for the http server or for use with multicast dns discovery
-p, --port string Port of the chromecast device if 'addr' is specified (default "8009")
-u, --uuid string chromecast device uuid
--verbose verbose logging
--version display command version
--with-ui run with a UI
Use "go-chromecast [command] --help" for more information about a command.
# View available cast devices.
$ go-chromecast ls
Found 2 cast devices
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
# Status of a cast device.
$ go-chromecast status
Found 2 cast dns entries, select one:
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
Enter selection: 1
Idle (Backdrop), volume=1.00 muted=false
# Specify a cast device name.
$ go-chromecast status -n "Living Room Speaker"
Idle, volume=0.17 muted=false
# Specify a cast device by ip address.
$ go-chromecast status -a 192.168.0.52
Idle, volume=0.17 muted=false
# Specify a cast device uuid.
$ go-chromecast status -u b87d86bed423a6feb8b91a7d2778b55c
Idle (Default Media Receiver), volume=0.17 muted=false
# Play a file hosted on the internet
$ go-chromecast load https://example.com/path/to/media.mp4
# Load a local media file (can play both audio and video).
$ go-chromecast load ~/Downloads/SampleAudio_0.4mb.mp3
Found 2 cast dns entries, select one:
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="" uuid="b87d86bed423a6feb8b91a7d2778b55c"
Enter selection: 2
# Status of cast device running an audio file.
$ go-chromecast status
Found 2 cast dns entries, select one:
1) device="Chromecast" device_name="MarieGotGame?" address="192.168.0.115:8009" status="" uuid="b380c5847b3182e4fb2eb0d0e270bf16"
2) device="Google Home Mini" device_name="Living Room Speaker" address="192.168.0.52:8009" status="Default Media Receiver" uuid="b87d86bed423a6feb8b91a7d2778b55c"
Enter selection: 2
Default Media Receiver (PLAYING), unknown, time remaining=8s/28s, volume=1.00, muted=false
# Play a playlist of media files.
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker"
Attemping to play the following media:
- /home/jonathan/playlist_test/SampleAudio_0.4mb.mp3
- /home/jonathan/playlist_test/sample_1.mp3
# Select where to start a playlist from.
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker" --select
Will play the following items, select where to start from:
1) /home/jonathan/playlist_test/SampleAudio_0.4mb.mp3: last played "2018-11-25 11:17:25 +0000 GMT"
2) /home/jonathan/playlist_test/sample_1.mp3: last played "2018-11-25 11:17:28 +0000 GMT"
Enter selection: 2
Attemping to play the following media:
- /home/jonathan/playlist_test/sample_1.mp3
# Start a playlist from the start, ignoring if you have previously played that playlist.
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker" --continue=false
# Start a playlist and launch the terminal ui
$ go-chromecast playlist ~/playlist_test/ -n "Living Room Speaker" --with-ui
# Start a slideshow of images
$ go-chromecast slideshow slideshow_images/*.png --repeat=false
# Pause the playing media.
$ go-chromecast pause
# Continue playing the currently playing media.
$ go-chromecast play
# Play the next item in a playlist.
$ go-chromecast next
# Play the previous item in a playlist.
$ go-chromecast previous
# Rewind the currently playing media by x seconds.
$ go-chromecast rewind 30
# Go forward in the currently playing media by x seconds.
$ go-chromecast seek 30
# Get the current volume level
$ go-chromecast volume
# Set the volume level
$ go-chromecast volume 0.55
# View what messages a cast device is sending out.
$ go-chromecast watch
# Use a terminal UI to interact with the cast device
$ go-chromecast ui
Antarmuka pengguna terminal dasar disediakan, yang mendukung kontrol berikut:
Ini dapat dijalankan dengan cara berikut:
Jika Anda hanya ingin mengontrol chromecast yang sudah memutar sesuatu dari jarak jauh:
$ go-chromecast ui
Gunakan UI yang dikombinasikan dengan perintah playlist
(dirinci di atas):
$ go-chromecast --with-ui playlist /path/to/directory
Gunakan UI yang dikombinasikan dengan perintah load
(dirinci di atas):
$ go-chromecast --with-ui load /path/to/file.flac
Ada server HTTP API yang disediakan yang memiliki api berikut:
GET /devices?interface=<network_interface>&wait=<seconds>
POST /connect?uuid=<device_uuid>&addr=<device_addr>&port=<device_port>&interface=<network_interface>&wait=<seconds>
POST /disconnect?uuid=<device_uuid>&stop=<bool>
POST /disconnect-all?stop=<bool>
POST /status?uuid=<device_uuid>
POST /pause?uuid=<device_uuid>
POST /unpause?uuid=<device_uuid>
POST /mute?uuid=<device_uuid>
POST /unmute?uuid=<device_uuid>
POST /stop?uuid=<device_uuid>
GET /volume?uuid=<device_uuid>
POST /volume?uuid=<device_uuid>&volume=<float>
POST /rewind?uuid=<device_uuid>&seconds=<int>
POST /seek?uuid=<device_uuid>&seconds=<int>
POST /seek-to?uuid=<device_uuid>&seconds=<float>
POST /load?uuid=<device_uuid>&path=<filepath_or_url>&content_type=<string>
$ go-chromecast httpserver
Start the HTTP server which provides an HTTP
api to control chromecast devices on a network.
Usage:
go-chromecast httpserver [flags]
Flags:
-h, --help help for httpserver
--http-addr string addr for the http server to listen on (default "0.0.0.0")
--http-port string port for the http server to listen on (default "8011")
Ada dukungan untuk memutar item media sebagai playlist.
Jika memutar dari daftar putar, Anda dapat melewati tanda --select
, dan ini memungkinkan Anda memilih media untuk mulai memutar. Ini berguna jika Anda sudah memainkan beberapa media dan ingin memulai dari media yang belum Anda mainkan.
Cache disimpan untuk media yang diputar, jadi jika Anda memutar media dari daftar putar, cache akan memeriksa file media apa yang baru-baru ini Anda putar dan memutar yang berikutnya dari daftar putar. --continue=false
dapat dilewati dan ini akan memulai playlist dari awal.
Jika Anda ingin melihat apa yang dikirimkan perangkat, Anda dapat watch
pesan protobuf yang dikirim dari perangkat Anda:
$ go-chromecast watch
Dukungan eksperimental text-to-speech telah ditambahkan. Ini menggunakan Text-to-Speech Google Cloud untuk mengubah teks menjadi file audio mp3, yang kemudian dialirkan ke perangkat.
Api text-to-speech harus diaktifkan https://console.cloud.google.com/flows/enableapi?apiid=texttospeech.googleapis.com dan akun layanan google diperlukan https://console.cloud.google. com/apis/credentials/serviceaccountkey
$ go-chromecast tts <message_to_say> --google-service-account=/path/to/service/account.json
Untuk bahasa non-en-AS
$ go-chromecast tts <message_to_say> --google-service-account=/path/to/service/account.json
--voice-name en-US-Wavenet-G --speaking-rate 1.05 --pitch 0.9
Daftar suara yang tersedia (nama suara) dapat ditemukan di sini: https://cloud.google.com/text-to-speech/
Gunakan SSML
$ go-chromecast tts '<speak>Hello<break time="500ms"/>world.</speak>'
--google-service-account=/path/to/service/account.json
--ssml