i8beef / node-red-contrib-castv2

MIT License
22 stars 14 forks source link

A little help... #13

Closed Paul-Reed closed 4 years ago

Paul-Reed commented 4 years ago

I'm using your example to cast a mp3 file;

{
  host: "192.168.1.5",
  payload: {
    type: "MEDIA",
    media: {
      url: "http://192.168.1.9/doorbell.mp3",
      contentType: "audio/mp3",
      streamType: "BUFFERED",
          }
  }
}

...but I'm struggling formatting the message in node-RED. What are you using - a function node, change node etc? It would be great if you had a quick flow to demo what nodes to use to get the message in the right format.

Thanks

Paul

i8beef commented 4 years ago

Yes, you'd just build the message in a function node and hand it in. If you're just sending streamType BUFFERED you can exclude that, its the default. And contentType can be inferred from .mp3 on the URL too so it can be excluded if you want.

A sample flow for the most basic case would literally just be a function with this:

return {
  host: '1.1.1.1',
  payload: {
    type: 'MEDIA',
    media: {
      url: 'http://youUrl'
    }
  }
};
Paul-Reed commented 4 years ago

Thanks, that was easier than I expected! I've used node-RED for 4 years now, and this is the first time I've started a function node with; return { I usually end with; return msg I have it working now.