|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>Video.js Sandbox</title> |
| 6 | + <link href="../dist/video-js.css" rel="stylesheet" type="text/css"> |
| 7 | + <script src="../dist/video.js"></script> |
| 8 | + <link rel="icon" href="data:;base64,="> |
| 9 | +</head> |
| 10 | +<body> |
| 11 | + <div style="background-color:#eee; border: 1px solid #777; padding: 10px; margin-bottom: 20px; font-size: .8em; line-height: 1.5em; font-family: Verdana, sans-serif;"> |
| 12 | + <p>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</p> |
| 13 | + <pre>npm start</pre> |
| 14 | + <pre>open http://localhost:9999/sandbox/index.html</pre> |
| 15 | + </div> |
| 16 | + |
| 17 | + <div style="background-color:#eee; border: 1px solid #777; padding: 10px; margin-bottom: 20px; font-size: 1em; line-height: 1.5em; font-family: Verdana, sans-serif;"> |
| 18 | + <p> |
| 19 | + In developer console, Sources tab, look for <code>clearCacheForPlayer</code> function. |
| 20 | + Place a logpoint at function closing. Logpoint content should be: |
| 21 | + </p> |
| 22 | + <pre style="font-size: 1.2em;">'middlewareInstances nr', Object.keys(middlewareInstances).length</pre> |
| 23 | + <p> |
| 24 | + When one or more players are removed, the number of instances should *NOT* grow. |
| 25 | + </p> |
| 26 | + </div> |
| 27 | + |
| 28 | + <div> |
| 29 | + <button id="add-player" style="min-height: 36px;">Add player</button> |
| 30 | + <button id="remove-all" style="min-height: 36px;">Remove all players</button> |
| 31 | + </div> |
| 32 | + |
| 33 | + <div id="player-container"></div> |
| 34 | + |
| 35 | + <script> |
| 36 | + let playerList = []; |
| 37 | + |
| 38 | + document.querySelector('#add-player').addEventListener('click', addPlayer); |
| 39 | + document.querySelector('#remove-all').addEventListener('click', removeAll); |
| 40 | + |
| 41 | + function addPlayer() { |
| 42 | + const videoJsElem = document.createElement('video-js'); |
| 43 | + videoJsElem.setAttribute('controls', ''); |
| 44 | + videoJsElem.setAttribute('preload', 'auto'); |
| 45 | + videoJsElem.setAttribute('width', '640'); |
| 46 | + videoJsElem.setAttribute('height', '264'); |
| 47 | + videoJsElem.setAttribute('poster', 'https://vjs.zencdn.net/v/oceans.png'); |
| 48 | + |
| 49 | + document.querySelector('#player-container').appendChild(videoJsElem); |
| 50 | + |
| 51 | + const player = videojs(videoJsElem); |
| 52 | + player.src({ |
| 53 | + src: 'https://vjs.zencdn.net/v/oceans.mp4', |
| 54 | + type: 'video/mp4', |
| 55 | + }); |
| 56 | + |
| 57 | + playerList.push(player); |
| 58 | + |
| 59 | + player.log('Video.js player created', player.id()); |
| 60 | + } |
| 61 | + |
| 62 | + function removeAll() { |
| 63 | + for (const player of playerList) { |
| 64 | + player.dispose(); |
| 65 | + } |
| 66 | + playerList.length = 0; |
| 67 | + } |
| 68 | + </script> |
| 69 | + |
| 70 | +</body> |
| 71 | +</html> |
0 commit comments