I did something similar in Node-Red using castv2. It sometimes chops the first few milliseconds of the audio file but it works flawlessly otherwise.
[
{
"id": "a83ecdca.0284d",
"type": "tab",
"label": "Chromecasts",
"disabled": false,
"info": ""
},
{
"id": "72464afe.6563b4",
"type": "group",
"z": "a83ecdca.0284d",
"name": "Living Space",
"style": {
"label": true
},
"nodes": [
"3ea772dd.97674e",
"dcd90f8b.ee59e",
"dd3e647e.a391d8",
"21c1abf0.d9eee4",
"485e304c.7a19a",
"5758539e.daa58c",
"5d3e039b.68968c",
"ba2bd794.c6d828",
"1c1ed4cb.d1a82b",
"913bf8bc.33a198",
"bec880d7.27689",
"51717c9e.2c5444",
"1ac46e06.e468d2",
"c8a79924.20f038",
"7d7593ef.a1574c",
"455d55b2.23812c",
"565da0e8.05956"
],
"x": 324,
"y": 209,
"w": 1837,
"h": 282
},
{
"id": "3ea772dd.97674e",
"type": "function",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Mute",
"func": "msg.payload = {\n type: \"MUTE\",\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 500,
"y": 275,
"wires": [
[
"dcd90f8b.ee59e"
]
]
},
{
"id": "dcd90f8b.ee59e",
"type": "castv2-sender",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "",
"connection": "9b0075f1.3a9588",
"x": 705,
"y": 300,
"wires": [
[
"1ac46e06.e468d2"
]
]
},
{
"id": "dd3e647e.a391d8",
"type": "switch",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Playing",
"property": "payload.playerState",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "PLAYING",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1085,
"y": 300,
"wires": [
[
"51717c9e.2c5444"
]
]
},
{
"id": "21c1abf0.d9eee4",
"type": "link in",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Send to - Living Space Chromecast",
"links": [
"d7bf184b.c8e788"
],
"x": 365,
"y": 300,
"wires": [
[
"3ea772dd.97674e",
"dcd90f8b.ee59e"
]
]
},
{
"id": "485e304c.7a19a",
"type": "function",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Seek Zero",
"func": "msg.payload = {\n type: \"SEEK\",\n time: 0 // Time to seek to in seconds\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1670,
"y": 400,
"wires": [
[
"ba2bd794.c6d828"
]
]
},
{
"id": "5758539e.daa58c",
"type": "function",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Pause",
"func": "msg.payload = {\n type: \"PAUSE\"\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1650,
"y": 300,
"wires": [
[
"ba2bd794.c6d828"
]
]
},
{
"id": "5d3e039b.68968c",
"type": "function",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Play",
"func": "msg.payload = {\n type: \"PLAY\"\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1850,
"y": 450,
"wires": [
[
"ba2bd794.c6d828"
]
]
},
{
"id": "ba2bd794.c6d828",
"type": "castv2-sender",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "",
"connection": "9b0075f1.3a9588",
"x": 2055,
"y": 350,
"wires": [
[]
]
},
{
"id": "1c1ed4cb.d1a82b",
"type": "debug",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1095,
"y": 250,
"wires": []
},
{
"id": "913bf8bc.33a198",
"type": "switch",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Paused",
"property": "payload.playerState",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "PAUSED",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1085,
"y": 350,
"wires": [
[
"c8a79924.20f038"
]
]
},
{
"id": "bec880d7.27689",
"type": "switch",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Finished",
"property": "payload.idleReason",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "FINISHED",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1085,
"y": 400,
"wires": [
[
"7d7593ef.a1574c"
]
]
},
{
"id": "51717c9e.2c5444",
"type": "trigger",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Limit events",
"op1": "",
"op2": "",
"op1type": "pay",
"op2type": "payl",
"duration": "0",
"extend": false,
"overrideDelay": false,
"units": "ms",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 1445,
"y": 300,
"wires": [
[
"5758539e.daa58c"
]
]
},
{
"id": "1ac46e06.e468d2",
"type": "switch",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Has Value",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "nnull"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 895,
"y": 300,
"wires": [
[
"dd3e647e.a391d8",
"bec880d7.27689",
"913bf8bc.33a198",
"1c1ed4cb.d1a82b"
]
]
},
{
"id": "c8a79924.20f038",
"type": "trigger",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Limit events",
"op1": "",
"op2": "",
"op1type": "pay",
"op2type": "payl",
"duration": "0",
"extend": false,
"overrideDelay": false,
"units": "ms",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 1445,
"y": 350,
"wires": [
[
"455d55b2.23812c",
"565da0e8.05956",
"485e304c.7a19a"
]
]
},
{
"id": "7d7593ef.a1574c",
"type": "function",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Reset",
"func": "\nmsg.reset = true;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1225,
"y": 400,
"wires": [
[
"c8a79924.20f038",
"51717c9e.2c5444"
]
]
},
{
"id": "455d55b2.23812c",
"type": "function",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "Unmute",
"func": "msg.payload = {\n type: \"UNMUTE\"\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 1660,
"y": 350,
"wires": [
[
"ba2bd794.c6d828"
]
]
},
{
"id": "565da0e8.05956",
"type": "delay",
"z": "a83ecdca.0284d",
"g": "72464afe.6563b4",
"name": "",
"pauseType": "delay",
"timeout": "100",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 1670,
"y": 450,
"wires": [
[
"5d3e039b.68968c"
]
]
},
{
"id": "9b0075f1.3a9588",
"type": "castv2-connection",
"name": "",
"target": "Living Space speaker",
"host": "",
"port": "8009"
}
]
Input Payload:
msg.payload = {
type: "MEDIA",
media: {
url: "https://storage.googleapis.com/gilfoyle/the-skypark/v1/common/sounds/effects/kaching.mp3",
contentType: "audio/mp3",
streamType: "LIVE",
}
}