# Destroying WowzaPlayer on page change?

**URL:** https://community.wowza.com/t/destroying-wowzaplayer-on-page-change/49430
**Category:** Wowza Player
**Created:** [August 14, 2017, 5:17pm UTC](https://community.wowza.com/t/destroying-wowzaplayer-on-page-change/49430 "2017-08-14T17:17:29Z")
**Posts on this page:** 5
**Page:** 1

<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 14, 2017, 5:17pm UTC](https://community.wowza.com/t/destroying-wowzaplayer-on-page-change/49430/1 "2017-08-14T17:17:29Z")

</div>

Hello everyone,

I have added WowzaPlayer to my Angular4 application. It works well except that when I try to change the view by clicking some link in the navigation bar it starts throwing exception looking like this:

======================== Start of exception =================================

vendor.bundle.js:56394 ERROR Error: Uncaught (in promise): NotFoundError: Failed to execute ‘removeChild’ on ‘Node’: The node to be removed is not a child of this node. Error: Failed to execute ‘removeChild’ on ‘Node’: The node to be removed is not a child of this node. at J0td.destroy (wowzaplayer.js:1) at a7td.destroy (wowzaplayer.js:1) at u5Ud.destroy (wowzaplayer.js:1) at C.d.C (wowzaplayer.min.js:30) at C.d.destroy (wowzaplayer.min.js:31) at TagDetailsComponent.webpackJsonp…/…/…/…/…/src/app/tags/tag-details/tag-details.component.ts.TagDetailsComponent.ngOnDestroy (main.bundle.js:1502) at callProviderLifecycles (vendor.bundle.js:66560) at callElementProvidersLifecycles (vendor.bundle.js:66529) at callLifecycleHooksChildrenFirst (vendor.bundle.js:66513) at destroyView (vendor.bundle.js:67849) at J0td.destroy (wowzaplayer.js:1) at a7td.destroy (wowzaplayer.js:1) at u5Ud.destroy (wowzaplayer.js:1) at C.d.C (wowzaplayer.min.js:30) at C.d.destroy (wowzaplayer.min.js:31) at TagDetailsComponent.webpackJsonp…/…/…/…/…/src/app/tags/tag-details/tag-details.component.ts.TagDetailsComponent.ngOnDestroy (main.bundle.js:1502) at callProviderLifecycles (vendor.bundle.js:66560) at callElementProvidersLifecycles (vendor.bundle.js:66529) at callLifecycleHooksChildrenFirst (vendor.bundle.js:66513) at destroyView (vendor.bundle.js:67849) at resolvePromise (polyfills.bundle.js:3198) at resolvePromise (polyfills.bundle.js:3169) at polyfills.bundle.js:3246 at ZoneDelegate.webpackJsonp…/…/…/…/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2839) at Object.onInvokeTask (vendor.bundle.js:59255) at ZoneDelegate.webpackJsonp…/…/…/…/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.bundle.js:2838) at Zone.webpackJsonp…/…/…/…/zone.js/dist/zone.js.Zone.runTask (polyfills.bundle.js:2606) at drainMicroTaskQueue (polyfills.bundle.js:3010) at ZoneTask.webpackJsonp…/…/…/…/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (polyfills.bundle.js:2917) at invokeTask (polyfills.bundle.js:3779)

======================== End of exception =================================

I’m calling the destroy method before the page to be destroyed. This doesn’t help.

ngOnDestroy() { (window as any).WowzaPlayer.destroy(‘player’); }

Can anyone help me with this issue? What should I call before to load the new page? Is there anything else I need to call?

---

<div class="post-metadata">

### Author: ![Rogier\_Tuinte1](https://avatars.discourse-cdn.com/v4/letter/r/a88e4f/32.png) [@Rogier\_Tuinte1](https://community.wowza.com/u/Rogier_Tuinte1)
#### Post date: [March 2, 2018, 11:46pm UTC](https://community.wowza.com/t/destroying-wowzaplayer-on-page-change/49430/2 "2018-03-02T23:46:35Z")

</div>

I’m also experiencing this issue.

---

<div class="post-metadata">

### Author: ![DCTI\_IGPF](https://avatars.discourse-cdn.com/v4/letter/d/c77e96/32.png) [@DCTI\_IGPF](https://community.wowza.com/u/DCTI_IGPF)
#### Post date: [March 6, 2018, 8:58pm UTC](https://community.wowza.com/t/destroying-wowzaplayer-on-page-change/49430/3 "2018-03-06T20:58:47Z")

</div>

I use this to stop it. Not sure if works with Angular4

```auto
function stopPlayer(){
	var myPlayer = WowzaPlayer.get("player"); //Where player is its div element
	if (myPlayer != null) {
		myPlayer.finish();
		myPlayer.destroy();
	}
}

```

---

<div class="post-metadata">

### Author: ![Weijing\_Lin](https://avatars.discourse-cdn.com/v4/letter/w/ee7513/32.png) [@Weijing\_Lin](https://community.wowza.com/u/Weijing_Lin)
#### Post date: [November 29, 2019, 1:04pm UTC](https://community.wowza.com/t/destroying-wowzaplayer-on-page-change/49430/4 "2019-11-29T13:04:01Z")

</div>

It doesn’t work for me :\*(

---

<div class="post-metadata">

### Author: ![Rose\_Power-Wowza\_Com](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/rose_power-wowza_com/32/431_2.png) [@Rose\_Power-Wowza\_Com](https://community.wowza.com/u/Rose_Power-Wowza_Com)
#### Post date: [November 30, 2019, 5:12pm UTC](https://community.wowza.com/t/destroying-wowzaplayer-on-page-change/49430/5 "2019-11-30T17:12:49Z")

</div>

This is our most recent documentation on how to use the destroy method:

### Destroy a WowzaPlayer instance

The destroy method deallocates a WowzaPlayer instance.

destroy ( );

If you have the WowzaPlayer instance available, for example, myPlayer, you can do the following:

```auto
myPlayer.destroy();

```

**More info here:**

[**https://www.wowza.com/docs/wowza-player-javascript-api-overview#destroy-a-wowzaplayer-instance**](https://www.wowza.com/docs/wowza-player-javascript-api-overview#destroy-a-wowzaplayer-instance)

\*\*\*If you still experience any issues, please submit a ticket to our official technical support and we’ll take a look:

[https://www.wowza.com/support/open-ticket](https://www.wowza.com/support/open-ticket)
