Wowza Community

Destroying WowzaPlayer on page change?

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?

I’m also experiencing this issue.

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

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

It doesn’t work for me :*(

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:

myPlayer.destroy();

More info here:

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