Skip to content

Commit 1091d09

Browse files
committed
Video.destroy has been renamed to Video.preDestroy, so that it now destroys properly like all other Game Objects. Fix phaserjs#4821
1 parent 9ff331e commit 1091d09

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

src/gameobjects/video/Video.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,16 @@ var Video = new Class({
366366
*/
367367
this._isSeeking = false;
368368

369+
/**
370+
* Should the Video element that this Video is using, be removed from the DOM
371+
* when this Video is destroyed?
372+
*
373+
* @name Phaser.GameObjects.Video#removeVideoElementOnDestroy
374+
* @type {boolean}
375+
* @since 3.21.0
376+
*/
377+
this.removeVideoElementOnDestroy = false;
378+
369379
this.setPosition(x, y);
370380
this.initPipeline();
371381

@@ -1711,22 +1721,21 @@ var Video = new Class({
17111721
},
17121722

17131723
/**
1714-
* Destroys the Video object. This calls `Video.stop` and optionally `Video.removeVideoElement`.
1724+
* Handles the pre-destroy step for the Video object.
1725+
*
1726+
* This calls `Video.stop` and optionally `Video.removeVideoElement`.
17151727
*
17161728
* If any Sprites are using this Video as their texture it is up to you to manage those.
17171729
*
1718-
* @method Phaser.GameObjects.Video#destroy
1719-
* @since 3.20.0
1720-
*
1721-
* @param {boolean} [removeVideoElement=false] - Should the video element be removed from the DOM?
1730+
* @method Phaser.GameObjects.Video#preDestroy
1731+
* @private
1732+
* @since 3.21.0
17221733
*/
1723-
destroy: function (removeVideoElement)
1734+
preDestroy: function ()
17241735
{
1725-
if (removeVideoElement === undefined) { removeVideoElement = false; }
1726-
17271736
this.stop();
17281737

1729-
if (removeVideoElement)
1738+
if (this.removeVideoElementOnDestroy)
17301739
{
17311740
this.removeVideoElement();
17321741
}

0 commit comments

Comments
 (0)