These nodes are based on a fork of the node-red-contrib-chromecast. It is for stream media on a chromecast or a google home device.
This is still in development!
npm install node-red-contrib-cast
Simple flow that sends an mp3 to the chromecast or google cast device:
[{"id":"a21f1807.41d7f8","type":"cast-to-client","z":"d900d7d9.c4c498","name":"","url":null,"contentType":"","message":null,"language":"en","ip":"","port":"","volume":null,"x":590,"y":80,"wires":[["fba1eb3.2515918"]]},{"id":"74313baf.f282f4","type":"inject","z":"d900d7d9.c4c498","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":80,"wires":[["53d91dd8.67b924"]]},{"id":"53d91dd8.67b924","type":"change","z":"d900d7d9.c4c498","name":"","rules":[{"t":"set","p":"ip","pt":"msg","to":"192.168.1.125","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=Word%20Up&tl=En-gb","tot":"str"},{"t":"set","p":"contentType","pt":"msg","to":"audio/mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":80,"wires":[["a21f1807.41d7f8"]]},{"id":"fba1eb3.2515918","type":"debug","z":"d900d7d9.c4c498","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":80,"wires":[]},{"id":"9ef34079.24061","type":"comment","z":"d900d7d9.c4c498","name":"stream a url","info":"","x":130,"y":40,"wires":[]}]
Simple flow that sends an text to Google TTS and the result to a the chromecast or google cast device:
[{"id":"8d9663a.05e27a","type":"cast-to-client","z":"d900d7d9.c4c498","name":"","url":null,"contentType":"","message":null,"language":"en","ip":"","port":"","volume":null,"x":590,"y":200,"wires":[["b885e401.447548"]]},{"id":"6faf449b.c11efc","type":"inject","z":"d900d7d9.c4c498","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":200,"wires":[["23bdf480.46b85c"]]},{"id":"23bdf480.46b85c","type":"change","z":"d900d7d9.c4c498","name":"","rules":[{"t":"set","p":"ip","pt":"msg","to":"192.168.1.125","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"Word Up","tot":"str"},{"t":"set","p":"language","pt":"msg","to":"En-gb","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":200,"wires":[["8d9663a.05e27a"]]},{"id":"b885e401.447548","type":"debug","z":"d900d7d9.c4c498","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":200,"wires":[]},{"id":"9a5a2ce.5ae7ed","type":"comment","z":"d900d7d9.c4c498","name":"say a text","info":"","x":120,"y":160,"wires":[]}]
[{"id":"443984d.4919a7c","type":"cast-to-client","z":"c4dd07cf.84ae98","name":"","url":"","contentType":"","message":"","language":"de","ip":"192.168.1.125","port":"","volume":"","x":490,"y":840,"wires":[["cad88339.e69ff"]]},{"id":"cc601032.ef8b9","type":"inject","z":"c4dd07cf.84ae98","name":"","topic":"","payload":"youtube","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":840,"wires":[["62aea8fa.99c718"]]},{"id":"cad88339.e69ff","type":"debug","z":"c4dd07cf.84ae98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":840,"wires":[]},{"id":"62aea8fa.99c718","type":"change","z":"c4dd07cf.84ae98","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"http://commondatastorage.googleapis.com/gtv-videos-bucket/big_buck_bunny_1080p.mp4","tot":"str"},{"t":"set","p":"contentType","pt":"msg","to":"video/mp4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":840,"wires":[["443984d.4919a7c"]]}]
[{"id":"82e3c67a.27b218","type":"cast-to-client","z":"c4dd07cf.84ae98","name":"","url":"","contentType":"","message":"","language":"en","ip":"192.168.1.125","port":"","volume":"","x":490,"y":220,"wires":[["6bc79592.92574c"]]},{"id":"a5bddaf0.4e9578","type":"inject","z":"c4dd07cf.84ae98","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":220,"wires":[["82e3c67a.27b218"]]},{"id":"6bc79592.92574c","type":"debug","z":"c4dd07cf.84ae98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":220,"wires":[]}]
This will given an object of the following form:
{
"applications": [{
"appId": "CC1AD845",
"displayName": "Default Media Receiver",
"iconUrl": "",
"isIdleScreen": false,
"launchedFromCloud": false,
"namespaces": [{
"name": "urn:x-cast:com.google.cast.cac"
}, {
"name": "urn:x-cast:com.google.cast.broadcast"
}, {
"name": "urn:x-cast:com.google.cast.media"
}
],
"sessionId": "8g547685-4ce7-4968-b656-8679b01f9a77",
"statusText": "Default Media Receiver",
"transportId": "8g547685-4ce7-4968-b656-8679b01f9a77"
}
],
"userEq": {
"high_shelf": {
"frequency": 4500,
"gain_db": 0,
"quality": 0.707
},
"low_shelf": {
"frequency": 150,
"gain_db": 0,
"quality": 0.707
},
"max_peaking_eqs": 0,
"peaking_eqs": []
},
"volume": {
"controlType": "master",
"level": 0.15000000596046448,
"muted": false,
"stepInterval": 0.019999999552965164
}
}
or if currently playing media
{
"applications": [{
"appId": "12F05308",
"displayName": "TuneIn Free",
"iconUrl": "https://lh3.googleusercontent.com/HY9FJJF6gvT-JykObo1KvoNbewRoUJa2VjsE8TRgmBUmFFYGDI3FYJRGxGkj9gkMh_f3K-QSytav8G8",
"isIdleScreen": false,
"launchedFromCloud": true,
"namespaces": [{
"name": "urn:x-cast:com.google.cast.cac"
}, {
"name": "urn:x-cast:com.tunein.cast.init"
}, {
"name": "urn:x-cast:com.tunein.cast.initUrl"
}, {
"name": "urn:x-cast:com.tunein.cast.play"
}, {
"name": "urn:x-cast:com.tunein.cast.pause"
}, {
"name": "urn:x-cast:com.tunein.cast.stop"
}, {
"name": "urn:x-cast:com.tunein.cast.comm.addSender"
}, {
"name": "urn:x-cast:com.tunein.cast.comm.mediaLoaded"
}, {
"name": "urn:x-cast:com.tunein.cast.comm.playState"
}, {
"name": "urn:x-cast:com.tunein.cast.comm.tuneDataLoaded"
}, {
"name": "urn:x-cast:com.tunein.cast.comm.scrubberMovedMessage"
}, {
"name": "urn:x-cast:com.tunein.cast.comm.nowPlayingDataLoaded"
}, {
"name": "urn:x-cast:com.tunein.cast.comm.error"
}, {
"name": "urn:x-cast:com.google.cast.broadcast"
}, {
"name": "urn:x-cast:com.google.cast.media"
}
],
"sessionId": "1f8d64e1-fde4-42kb-xxc3-b77493ej54a6",
"statusText": "Casting: Radio Dresden",
"transportId": "1f8d64e1-fde4-42kb-xxc3-b77493ej54a6"
}
],
"userEq": {
"high_shelf": {
"frequency": 4500,
"gain_db": 0,
"quality": 0.707
},
"low_shelf": {
"frequency": 150,
"gain_db": 0,
"quality": 0.707
},
"max_peaking_eqs": 0,
"peaking_eqs": []
},
"volume": {
"controlType": "master",
"level": 0.15000000596046448,
"muted": false,
"stepInterval": 0.019999999552965164
}
}
- Cast Node - Send media to chromecast or googole home devices
The cast node has a couple of settings, which can be provided by the configuration or by the incomming message object.
Options for the incomming message object:
-
IP,
msg.ip
ormsg.payload.ip
the IP address of the device to cast the media. Could also be defined in the configuration of the node. -
Port,
msg.port
ormsg.payload.port
the port of the device (if not given default8009
will be used). -
Media Url,
msg.url
ormsg.payload.url
url to a media file which should be cast to the cast device. For a chromecast this chould be a media or a viideo file. For a Google Home device without a display this could only a audio file. Can be an array of url. -
Media Type,
msg.contentType
ormsg.payload.contentType
the content type (mime type) of the file in the url. This property is required if a url is given. Could also be defined in the configuration of the node. -
Image Url,
msg.imageUrl
ormsg.payload.imageUrl
url to a image file which represents the artwork for the url which should be cast to the cast device. For a chromecast this should be an image file. For a Google Home device without a display this is irrelevant. -
Message,
msg.message
ormsg.payload.message
a text which should be send to the google tts engine to convert to a mp3 file. -
Language,
msg.language
ormsg.payload.language
the language which should be used for conveting the message to the media file. -
Volume,
msg.volume
ormsg.payload.volume
the volume should be set. -
Additional options (not configurable):
msg.status
is set totrue
the player status will be queried and send as output, No media will be playedmsg.lowerVolumeLimit
ormsg.payload.lowerVolumeLimit
will set the volume to this value, if the current volume is below this value.msg.upperVolumeLimit
ormsg.payload.upperVolumeLimit
will set the volume to this value, if the current volume is above this limit.msg.muted
ormsg.payload.muted
the volume will be muted if set to false, otherwise the volume will be unmuted.msg.seek
ormsg.payload.seek
will sets the current position in the stream.msg.duration
ormsg.payload.duration
will sets the duration of the playing stream in seconds.
So the config can be at 3 places. The config of the node, a property of the msg.payload
or a property of the msg
object. The information is loaded in that order (e.g. url):
- (1st) If the
msg.payload
is a object and contains a propertymsg.payload.url
this setting will be used.- (2nd) otherwise if the
msg
object contains the propertymsg.url
this setting will be used.- (3rd) otherwise if in the configuration the Media Url property is set this url will be used.
- (2nd) otherwise if the
Common Video File MIME Types are:
Video Type | Extension | MIME Type |
---|---|---|
Flash | .flv | video/x-flv |
MPEG-4 | .mp4 | video/mp4 |
iPhone Index | .m3u8 | application/x-mpegURL |
iPhone Segment | .ts | video/MP2T |
3GP Mobile | .3gp | video/3gpp |
QuickTime | .mov | video/quicktime |
A/V Interleave | .avi | video/x-msvideo |
Windows Media | .wmv | video/x-ms-wmv |
Common Audio File MIME Types are:
File Extension | MIME Type |
---|
au | audio/basic snd | audio/basic Linear PCM | auido/L24 mid | audio/mid rmi | audio/mid mp3 | audio/mp3 mp4 audio | audio/mp4 aif | audio/x-aiff aifc | audio/x-aiff aiff | audio/x-aiff m3u | audio/x-mpegurl ra | audio/vnd.rn-realaudio ram | audio/vnd.rn-realaudio Ogg Vorbis | audio/ogg Vorbis | audio/vorbis wav | audio/vnd.wav
When no Media Url or Message is setup, the player will stop playing the current media and the status will be queried and send as output. If only the status should be get without interrupting the current playing media msg.status
needs to be set to true
.
More advanced control is possible by using msg.payload.media
. This must be an object with the following properties:
Name | Type | Description |
---|---|---|
contentId | string | Url of the media. If the url is defined in confuguration or by msg.payload.url or msg.url this property will be set or overwritten. |
streamType | string | Describes the type of media artifact as one of the following:NONE , BUFFERED or LIVE .If not defined, BUFFERED will be used. |
contentType | string | MIME content type of the media being played. If defined in configuration or by msg.contentType or msg.payload.contentType this property will be set or overwritten.If not defined, audio/mp3 will be used. |
metadata | object | metadata which should be used. |
duration | double | Duration of the currently playing stream in seconds. If defined as msg.duration or msg.payload.duration this property will be set or overwritten. |
To differentiate different recivers, it may be helpful to choose different icons.
This is possible by choosing another icon in the Node Settings:
For this purpose, the node already comes with a selection of useful icons:
For bugs, questions and discussions please use the GitHub Issues.
Even for those that don't have the technical knowhow to help developing on there are ways to support development. So if you want to donate some money please feel free to send money via PayPal.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
this node is published also here: Npm pakage: https://www.npmjs.com/package/node-red-contrib-cast Node-Red: https://flows.nodered.org/node/node-red-contrib-cast