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

**URL:** <https://community.wowza.com/t/how-can-i-change-source-url-via-javascript-on-already-loaded-player/38663>\
**Category:** Wowza Player\
**Created:** [December 22, 2016, 1:43pm UTC](https://community.wowza.com/t/how-can-i-change-source-url-via-javascript-on-already-loaded-player/38663 "2016-12-22T13:43:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jehun\_koa](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@Jehun\_koa](https://community.wowza.com/u/Jehun_koa)\
**Post date:** [December 22, 2016, 1:43pm UTC](https://community.wowza.com/t/how-can-i-change-source-url-via-javascript-on-already-loaded-player/38663/1 "2016-12-22T13:43:27Z")

</div>

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

More detail setting references and examples needed…

---

<div class="post-metadata">

**Author:** ![Tonima\_Afroze](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@Tonima\_Afroze](https://community.wowza.com/u/Tonima_Afroze)\
**Post date:** [May 11, 2017, 1:18pm UTC](https://community.wowza.com/t/how-can-i-change-source-url-via-javascript-on-already-loaded-player/38663/2 "2017-05-11T13:18:59Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Gregg\_Cowell](https://avatars.discourse-cdn.com/v4/letter/g/ee7513/32.png) [@Gregg\_Cowell](https://community.wowza.com/u/Gregg_Cowell)\
**Post date:** [July 31, 2017, 11:41am UTC](https://community.wowza.com/t/how-can-i-change-source-url-via-javascript-on-already-loaded-player/38663/3 "2017-07-31T11:41:31Z")

</div>

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

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

)

```

---

<div class="post-metadata">

**Author:** ![dan\_schlegel](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@dan\_schlegel](https://community.wowza.com/u/dan_schlegel)\
**Post date:** [August 15, 2017, 2:44pm UTC](https://community.wowza.com/t/how-can-i-change-source-url-via-javascript-on-already-loaded-player/38663/4 "2017-08-15T14:44:23Z")

</div>

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

```auto
    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);
    };

```
