Wowza Community

How can I change source URL via JavaScript on already loaded player

How can I change source URL via JavaScript on already loaded player

More detail setting references and examples needed…

Did you solve this? I have the exact same problem. I will need to change the URL based on user input (the user has multiple streams to choose from).

I found that the only way to do this was via the setConfig method on the player object.

myPlayer.setConfig(
            {
                "sourceURL":"http://[NEW_URL}"
            }

)

I first destroy the player, then pass the new options containing the new URL address from where to stream. Example in TypeScript below:

    onVodClick() {
        if (this.player != null) {
            this.player.destroy();
        }

        this.wowzaPlayerOptions.title = "VOD";
        this.wowzaPlayerOptions.sourceURL = this.urls.vod;

        this.player = (window as any).WowzaPlayer.create('player', this.wowzaPlayerOptions);
    };