Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@
* @siropeich [Siro Blanco, Epic Labs]
* @epiclabsDASH [Jesus Oliva, Epic Labs]
* @adripanico [Adrian Caballero, Epic Labs]
* @ahfarmer [Andrew Farmer, Rhombus Systems]
14 changes: 13 additions & 1 deletion src/core/FactoryMaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
const FactoryMaker = (function () {

let instance;
const singletonContexts = [];
let singletonContexts = [];
const singletonFactories = {};
const classFactories = {};

Expand Down Expand Up @@ -94,6 +94,17 @@ const FactoryMaker = (function () {
});
}

/**
* Use this method to remove all singleton instances associated with a particular context.
*
* @param {Object} context
* @memberof module:FactoryMaker
* @instance
*/
function deleteSingletonInstances(context) {
singletonContexts = singletonContexts.filter(x => x.context !== context);
}

/*------------------------------------------------------------------------------------------*/

// Factories storage Management
Expand Down Expand Up @@ -239,6 +250,7 @@ const FactoryMaker = (function () {
extend: extend,
getSingletonInstance: getSingletonInstance,
setSingletonInstance: setSingletonInstance,
deleteSingletonInstances: deleteSingletonInstances,
getSingletonFactory: getSingletonFactory,
getSingletonFactoryByName: getSingletonFactoryByName,
updateSingletonFactory: updateSingletonFactory,
Expand Down
17 changes: 15 additions & 2 deletions src/streaming/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ function MediaPlayer() {
* Sets the MPD source and the video element to null. You can also reset the MediaPlayer by
* calling attachSource with a new source file.
*
* Calling this method is all that is necessary to destroy a MediaPlayer instance.
* This call does not destroy the MediaPlayer. To destroy the MediaPlayer and free all of its
* memory, call destroy().
*
* @memberof module:MediaPlayer
* @instance
Expand Down Expand Up @@ -375,6 +376,17 @@ function MediaPlayer() {
}
}

/**
* Completely destroys the media player and frees all memory.
*
* @memberof module:MediaPlayer
* @instance
*/
function destroy() {
reset();
FactoryMaker.deleteSingletonInstances(context);
}

/**
* The ready state of the MediaPlayer based on both the video element and MPD source being defined.
*
Expand Down Expand Up @@ -2303,7 +2315,8 @@ function MediaPlayer() {
getSettings: getSettings,
updateSettings: updateSettings,
resetSettings: resetSettings,
reset: reset
reset: reset,
destroy: destroy
};

setup();
Expand Down