diff --git a/sandbox/middleware-instances.html.example b/sandbox/middleware-instances.html.example new file mode 100644 index 0000000000..b33e6b6169 --- /dev/null +++ b/sandbox/middleware-instances.html.example @@ -0,0 +1,71 @@ + + + + + Video.js Sandbox + + + + + +
+

You can use /sandbox/ for writing and testing your own code. Nothing in /sandbox/ will get checked into the repo, except files that end in .example (so don't edit or add those files). To get started run `npm start` and open the index.html

+
npm start
+
open http://localhost:9999/sandbox/index.html
+
+ +
+

+ In developer console, Sources tab, look for clearCacheForPlayer function. + Place a logpoint at function closing. Logpoint content should be: +

+
'middlewareInstances nr', Object.keys(middlewareInstances).length
+

+ When one or more players are removed, the number of instances should *NOT* grow. +

+
+ +
+ + +
+ +
+ + + + + diff --git a/src/js/tech/middleware.js b/src/js/tech/middleware.js index bb034ad3b4..78182c4a28 100644 --- a/src/js/tech/middleware.js +++ b/src/js/tech/middleware.js @@ -247,7 +247,9 @@ function executeRight(mws, method, value, terminated) { * A {@link Player} instance. */ export function clearCacheForPlayer(player) { - middlewareInstances[player.id()] = null; + if (middlewareInstances.hasOwnProperty(player.id())) { + delete middlewareInstances[player.id()]; + } } /**