'Node-Red How to change the property of a node using a function-node

we are working on a group project and we have ran into a problem.

We are creating a music player in Node-Red where when you inject start the music file starts to play and when you press stop it stops. But we have one problem, we want to integrate MQTT later on in the project so that a user can choose an available song to play. We just don't know how to change the property of a node using a function. The property of the node requires a directory and we have been trying to change this directory to something else using a function node but without success. Is there an easy way to do this or not?

This is an image of my flow:

Node-Red Flow

This is the JSON code of my flow:

[
    {
        "id": "7cdfcf03214c3a9e",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "03a768ec195a930d",
        "type": "PlaySound",
        "z": "7cdfcf03214c3a9e",
        "name": "",
        "playerOptions": "{}",
        "audioURI": "",
        "options": "{}",
        "x": 850,
        "y": 360,
        "wires": [
            []
        ]
    },
    {
        "id": "b67c61e3dbcc8cab",
        "type": "inject",
        "z": "7cdfcf03214c3a9e",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "start",
        "payloadType": "str",
        "x": 510,
        "y": 360,
        "wires": [
            [
                "5e81c624e936153b"
            ]
        ]
    },
    {
        "id": "5e81c624e936153b",
        "type": "function",
        "z": "7cdfcf03214c3a9e",
        "name": "",
        "func": "msg.audioURI = 'C:\\\\Users\\\\louis\\\\Downloads\\\\Backstreet Boys - I Want It That Way (Official HD Video) (192 kbps).mp3';\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 660,
        "y": 360,
        "wires": [
            [
                "03a768ec195a930d"
            ]
        ]
    }
]

The inject node contains a msg.payload with a string that says start

The function node contains the following code:

msg.audioURI = 'C:\\Users\\louis\\Downloads\\Backstreet Boys - I Want It That Way (Official HD Video) (192 kbps).mp3';
return msg;

The playsound node contains the following properties:

Playsound-Node property

This is the node we are currently using: https://flows.nodered.org/node/node-red-contrib-play-sound



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source