benchmark.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title></title>
  6. </head>
  7. <body>
  8. <script src="hls.js"></script>
  9. <video id="video" controls></video>
  10. <script>
  11. function parseQuery(queryString) {
  12. var query = {};
  13. var pairs = (
  14. queryString[0] === '?' ? queryString.slice(1) : queryString
  15. ).split('&');
  16. for (var i = 0; i < pairs.length; i++) {
  17. var pair = pairs[i].split('=');
  18. query[decodeURIComponent(pair[0])] = decodeURIComponent(
  19. pair[1] || ''
  20. );
  21. }
  22. return query;
  23. }
  24. /* get stream from query string */
  25. function getParameterByName(name) {
  26. var query = parseQuery(window.location.search);
  27. return query.hasOwnProperty(name) ? query[name] : undefined;
  28. }
  29. var stream =
  30. getParameterByName('stream') ||
  31. 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
  32. </script>
  33. <script>
  34. if (Hls.isSupported()) {
  35. var video = document.getElementById('video');
  36. var hls = new Hls();
  37. hls.loadSource(stream);
  38. hls.attachMedia(video);
  39. hls.on(Hls.Events.MEDIA_ATTACHED, function () {
  40. video.muted = true;
  41. video.play();
  42. });
  43. }
  44. </script>
  45. <script>
  46. var video = document.getElementById('video');
  47. window.onload = function () {
  48. var i = 0;
  49. var el = document.getElementById('update');
  50. function foo() {
  51. i++;
  52. el.innerHTML =
  53. 'animation:' +
  54. i +
  55. ',decoded:' +
  56. video.webkitDecodedFrameCount +
  57. ',dropped:' +
  58. video.webkitDroppedFrameCount;
  59. window.requestAnimationFrame(foo);
  60. }
  61. foo();
  62. };
  63. </script>
  64. <div id="update"></div>
  65. </body>
  66. </html>