File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 4747* @siropeich [ Siro Blanco, Epic Labs]
4848* @epiclabsDASH [ Jesus Oliva, Epic Labs]
4949* @adripanico [ Adrian Caballero, Epic Labs]
50+ * @ahfarmer [ Andrew Farmer, Rhombus Systems]
Original file line number Diff line number Diff line change 3535const FactoryMaker = ( function ( ) {
3636
3737 let instance ;
38- const singletonContexts = [ ] ;
38+ let singletonContexts = [ ] ;
3939 const singletonFactories = { } ;
4040 const classFactories = { } ;
4141
@@ -94,6 +94,17 @@ const FactoryMaker = (function () {
9494 } ) ;
9595 }
9696
97+ /**
98+ * Use this method to remove all singleton instances associated with a particular context.
99+ *
100+ * @param {Object } context
101+ * @memberof module:FactoryMaker
102+ * @instance
103+ */
104+ function deleteSingletonInstances ( context ) {
105+ singletonContexts = singletonContexts . filter ( x => x . context !== context ) ;
106+ }
107+
97108 /*------------------------------------------------------------------------------------------*/
98109
99110 // Factories storage Management
@@ -239,6 +250,7 @@ const FactoryMaker = (function () {
239250 extend : extend ,
240251 getSingletonInstance : getSingletonInstance ,
241252 setSingletonInstance : setSingletonInstance ,
253+ deleteSingletonInstances : deleteSingletonInstances ,
242254 getSingletonFactory : getSingletonFactory ,
243255 getSingletonFactoryByName : getSingletonFactoryByName ,
244256 updateSingletonFactory : updateSingletonFactory ,
Original file line number Diff line number Diff line change @@ -347,7 +347,8 @@ function MediaPlayer() {
347347 * Sets the MPD source and the video element to null. You can also reset the MediaPlayer by
348348 * calling attachSource with a new source file.
349349 *
350- * Calling this method is all that is necessary to destroy a MediaPlayer instance.
350+ * This call does not destroy the MediaPlayer. To destroy the MediaPlayer and free all of its
351+ * memory, call destroy().
351352 *
352353 * @memberof module:MediaPlayer
353354 * @instance
@@ -375,6 +376,17 @@ function MediaPlayer() {
375376 }
376377 }
377378
379+ /**
380+ * Completely destroys the media player and frees all memory.
381+ *
382+ * @memberof module:MediaPlayer
383+ * @instance
384+ */
385+ function destroy ( ) {
386+ reset ( ) ;
387+ FactoryMaker . deleteSingletonInstances ( context ) ;
388+ }
389+
378390 /**
379391 * The ready state of the MediaPlayer based on both the video element and MPD source being defined.
380392 *
@@ -2303,7 +2315,8 @@ function MediaPlayer() {
23032315 getSettings : getSettings ,
23042316 updateSettings : updateSettings ,
23052317 resetSettings : resetSettings ,
2306- reset : reset
2318+ reset : reset ,
2319+ destroy : destroy
23072320 } ;
23082321
23092322 setup ( ) ;
You can’t perform that action at this time.
0 commit comments