Hi all,
I'm struggling with this for a while. I'm trying to play all mp3 urls, one-by-one, through the HTTP out node. It works only when the function node is:
msg.payload = msg.payload[0].url;
return msg;
But when I'm trying to play the entire array, it fails. I'm sure I'm missing something here...
Any ideas to make it work? 10x
Here's my flow:
[{"id":"c737fb49.1834d8","type":"http in","z":"c3131846.ef3fe8","name":"","url":"/playlist","method":"get","upload":false,"swaggerDoc":"","x":75,"y":165.25,"wires":[["d2e4ca04.dde7d8"]]},{"id":"7130c772.6ee758","type":"function","z":"c3131846.ef3fe8","name":"Array","func":"//msg.topic=\"word1\"\n//msg.payload = msg.payload[0].url;\n//return msg;\n\nvar msgList = [];\nvar letterList = msg.payload;\nfor (var i =0 ; i < 5; i++){\n msgList.push({payload:letterList[i].url});\n}\n\nmsg.payload = msgList;\nreturn msg;","outputs":1,"noerr":0,"x":214.375,"y":247.75,"wires":[["9e7a33ad.4330b"]]},{"id":"fee8e102.5fb1a","type":"change","z":"c3131846.ef3fe8","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":464.75006103515625,"y":274.58331298828125,"wires":[["5142f40f.23405c","e20b14db.c4dfd8"]]},{"id":"e20b14db.c4dfd8","type":"http request","z":"c3131846.ef3fe8","name":"","method":"GET","ret":"bin","paytoqs":false,"url":"","tls":"","proxy":"","authType":"","x":587.472412109375,"y":323.77764892578125,"wires":[["9419c512.606338"]]},{"id":"9419c512.606338","type":"change","z":"c3131846.ef3fe8","name":"Set Headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"audio/mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":694.3056030273438,"y":271.97210693359375,"wires":[["6d5f2037.2e368","c9fea8b8.e61df8"]]},{"id":"6d5f2037.2e368","type":"http response","z":"c3131846.ef3fe8","name":"","statusCode":"","headers":{},"x":822.9722290039062,"y":314.388916015625,"wires":[]},{"id":"9e7a33ad.4330b","type":"delay","z":"c3131846.ef3fe8","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"2","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":288.75001525878906,"y":286.5,"wires":[["fee8e102.5fb1a"]]},{"id":"c9fea8b8.e61df8","type":"debug","z":"c3131846.ef3fe8","name":"","active":false,"console":"false","complete":"false","x":826.5,"y":218.75,"wires":[]},{"id":"5142f40f.23405c","type":"debug","z":"c3131846.ef3fe8","name":"","active":true,"console":"false","complete":"false","x":601,"y":221,"wires":[]},{"id":"d2e4ca04.dde7d8","type":"function","z":"c3131846.ef3fe8","name":"mp3","func":"msg.payload = \n[{\"url\":\"https://freesound.org/data/previews/179/179101_3332582-lq.mp3\"},\n{\"url\":\"https://freesound.org/data/previews/428/428908_8584880-lq.mp3\"},\n{\"url\":\"https://freesound.org/data/previews/340/340481_313780-lq.mp3\"},\n{\"url\":\"https://freesound.org/data/previews/476/476542_9786444-lq.mp3\"},\n{\"url\":\"https://freesound.org/data/previews/482/482385_3442171-lq.mp3\"}]\nreturn msg;","outputs":1,"noerr":0,"x":155,"y":205,"wires":[["7130c772.6ee758"]]},{"id":"b2fd8f41.38a24","type":"inject","z":"c3131846.ef3fe8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":60.5,"y":319,"wires":[["d2e4ca04.dde7d8"]]}]