[
  {
    "path": ".editorconfig",
    "content": "# http://editorconfig.org\nroot = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\nindent_style = space\nindent_size = 2\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[*.md]\ntrim_trailing_whitespace = false\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "## Description\nBriefly describe the issue.\nInclude a [reduced test case](https://css-tricks.com/reduced-test-cases/).\n\n## Steps to reproduce\nExplain in detail the exact steps necessary to reproduce the issue.\n\n1.\n2.\n3.\n\n## Results\n### Expected\nPlease describe what you expected to see.\n\n### Actual\nPlease describe what actually happened.\n\n### Error output\nIf there are any errors at all, please include them here.\n\n## Additional Information\nPlease include any additional information necessary here. Including the following:\n\n### versions\n#### videojs\nwhat version of videojs does this occur with?\n\n#### browsers\nwhat browser are affected?\n\n#### OSes\nwhat platforms (operating systems and devices) are affected?\n\n### plugins\nare any videojs plugins being used on the page? If so, please list them below.\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "## Description\nPlease describe the change as necessary.\nIf it's a feature or enhancement please be as detailed as possible.\nIf it's a bug fix, please link the issue that it fixes or describe the bug in as much detail.\n\n## Specific Changes proposed\nPlease list the specific changes involved in this pull request.\n\n## Requirements Checklist\n- [ ] Feature implemented / Bug fixed\n- [ ] If necessary, more likely in a feature request than a bug fix\n  - [ ] Unit Tests updated or fixed\n  - [ ] Docs/guides updated\n- [ ] Reviewed by Two Core Contributors\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: ci\n\non: [push, pull_request]\n\njobs:\n  should-skip:\n    continue-on-error: true\n    runs-on: ubuntu-latest\n    # Map a step output to a job output\n    outputs:\n      should-skip-job: ${{steps.skip-check.outputs.should_skip}}\n    steps:\n      - id: skip-check\n        uses: fkirc/skip-duplicate-actions@v5.3.0\n        with:\n          github_token: ${{github.token}}\n\n  ci:\n    needs: should-skip\n    if: ${{needs.should-skip.outputs.should-skip-job != 'true' || github.ref == 'refs/heads/main'}}\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [ubuntu-latest]\n        test-type: ['unit', 'coverage']\n    env:\n      BROWSER_STACK_USERNAME: ${{secrets.BROWSER_STACK_USERNAME}}\n      BROWSER_STACK_ACCESS_KEY: ${{secrets.BROWSER_STACK_ACCESS_KEY}}\n      CI_TEST_TYPE: ${{matrix.test-type}}\n    runs-on: ${{matrix.os}}\n    steps:\n    - name: checkout code\n      uses: actions/checkout@v3\n\n    - name: read node version from .nvmrc\n      run: echo \"NVMRC=$(cat .nvmrc)\" >> $GITHUB_OUTPUT\n      shell: bash\n      id: nvm\n\n    - name: update apt cache on linux w/o browserstack\n      run: sudo apt-get update\n\n    - name: install ffmpeg/pulseaudio for firefox on linux w/o browserstack\n      run: sudo apt-get install ffmpeg pulseaudio\n\n    - name: start pulseaudio for firefox on linux w/o browserstack\n      run: pulseaudio -D\n\n    - name: setup node\n      uses: actions/setup-node@v3\n      with:\n        node-version: '${{steps.nvm.outputs.NVMRC}}'\n        cache: npm\n\n    # turn off the default setup-node problem watchers...\n    - run: echo \"::remove-matcher owner=eslint-compact::\"\n    - run: echo \"::remove-matcher owner=eslint-stylish::\"\n    - run: echo \"::remove-matcher owner=tsc::\"\n\n    - name: npm install\n      run: npm i --prefer-offline --no-audit\n\n    - name: run npm test\n      uses: coactions/setup-xvfb@v1\n      with:\n        run: npm run test\n\n    - name: coverage\n      uses: codecov/codecov-action@v3\n      with:\n        token: ${{secrets.CODECOV_TOKEN}}\n        files: './test/dist/coverage/coverage-final.json'\n        fail_ci_if_error: true\n      if: ${{startsWith(env.CI_TEST_TYPE, 'coverage')}}\n"
  },
  {
    "path": ".gitignore",
    "content": "# OS\nThumbs.db\nehthumbs.db\nDesktop.ini\n.DS_Store\n._*\n\n# Editors\n*~\n*.swp\n*.tmproj\n*.tmproject\n*.sublime-*\n.idea/\n.project/\n.settings/\n.vscode/\n\n# Logs\nlogs\n*.log\nnpm-debug.log*\n\n# Dependency directories\nbower_components/\nnode_modules/\n\n# Build-related directories\ndist/\nes/\ncjs/\ndocs/api/\ntest/dist/\n.eslintcache\n.yo-rc.json\n"
  },
  {
    "path": ".husky/pre-commit",
    "content": "#!/usr/bin/env sh\n. \"$(dirname -- \"$0\")/_/husky.sh\"\n\nnpx lint-staged\n"
  },
  {
    "path": ".husky/pre-push",
    "content": "#!/usr/bin/env sh\n. \"$(dirname -- \"$0\")/_/husky.sh\"\n\nnpm run test\n"
  },
  {
    "path": ".npmignore",
    "content": "# Intentionally left blank, so that npm does not ignore anything by default,\n# but relies on the package.json \"files\" array to explicitly define what ends\n# up in the package.\n"
  },
  {
    "path": ".nvmrc",
    "content": "16\n"
  },
  {
    "path": ".travis.yml",
    "content": "sudo: false\ndist: trusty\nlanguage: node_js\n# node version is specified using the .nvmrc file\nbefore_install:\n  - npm install -g greenkeeper-lockfile@1\nbefore_script:\n  - export DISPLAY=:99.0\n  - sh -e /etc/init.d/xvfb start\n  - greenkeeper-lockfile-update\nafter_script:\n  - greenkeeper-lockfile-upload\naddons:\n  firefox: latest\n  chrome: stable\n\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "<a name=\"4.1.0\"></a>\n# [4.1.0](https://github.com/videojs/videojs-contrib-quality-levels/compare/v4.0.0...v4.1.0) (2024-03-06)\n\n### Features\n\n* add types support (#149) ([7bc330e](https://github.com/videojs/videojs-contrib-quality-levels/commit/7bc330e)), closes [#149](https://github.com/videojs/videojs-contrib-quality-levels/issues/149)\n\n### Chores\n\n* Update CI workflow (#144) ([f088ede](https://github.com/videojs/videojs-contrib-quality-levels/commit/f088ede)), closes [#144](https://github.com/videojs/videojs-contrib-quality-levels/issues/144)\n\n<a name=\"4.0.0\"></a>\n# [4.0.0](https://github.com/videojs/videojs-contrib-quality-levels/compare/v3.0.0...v4.0.0) (2023-03-31)\n\n### Features\n\n* make quality level list iterable (#136) ([c054f8c](https://github.com/videojs/videojs-contrib-quality-levels/commit/c054f8c)), closes [#136](https://github.com/videojs/videojs-contrib-quality-levels/issues/136)\n* update to support only Video.js 8 and eliminate deprecation warnings (#138) ([ccab6ca](https://github.com/videojs/videojs-contrib-quality-levels/commit/ccab6ca)), closes [#138](https://github.com/videojs/videojs-contrib-quality-levels/issues/138)\n\n\n### BREAKING CHANGES\n\n* This breaks compatibility with all versions of Internet Explorer.\n* With this change, videojs-contrib-quality-levels supports only Video.js 8 and newer.\n\n<a name=\"3.0.0\"></a>\n# [3.0.0](https://github.com/videojs/videojs-contrib-quality-levels/compare/v2.2.1...v3.0.0) (2022-12-22)\n\n### Features\n\n* Don't transpile classes ([7b01bb3](https://github.com/videojs/videojs-contrib-quality-levels/commit/7b01bb3))\n\n### Chores\n\n* skip vjsverify es check ([89460b1](https://github.com/videojs/videojs-contrib-quality-levels/commit/89460b1))\n\n<a name=\"2.2.1\"></a>\n## [2.2.1](https://github.com/videojs/videojs-contrib-quality-levels/compare/v2.2.0...v2.2.1) (2022-11-23)\n\n### Chores\n\n* do not run tests on npm version (#141) ([e598158](https://github.com/videojs/videojs-contrib-quality-levels/commit/e598158)), closes [#141](https://github.com/videojs/videojs-contrib-quality-levels/issues/141)\n* **package:** add Video.js 8 as a compatible version (#140) ([5e61e71](https://github.com/videojs/videojs-contrib-quality-levels/commit/5e61e71)), closes [#140](https://github.com/videojs/videojs-contrib-quality-levels/issues/140)\n\n<a name=\"2.2.0\"></a>\n# [2.2.0](https://github.com/videojs/videojs-contrib-quality-levels/compare/v2.1.0...v2.2.0) (2022-09-09)\n\n### Features\n\n* add frameRate property to the quality level (#134) ([13998a7](https://github.com/videojs/videojs-contrib-quality-levels/commit/13998a7)), closes [#134](https://github.com/videojs/videojs-contrib-quality-levels/issues/134)\n\n### Chores\n\n* update jsdoc (#132) ([dbcc7b4](https://github.com/videojs/videojs-contrib-quality-levels/commit/dbcc7b4)), closes [#132](https://github.com/videojs/videojs-contrib-quality-levels/issues/132)\n\n### Code Refactoring\n\n* remove IE8 specific changes (#133) ([316f405](https://github.com/videojs/videojs-contrib-quality-levels/commit/316f405)), closes [#133](https://github.com/videojs/videojs-contrib-quality-levels/issues/133)\n\n### Documentation\n\n* Fix typo in README (#135) ([7036132](https://github.com/videojs/videojs-contrib-quality-levels/commit/7036132)), closes [#135](https://github.com/videojs/videojs-contrib-quality-levels/issues/135)\n\n### Tests\n\n* update karma-config to fix local tests (#137) ([77bb0f1](https://github.com/videojs/videojs-contrib-quality-levels/commit/77bb0f1)), closes [#137](https://github.com/videojs/videojs-contrib-quality-levels/issues/137)\n\n<a name=\"2.1.0\"></a>\n# [2.1.0](https://github.com/videojs/videojs-contrib-quality-levels/compare/v2.0.9...v2.1.0) (2021-04-05)\n\n### Features\n\n* mark Video.js as a peer dependency (#125) ([1115f78](https://github.com/videojs/videojs-contrib-quality-levels/commit/1115f78)), closes [#125](https://github.com/videojs/videojs-contrib-quality-levels/issues/125)\n\n### Chores\n\n* **package:** update npm-run-all to 4.1.5 (#72) ([a9e7ff5](https://github.com/videojs/videojs-contrib-quality-levels/commit/a9e7ff5)), closes [#72](https://github.com/videojs/videojs-contrib-quality-levels/issues/72)\n* **package:** update videojs-generate-karma-config to version 5.0.2 (#77) ([72190a4](https://github.com/videojs/videojs-contrib-quality-levels/commit/72190a4)), closes [#77](https://github.com/videojs/videojs-contrib-quality-levels/issues/77)\n* Update videojs-generate-karma-config to the latest version 🚀 (#65) ([50b2b42](https://github.com/videojs/videojs-contrib-quality-levels/commit/50b2b42)), closes [#65](https://github.com/videojs/videojs-contrib-quality-levels/issues/65)\n\n### Documentation\n\n* Fixed grammar and removed some unnecessary words (#83) ([63da16f](https://github.com/videojs/videojs-contrib-quality-levels/commit/63da16f)), closes [#83](https://github.com/videojs/videojs-contrib-quality-levels/issues/83)\n* **README:** Fix minor typo (#114) ([153583e](https://github.com/videojs/videojs-contrib-quality-levels/commit/153583e)), closes [#114](https://github.com/videojs/videojs-contrib-quality-levels/issues/114)\n* update description in readme (#84) ([433df96](https://github.com/videojs/videojs-contrib-quality-levels/commit/433df96)), closes [#84](https://github.com/videojs/videojs-contrib-quality-levels/issues/84)\n\n<a name=\"2.0.9\"></a>\n## [2.0.9](https://github.com/videojs/videojs-contrib-quality-levels/compare/v2.0.8...v2.0.9) (2018-09-17)\n\n### Bug Fixes\n\n* another version reporting issue ([9003e8d](https://github.com/videojs/videojs-contrib-quality-levels/commit/9003e8d))\n\n<a name=\"2.0.8\"></a>\n## [2.0.8](https://github.com/videojs/videojs-contrib-quality-levels/compare/v2.0.7...v2.0.8) (2018-09-17)\n\n### Bug Fixes\n\n* Remove the postinstall script to prevent install issues (#54) ([7562cdb](https://github.com/videojs/videojs-contrib-quality-levels/commit/7562cdb)), closes [#54](https://github.com/videojs/videojs-contrib-quality-levels/issues/54)\n* report correct version (#57) ([1992300](https://github.com/videojs/videojs-contrib-quality-levels/commit/1992300)), closes [#57](https://github.com/videojs/videojs-contrib-quality-levels/issues/57)\n\n### Chores\n\n* update to generator-videojs-plugin[@7](https://github.com/7).2.0 ([9660214](https://github.com/videojs/videojs-contrib-quality-levels/commit/9660214))\n* **package:** update rollup to version 0.66.0 (#56) ([0467b62](https://github.com/videojs/videojs-contrib-quality-levels/commit/0467b62)), closes [#56](https://github.com/videojs/videojs-contrib-quality-levels/issues/56)\n* **package:** update videojs-contrib-hls to version 5.14.1 (#31) ([b1a17fa](https://github.com/videojs/videojs-contrib-quality-levels/commit/b1a17fa)), closes [#31](https://github.com/videojs/videojs-contrib-quality-levels/issues/31)\n* **package:** update videojs-generate-rollup-config to version 2.2.0 (#55) ([4ad0a93](https://github.com/videojs/videojs-contrib-quality-levels/commit/4ad0a93)), closes [#55](https://github.com/videojs/videojs-contrib-quality-levels/issues/55)\n\n<a name=\"2.0.7\"></a>\n## [2.0.7](https://github.com/videojs/videojs-contrib-quality-levels/compare/v2.0.6...v2.0.7) (2018-08-23)\n\n### Chores\n\n* generator v7 (#50) ([7837d93](https://github.com/videojs/videojs-contrib-quality-levels/commit/7837d93)), closes [#50](https://github.com/videojs/videojs-contrib-quality-levels/issues/50)\n\n<a name=\"2.0.6\"></a>\n## [2.0.6](https://github.com/videojs/videojs-contrib-quality-levels/compare/v2.0.5...v2.0.6) (2018-08-03)\n\n### Bug Fixes\n\n* babel the es dist, by updating the generator (#45) ([0123ee8](https://github.com/videojs/videojs-contrib-quality-levels/commit/0123ee8)), closes [#45](https://github.com/videojs/videojs-contrib-quality-levels/issues/45)\n\n<a name=\"2.0.5\"></a>\n## 2.0.5 (2018-07-05)\n\n### Chores\n\n* video.js 5/6 compatibility and travis update (#12) ([c69ac5d](https://github.com/videojs/videojs-contrib-quality-levels/commit/c69ac5d)), closes [#12](https://github.com/videojs/videojs-contrib-quality-levels/issues/12)\n\n## 2.0.4 (2018-01-22)\n* Allow video js 6 to be used (#25)\n\n## 2.0.3 (2017-02-09)\n* chore: video.js 5/6 compatibility and travis update (#12)\n\n## 2.0.2 (2016-12-23)\n * Make global a dependency instead of devDependency\n\n## 2.0.1 (2016-12-13)\n * Make browserify-versionify a dependency instead of devDependency\n\n## 2.0.0 (2016-12-12)\n * Remove HLS and Dash specific logic\n * Return QualityLevel added or removed when using the add or remove api\n\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# CONTRIBUTING\n\nWe welcome contributions from everyone!\n\n## Getting Started\n\nMake sure you have Node.js 8 or higher and npm installed.\n\n1. Fork this repository and clone your fork\n1. Install dependencies: `npm install`\n1. Run a development server: `npm start`\n\n### Making Changes\n\nRefer to the [video.js plugin conventions][conventions] for more detail on best practices and tooling for video.js plugin authorship.\n\nWhen you've made your changes, push your commit(s) to your fork and issue a pull request against the original repository.\n\n### Running Tests\n\nTesting is a crucial part of any software project. For all but the most trivial changes (typos, etc) test cases are expected. Tests are run in actual browsers using [Karma][karma].\n\n- In all available and supported browsers: `npm test`\n- In a specific browser: `npm run test:chrome`, `npm run test:firefox`, etc.\n- While development server is running (`npm start`), navigate to [`http://localhost:9999/test/`][local]\n\n\n[karma]: http://karma-runner.github.io/\n[local]: http://localhost:9999/test/\n[conventions]: https://github.com/videojs/generator-videojs-plugin/blob/master/docs/conventions.md\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright Brightcove, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# videojs-contrib-quality-levels\n[![Build Status](https://travis-ci.org/videojs/videojs-contrib-quality-levels.svg?branch=master)](https://travis-ci.org/videojs/videojs-contrib-quality-levels)\n[![Greenkeeper badge](https://badges.greenkeeper.io/videojs/videojs-contrib-quality-levels.svg)](https://greenkeeper.io/)\n[![Slack Status](http://slack.videojs.com/badge.svg)](http://slack.videojs.com)\n\n[![NPM](https://nodei.co/npm/videojs-contrib-quality-levels.png?downloads=true&downloadRank=true)](https://nodei.co/npm/videojs-contrib-quality-levels/)\n\nA plugin that provides a framework of working with source quality levels.\n\nMaintenance Status: Stable\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n\n- [Installation](#installation)\n- [Using](#using)\n- [Supporting Quality Levels for your source](#supporting-quality-levels-for-your-source)\n  - [Populating the list](#populating-the-list)\n  - [Triggering the 'change' event](#triggering-the-change-event)\n  - [Supported Projects](#supported-projects)\n- [Including the Plugin](#including-the-plugin)\n  - [`<script>` Tag](#script-tag)\n  - [Browserify](#browserify)\n  - [RequireJS/AMD](#requirejsamd)\n- [License](#license)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Installation\n\n- [Installation](#installation)\n- [Using](#using)\n  - [Populating the list](#populating-the-list)\n    - [HLS](#hls)\n- [Including the Plugin](#including-the-plugin)\n  - [`<script>` Tag](#script-tag)\n  - [Browserify](#browserify)\n  - [RequireJS/AMD](#requirejsamd)\n- [License](#license)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n## Installation\n\n```sh\nnpm install --save videojs-contrib-quality-levels\n```\n\nThe npm installation is preferred, but Bower works, too.\n\n```sh\nbower install  --save videojs-contrib-quality-levels\n```\n\n## Using\n\nThe list of `QualityLevels` can be accessed using `qualityLevels()` on the Player object.\nWith this list, you can:\n * See which quality levels are available for the current source\n * Enable or disable specific quality levels to change which levels are selected by ABR\n * See which quality level is currently selected by ABR\n * Detect when the selected quality level changes\n\nExample\n```js\nlet player = videojs('my-video');\n\nlet qualityLevels = player.qualityLevels();\n\n// disable quality levels with less than 720 horizontal lines of resolution when added\n// to the list.\nqualityLevels.on('addqualitylevel', function(event) {\n  let qualityLevel = event.qualityLevel;\n\n  if (qualityLevel.height >= 720) {\n    qualityLevel.enabled = true;\n  } else {\n    qualityLevel.enabled = false;\n  }\n});\n\n// example function that will toggle quality levels between SD and HD, defining and HD\n// quality as having 720 horizontal lines of resolution or more\nlet toggleQuality = (function() {\n  let enable720 = true;\n\n  return function() {\n    for (let qualityLevel of qualityLevels) {\n      if (qualityLevel.height >= 720) {\n        qualityLevel.enabled = enable720;\n      } else {\n        qualityLevel.enabled = !enable720;\n      }\n    }\n    enable720 = !enable720;\n  };\n})();\n\nlet currentSelectedQualityLevelIndex = qualityLevels.selectedIndex; // -1 if no level selected\n\n// Listen to change events for when the player selects a new quality level\nqualityLevels.on('change', function() {\n  console.log('Quality Level changed!');\n  console.log('New level:', qualityLevels[qualityLevels.selectedIndex]);\n});\n```\n## Supporting Quality Levels for your source\nThis project provides the framework for working with source quality levels. Just including this project alongside videojs does not necessarily mean that there will be levels available in the list or that any events will be triggered. Some projects within the videojs org supports this project and automatically populates the list and triggers `change` events when the selected quality level changes. See the [Supported Projects](#supported-projects) section for a list of these projects.\n\nIf you are not using one of the supported projects, but still want to use quality levels with your source, you will have to implement your own plugin that populates the list and triggers change events when selected level changes. Implementing such a plugin is very specific to the source in question, so it is difficult to provide specific examples, but will most likely require a custom middleware, source handler, or tech.\n\n### Populating the list\nInitially the list of quality levels will be empty. You can add quality levels to the list by using `QualityLevelList.addQualityLevel` for each quality level specific to your source. `QualityLevelList.addQualityLevel` takes in a `Representation` object (or generic object with the required properties). All properties are required except `width`, `height` and `frameRate`.\n\nExample Representation\n```js\nRepresentation {\n  id: string,\n  width: number,\n  height: number,\n  bitrate: number,\n  frameRate: number,\n  enabled: function\n}\n```\n\nThe `enabled` function should take an optional boolean to enable or disable the representation and return whether it is currently enabled.\n\nYou can also remove quality levels from the list using `QualityLevelList.removeQualityLevel`. Call this function with the reference to the `QualityLevel` object you wish to remove. The `QualityLevelList.selectedIndex` property will automatically be updated when a quality level is removed so that it still refers to the correct level. If the currently selected level is removed, the `selectedIndex` will be set to `-1`.\n\n### Triggering the 'change' event\n\nWhen your playback plugin changes the selected quality for playback, you will also have to trigger the `change` event on the `QualityLevelList` and update the `QualityLevelList.selectedIndex_`, as it does not have knowledge of which quality is active in playback.\n\n```js\nlet player = videojs('my-video');\n\nlet qualityLevels = player.qualityLevels();\n\nqualityLevels.selectedIndex_ = 0;\nqualityLevels.trigger({ type: 'change', selectedIndex: 0 });\n```\n\n### Supported Projects\n\nThe following projects have built-in support for videojs-contrib-quality-levels and will automatically populate the list with available levels and trigger `change` events when the quality level changes.\n\n* HLS\n  * [@videojs/http-streaming](https://github.com/videojs/http-streaming)\n    * Recommended for HLS\n    * http-streaming is included by default with video.js version 7+\n  * [videojs-contrib-hls](https://github.com/videojs/videojs-contrib-hls)\n    * version 4.1+\n* DASH\n  * [@videojs/http-streaming](https://github.com/videojs/http-streaming)\n    * http-streaming is included by default with video.js version 7+\n\n## Including the Plugin\n\nTo include videojs-contrib-quality-levels on your website or web application, use any of the following methods.\n\n### `<script>` Tag\n\nThis is the simplest case. Get the script in whatever way you prefer and include the plugin _after_ you include [video.js][videojs], so that the `videojs` global is available.\n\n```html\n<script src=\"//path/to/video.min.js\"></script>\n<script src=\"//path/to/videojs-contrib-quality-levels.min.js\"></script>\n<script>\n  var player = videojs('my-video');\n\n  player.qualityLevels();\n</script>\n```\n\n### Browserify\n\nWhen using with Browserify, install videojs-contrib-quality-levels via npm and `require` the plugin as you would any other module.\n\n```js\nvar videojs = require('video.js');\n\n// The actual plugin function is exported by this module, but it is also\n// attached to the `Player.prototype`; so, there is no need to assign it\n// to a variable.\nrequire('videojs-contrib-quality-levels');\n\nvar player = videojs('my-video');\n\nplayer.qualityLevels();\n```\n\n### RequireJS/AMD\n\nWhen using with RequireJS (or another AMD library), get the script in whatever way you prefer and `require` the plugin as you normally would:\n\n```js\nrequire(['video.js', 'videojs-contrib-quality-levels'], function(videojs) {\n  var player = videojs('my-video');\n\n  player.qualityLevels();\n});\n```\n\n## License\n\nApache-2.0. Copyright (c) Brightcove, Inc.\n\n\n[videojs]: http://videojs.com/\n"
  },
  {
    "path": "index.html",
    "content": "<!doctype html>\n<html>\n<head>\n  <meta charset=\"utf-8\">\n  <title>videojs-contrib-quality-levels Demo</title>\n  <link href=\"/node_modules/video.js/dist/video-js.css\" rel=\"stylesheet\">\n  <style>\n    button.enabled {\n      background: SkyBlue;\n    }\n    button.selected {\n      background: SpringGreen;\n    }\n    button.disabled {\n      background: red;\n    }\n  </style>\n</head>\n<body>\n  <div id=\"fixture\">\n  </div>\n  <div id=\"quality-levels\">\n    <h2>Quality Levels:</h2>\n  </div>\n  <ul>\n    <li><a href=\"/test/debug.html\">Run unit tests in browser.</a></li>\n    <li><a href=\"/docs/api/\">Read generated docs.</a></li>\n  </ul>\n  <script src=\"/node_modules/video.js/dist/video.js\"></script>\n  <script src=\"/node_modules/videojs-contrib-hls/dist/videojs-contrib-hls.js\"></script>\n  <script src=\"/dist/videojs-contrib-quality-levels.js\"></script>\n  <script>\n    function createQualityButton(qualityLevel, parent) {\n      var button = document.createElement('button');\n      var classes = button.classList;\n\n      if (qualityLevel.enabled) {\n        classes.add('enabled');\n      } else {\n        classes.add('disabled');\n      }\n\n      button.innerHTML = qualityLevel.id + ': ' + qualityLevel.bitrate + ' kbps';\n      button.id = 'quality-level-' + qualityLevel.id;\n\n      button.onclick = function() {\n        var old = qualityLevel.enabled;\n        qualityLevel.enabled = !old;\n        button.classList.toggle('enabled');\n        button.classList.toggle('disabled');\n      }\n      parent.appendChild(button);\n    }\n\n    function createPlayer(callback) {\n      var video = document.createElement('video');\n      video.id = 'videojs-contrib-quality-levels-player';\n      video.className = 'video-js vjs-default-skin';\n      video.setAttribute('controls', true);\n      video.setAttribute('height', 300);\n      video.setAttribute('width', 600);\n      document.querySelector('#fixture').appendChild(video);\n\n      var options = {\n        autoplay: false,\n        qualityLevels: {}\n      };\n      var url = 'https://hslsslak-a.akamaihd.net/3303963094001/3303963094001_5147618278001_5147609827001.m3u8?pubId=3303963094001&videoId=5147609827001';\n      var type = 'application/x-mpegURL';\n\n      try {\n        window.player = videojs(video.id, options);\n\n        window.player.src({\n          src: url,\n          type: type\n        });\n\n        callback(window.player);\n      } catch(err) {\n        console.log(\"caught an error trying to create and add src to player:\", err);\n      }\n    }\n    function setup(player) {\n      player.ready(function() {\n        var qualityLevels = player.qualityLevels();\n        var container = document.getElementById('quality-levels');\n\n        qualityLevels.on('addqualitylevel', function(event) {\n          createQualityButton(event.qualityLevel, container);\n        });\n\n        qualityLevels.on('change', function(event) {\n          for (var i = 0; i < qualityLevels.length; i++) {\n            var level = qualityLevels[i];\n            var button = document.getElementById('quality-level-' + level.id);\n\n            button.classList.remove('selected');\n          }\n\n          var selected = qualityLevels[event.selectedIndex];\n          var button = document.getElementById('quality-level-' + selected.id);\n          button.classList.add('selected');\n        })\n      });\n    }\n\n    (function(window, videojs) {\n      createPlayer(setup);\n    })(window, window.videojs);\n  </script>\n</body>\n</html>\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"videojs-contrib-quality-levels\",\n  \"version\": \"4.1.0\",\n  \"description\": \"Exposes a list of quality levels available for the source.\",\n  \"main\": \"dist/videojs-contrib-quality-levels.cjs.js\",\n  \"types\": \"dist/types/plugin.d.ts\",\n  \"jsnext:main\": \"src/plugin.js\",\n  \"generator-videojs-plugin\": {\n    \"version\": \"8.0.0\"\n  },\n  \"repository\": \"videojs/videojs-contrib-quality-levels\",\n  \"scripts\": {\n    \"prebuild\": \"npm run clean\",\n    \"build\": \"npm-run-all -s clean -p build:*\",\n    \"build-prod\": \"cross-env-shell NO_TEST_BUNDLE=1 'npm run build'\",\n    \"build-test\": \"cross-env-shell TEST_BUNDLE_ONLY=1 'npm run build'\",\n    \"build:js\": \"rollup -c scripts/rollup.config.js\",\n    \"build:types\": \"tsc\",\n    \"clean\": \"shx rm -rf ./dist ./test/dist ./cjs ./es && shx mkdir -p ./dist ./test/dist ./cjs ./es\",\n    \"postclean\": \"shx mkdir -p ./dist ./test/dist\",\n    \"docs\": \"npm-run-all docs:*\",\n    \"docs:api\": \"jsdoc src -c scripts/jsdoc.config.json -r -d docs/api\",\n    \"docs:toc\": \"doctoc --notitle README.md\",\n    \"lint\": \"vjsstandard\",\n    \"server\": \"karma start scripts/karma.conf.js --singleRun=false --auto-watch\",\n    \"start\": \"npm-run-all -p server watch\",\n    \"pretest\": \"npm-run-all lint build\",\n    \"test\": \"npm-run-all lint build-test && karma start scripts/karma.conf.js\",\n    \"posttest\": \"shx cat test/dist/coverage/text.txt\",\n    \"update-changelog\": \"conventional-changelog -p videojs -i CHANGELOG.md -s\",\n    \"preversion\": \"npm test\",\n    \"version\": \"is-prerelease || npm run update-changelog && git add CHANGELOG.md\",\n    \"watch\": \"npm-run-all -p watch:*\",\n    \"watch:js\": \"npm run build:js -- -w\",\n    \"prepublishOnly\": \"npm-run-all build-prod && vjsverify --verbose --skip-es-check\",\n    \"prepare\": \"husky install\"\n  },\n  \"keywords\": [\n    \"videojs\",\n    \"videojs-plugin\"\n  ],\n  \"author\": \"Brightcove, Inc.\",\n  \"license\": \"Apache-2.0\",\n  \"copyright\": \"Copyright Brightcove, Inc. <https://www.brightcove.com/>\",\n  \"videojs-plugin\": {\n    \"script\": \"dist/videojs-contrib-quality-levels.min.js\"\n  },\n  \"vjsstandard\": {\n    \"ignore\": [\n      \"cjs\",\n      \"dist\",\n      \"docs\",\n      \"ejs\",\n      \"test/dist\"\n    ]\n  },\n  \"files\": [\n    \"CONTRIBUTING.md\",\n    \"dist/\",\n    \"docs/\",\n    \"index.html\",\n    \"scripts/\",\n    \"src/\",\n    \"test/\"\n  ],\n  \"dependencies\": {\n    \"global\": \"^4.4.0\"\n  },\n  \"peerDependencies\": {\n    \"video.js\": \"^8\"\n  },\n  \"devDependencies\": {\n    \"@babel/cli\": \"^7.13.16\",\n    \"@babel/runtime\": \"^7.14.0\",\n    \"@videojs/babel-config\": \"^0.2.0\",\n    \"@videojs/generator-helpers\": \"~2.0.2\",\n    \"conventional-changelog-cli\": \"^2.0.1\",\n    \"conventional-changelog-videojs\": \"^3.0.0\",\n    \"doctoc\": \"^1.3.1\",\n    \"husky\": \"^8.0.3\",\n    \"jsdoc\": \"^3.6.11\",\n    \"karma\": \"^6.3.2\",\n    \"lint-staged\": \"^7.2.2\",\n    \"not-prerelease\": \"^1.0.1\",\n    \"npm-merge-driver-install\": \"^1.0.0\",\n    \"npm-run-all\": \"^4.1.5\",\n    \"pkg-ok\": \"^2.2.0\",\n    \"rollup\": \"^2.46.0\",\n    \"semver\": \"^5.1.0\",\n    \"shx\": \"^0.3.2\",\n    \"sinon\": \"^9.1.0\",\n    \"typescript\": \"^5.4.2\",\n    \"video.js\": \"^8\",\n    \"videojs-generate-karma-config\": \"~8.0.0\",\n    \"videojs-generate-rollup-config\": \"^7.0.0\",\n    \"videojs-generator-verify\": \"^4.1.0\",\n    \"videojs-standard\": \"^9.0.1\"\n  },\n  \"module\": \"dist/videojs-contrib-quality-levels.es.js\",\n  \"lint-staged\": {\n    \"*.js\": \"vjsstandard --fix\",\n    \"README.md\": \"doctoc --notitle\"\n  },\n  \"browser\": \"dist/videojs-contrib-quality-levels.js\",\n  \"engines\": {\n    \"node\": \">=16\",\n    \"npm\": \">=8\"\n  }\n}\n"
  },
  {
    "path": "scripts/jsdoc.config.json",
    "content": "{\n    \"plugins\": [\"plugins/markdown\"]\n}\n\n"
  },
  {
    "path": "scripts/karma.conf.js",
    "content": "const generate = require('videojs-generate-karma-config');\n\nmodule.exports = function(config) {\n\n  // see https://github.com/videojs/videojs-generate-karma-config\n  // for options\n  const options = {};\n\n  config = generate(config, options);\n\n  // any other custom stuff not supported by options here!\n};\n"
  },
  {
    "path": "scripts/rollup.config.js",
    "content": "const generate = require('videojs-generate-rollup-config');\n\n// see https://github.com/videojs/videojs-generate-rollup-config\n// for options\nconst options = {};\nconst config = generate(options);\n\n// Add additonal builds/customization here!\n\n// export the builds to rollup\nexport default Object.values(config.builds);\n"
  },
  {
    "path": "src/plugin.js",
    "content": "import videojs from 'video.js';\nimport QualityLevelList from './quality-level-list.js';\nimport {version as VERSION} from '../package.json';\n\n/**\n * Initialization function for the qualityLevels plugin. Sets up the QualityLevelList and\n * event handlers.\n *\n * @param {Player} player Player object.\n * @param {Object} options Plugin options object.\n * @return {QualityLevelList} a list of QualityLevels\n */\nconst initPlugin = function(player, options) {\n  const originalPluginFn = player.qualityLevels;\n\n  const qualityLevelList = new QualityLevelList();\n\n  const disposeHandler = function() {\n    qualityLevelList.dispose();\n    player.qualityLevels = originalPluginFn;\n    player.off('dispose', disposeHandler);\n  };\n\n  player.on('dispose', disposeHandler);\n\n  player.qualityLevels = () => qualityLevelList;\n  player.qualityLevels.VERSION = VERSION;\n\n  return qualityLevelList;\n};\n\n/**\n * A video.js plugin.\n *\n * In the plugin function, the value of `this` is a video.js `Player`\n * instance. You cannot rely on the player being in a \"ready\" state here,\n * depending on how the plugin is invoked. This may or may not be important\n * to you; if not, remove the wait for \"ready\"!\n *\n * @param {Object} options Plugin options object\n * @return {QualityLevelList} a list of QualityLevels\n */\nconst qualityLevels = function(options) {\n  return initPlugin(this, videojs.obj.merge({}, options));\n};\n\n// Register the plugin with video.js.\nvideojs.registerPlugin('qualityLevels', qualityLevels);\n\n// Include the version number.\nqualityLevels.VERSION = VERSION;\n\nexport default qualityLevels;\n"
  },
  {
    "path": "src/quality-level-list.js",
    "content": "import videojs from 'video.js';\nimport QualityLevel from './quality-level.js';\n\n/**\n * A list of QualityLevels.\n *\n * interface QualityLevelList : EventTarget {\n *   getter QualityLevel (unsigned long index);\n *   readonly attribute unsigned long length;\n *   readonly attribute long selectedIndex;\n *\n *   void addQualityLevel(QualityLevel qualityLevel)\n *   void removeQualityLevel(QualityLevel remove)\n *   QualityLevel? getQualityLevelById(DOMString id);\n *\n *   attribute EventHandler onchange;\n *   attribute EventHandler onaddqualitylevel;\n *   attribute EventHandler onremovequalitylevel;\n * };\n *\n * @extends videojs.EventTarget\n * @class QualityLevelList\n */\nclass QualityLevelList extends videojs.EventTarget {\n  /**\n   * Creates a QualityLevelList.\n   */\n  constructor() {\n    super();\n\n    let list = this; // eslint-disable-line\n\n    list.levels_ = [];\n    list.selectedIndex_ = -1;\n\n    /**\n     * Get the index of the currently selected QualityLevel.\n     *\n     * @returns {number} The index of the selected QualityLevel. -1 if none selected.\n     * @readonly\n     */\n    Object.defineProperty(list, 'selectedIndex', {\n      get() {\n        return list.selectedIndex_;\n      }\n    });\n\n    /**\n     * Get the length of the list of QualityLevels.\n     *\n     * @returns {number} The length of the list.\n     * @readonly\n     */\n    Object.defineProperty(list, 'length', {\n      get() {\n        return list.levels_.length;\n      }\n    });\n\n    list[Symbol.iterator] = () => list.levels_.values();\n\n    return list;\n  }\n\n  /**\n   * Adds a quality level to the list.\n   *\n   * @param {Representation|Object} representation The representation of the quality level\n   * @param {string}   representation.id        Unique id of the QualityLevel\n   * @param {number=}  representation.width     Resolution width of the QualityLevel\n   * @param {number=}  representation.height    Resolution height of the QualityLevel\n   * @param {number}   representation.bandwidth Bitrate of the QualityLevel\n   * @param {number=}  representation.frameRate Frame-rate of the QualityLevel\n   * @param {Function} representation.enabled   Callback to enable/disable QualityLevel\n   * @return {QualityLevel} the QualityLevel added to the list\n   * @method addQualityLevel\n   */\n  addQualityLevel(representation) {\n    let qualityLevel = this.getQualityLevelById(representation.id);\n\n    // Do not add duplicate quality levels\n    if (qualityLevel) {\n      return qualityLevel;\n    }\n\n    const index = this.levels_.length;\n\n    qualityLevel = new QualityLevel(representation);\n\n    if (!('' + index in this)) {\n      Object.defineProperty(this, index, {\n        get() {\n          return this.levels_[index];\n        }\n      });\n    }\n\n    this.levels_.push(qualityLevel);\n\n    this.trigger({\n      qualityLevel,\n      type: 'addqualitylevel'\n    });\n\n    return qualityLevel;\n  }\n\n  /**\n   * Removes a quality level from the list.\n   *\n   * @param {QualityLevel} qualityLevel The QualityLevel to remove from the list.\n   * @return {QualityLevel|null} the QualityLevel removed or null if nothing removed\n   * @method removeQualityLevel\n   */\n  removeQualityLevel(qualityLevel) {\n    let removed = null;\n\n    for (let i = 0, l = this.length; i < l; i++) {\n      if (this[i] === qualityLevel) {\n        removed = this.levels_.splice(i, 1)[0];\n\n        if (this.selectedIndex_ === i) {\n          this.selectedIndex_ = -1;\n        } else if (this.selectedIndex_ > i) {\n          this.selectedIndex_--;\n        }\n        break;\n      }\n    }\n\n    if (removed) {\n      this.trigger({\n        qualityLevel,\n        type: 'removequalitylevel'\n      });\n    }\n\n    return removed;\n  }\n\n  /**\n   * Searches for a QualityLevel with the given id.\n   *\n   * @param {string} id The id of the QualityLevel to find.\n   * @return {QualityLevel|null} The QualityLevel with id, or null if not found.\n   * @method getQualityLevelById\n   */\n  getQualityLevelById(id) {\n    for (let i = 0, l = this.length; i < l; i++) {\n      const level = this[i];\n\n      if (level.id === id) {\n        return level;\n      }\n    }\n    return null;\n  }\n\n  /**\n   * Resets the list of QualityLevels to empty\n   *\n   * @method dispose\n   */\n  dispose() {\n    this.selectedIndex_ = -1;\n    this.levels_.length = 0;\n  }\n}\n\n/**\n * change - The selected QualityLevel has changed.\n * addqualitylevel - A QualityLevel has been added to the QualityLevelList.\n * removequalitylevel - A QualityLevel has been removed from the QualityLevelList.\n */\nQualityLevelList.prototype.allowedEvents_ = {\n  change: 'change',\n  addqualitylevel: 'addqualitylevel',\n  removequalitylevel: 'removequalitylevel'\n};\n\n// emulate attribute EventHandler support to allow for feature detection\nfor (const event in QualityLevelList.prototype.allowedEvents_) {\n  QualityLevelList.prototype['on' + event] = null;\n}\n\nexport default QualityLevelList;\n"
  },
  {
    "path": "src/quality-level.js",
    "content": "/**\n * A single QualityLevel.\n *\n * interface QualityLevel {\n *   readonly attribute DOMString id;\n *            attribute DOMString label;\n *   readonly attribute long width;\n *   readonly attribute long height;\n *   readonly attribute long bitrate;\n *            attribute boolean enabled;\n * };\n *\n * @class QualityLevel\n */\nexport default class QualityLevel {\n\n  /**\n   * Creates a QualityLevel\n   *\n   * @param {Representation|Object} representation The representation of the quality level\n   * @param {string}   representation.id        Unique id of the QualityLevel\n   * @param {number=}  representation.width     Resolution width of the QualityLevel\n   * @param {number=}  representation.height    Resolution height of the QualityLevel\n   * @param {number}   representation.bandwidth Bitrate of the QualityLevel\n   * @param {number=}  representation.frameRate Frame-rate of the QualityLevel\n   * @param {Function} representation.enabled   Callback to enable/disable QualityLevel\n   */\n  constructor(representation) {\n\n    let level = this; // eslint-disable-line\n\n    level.id = representation.id;\n    level.label = level.id;\n    level.width = representation.width;\n    level.height = representation.height;\n    level.bitrate = representation.bandwidth;\n    level.frameRate = representation.frameRate;\n    level.enabled_ = representation.enabled;\n\n    Object.defineProperty(level, 'enabled', {\n      /**\n       * Get whether the QualityLevel is enabled.\n       *\n       * @return {boolean} True if the QualityLevel is enabled.\n       */\n      get() {\n        return level.enabled_();\n      },\n\n      /**\n       * Enable or disable the QualityLevel.\n       *\n       * @param {boolean} enable true to enable QualityLevel, false to disable.\n       */\n      set(enable) {\n        level.enabled_(enable);\n      }\n    });\n\n    return level;\n  }\n}\n"
  },
  {
    "path": "test/plugin.test.js",
    "content": "import document from 'global/document';\nimport QUnit from 'qunit';\nimport sinon from 'sinon';\nimport videojs from 'video.js';\nimport plugin from '../src/plugin';\n\nconst Player = videojs.getComponent('Player');\n\nQUnit.test('the environment is sane', function(assert) {\n  assert.strictEqual(typeof Array.isArray, 'function', 'es5 exists');\n  assert.strictEqual(typeof sinon, 'object', 'sinon exists');\n  assert.strictEqual(typeof videojs, 'function', 'videojs exists');\n  assert.strictEqual(typeof plugin, 'function', 'plugin is a function');\n});\n\nQUnit.module('videojs-contrib-quality-levels', {\n\n  beforeEach() {\n\n    // Mock the environment's timers because certain things - particularly\n    // player readiness - are asynchronous in video.js 5. This MUST come\n    // before any player is created; otherwise, timers could get created\n    // with the actual timer methods!\n    this.clock = sinon.useFakeTimers();\n\n    this.fixture = document.getElementById('qunit-fixture');\n    this.video = document.createElement('video');\n    this.fixture.appendChild(this.video);\n    this.player = videojs(this.video);\n  },\n\n  afterEach() {\n    this.player.dispose();\n    this.clock.restore();\n  }\n});\n\nQUnit.test('registers itself with video.js', function(assert) {\n  assert.strictEqual(\n    typeof Player.prototype.qualityLevels,\n    'function',\n    'videojs-contrib-quality-levels plugin was registered'\n  );\n});\n\nQUnit.test('player qualityLevels method returns the proper object', function(assert) {\n  const qualityLevels = this.player.qualityLevels();\n\n  assert.equal(\n    qualityLevels.length,\n    0,\n    'the returned object contained the length property with the proper value'\n  );\n  assert.equal(\n    qualityLevels.selectedIndex,\n    -1,\n    'the returned object contained the selectedIndex property with the proper value'\n  );\n});\n"
  },
  {
    "path": "test/quality-level-list.test.js",
    "content": "import QUnit from 'qunit';\nimport QualityLevelList from '../src/quality-level-list';\nimport { representations } from './test-helpers';\n\nQUnit.module('QualityLevelList', {\n  beforeEach() {\n    this.qualityLevels = new QualityLevelList();\n    this.levels = representations;\n  }\n});\n\nQUnit.test('the QualityLevelList is iterable', function(assert) {\n  assert.ok(Symbol.iterator in this.qualityLevels, 'is iterable');\n});\n\nQUnit.test('Properly adds QualityLevels to the QualityLevelList', function(assert) {\n  let addCount = 0;\n\n  this.qualityLevels.on('addqualitylevel', (event) => {\n    addCount++;\n  });\n\n  const expected0 = this.qualityLevels.addQualityLevel(this.levels[0]);\n\n  assert.equal(this.qualityLevels.length, 1, 'added quality level');\n  assert.equal(addCount, 1, 'emmitted addqualitylevel event');\n  assert.strictEqual(this.qualityLevels[0], expected0, 'can access quality level with index');\n\n  const expected1 = this.qualityLevels.addQualityLevel(this.levels[1]);\n\n  assert.equal(this.qualityLevels.length, 2, 'added quality level');\n  assert.equal(addCount, 2, 'emmitted addqualitylevel event');\n  assert.strictEqual(this.qualityLevels[1], expected1, 'can access quality level with index');\n\n  const expectedDuplicate = this.qualityLevels.addQualityLevel(this.levels[0]);\n\n  assert.equal(this.qualityLevels.length, 2, 'does not add duplicate quality level');\n  assert.equal(addCount, 2, 'no event emitted on dulicate');\n  assert.strictEqual(this.qualityLevels[3], undefined, 'no index property defined');\n  assert.strictEqual(this.qualityLevels[0], expected0, 'quality level unchanged');\n  assert.strictEqual(this.qualityLevels[0], expectedDuplicate, 'adding duplicate returns same reference');\n  assert.strictEqual(this.qualityLevels[1], expected1, 'quality level unchanged');\n});\n\nQUnit.test('Properly removes QualityLevels from the QualityLevelList', function(assert) {\n  let removeCount = 0;\n  const expected = [];\n\n  this.levels.forEach((qualityLevel) => {\n    expected.push(this.qualityLevels.addQualityLevel(qualityLevel));\n  });\n\n  this.qualityLevels.on('removequalitylevel', (event) => {\n    removeCount++;\n  });\n\n  // Mock an initial selected quality level\n  this.qualityLevels.selectedIndex_ = 2;\n\n  assert.equal(this.qualityLevels.length, 4, '4 initial quality levels');\n\n  let removed = this.qualityLevels.removeQualityLevel(expected[3]);\n\n  assert.equal(this.qualityLevels.length, 3, 'removed quality level');\n  assert.equal(removeCount, 1, 'emitted removequalitylevel event');\n  assert.strictEqual(removed, expected[3], 'returned removed level');\n  assert.notStrictEqual(this.qualityLevels[3], expected[3], 'nothing at index');\n\n  removed = this.qualityLevels.removeQualityLevel(expected[1]);\n\n  assert.equal(this.qualityLevels.length, 2, 'removed quality level');\n  assert.equal(removeCount, 2, 'emitted removequalitylevel event');\n  assert.strictEqual(removed, expected[1], 'returned removed level');\n  assert.notStrictEqual(this.qualityLevels[1], expected[1], 'quality level not at index');\n  assert.strictEqual(\n    this.qualityLevels[this.qualityLevels.selectedIndex],\n    expected[2],\n    'selected index properly adjusted on quality level removal'\n  );\n\n  removed = this.qualityLevels.removeQualityLevel(expected[3]);\n\n  assert.equal(this.qualityLevels.length, 2, 'no quality level removed if not found');\n  assert.equal(removed, null, 'returned null when nothing removed');\n  assert.equal(removeCount, 2, 'no event emitted when quality level not found');\n\n  removed = this.qualityLevels.removeQualityLevel(expected[2]);\n\n  assert.equal(this.qualityLevels.length, 1, 'quality level removed');\n  assert.equal(removeCount, 3, 'emitted removequalitylevel event');\n  assert.strictEqual(removed, expected[2], 'returned removed level');\n  assert.equal(this.qualityLevels.selectedIndex, -1, 'selectedIndex set to -1 when removing selected quality level');\n});\n\nQUnit.test('can get quality level by id', function(assert) {\n  const expected = [];\n\n  this.levels.forEach((qualityLevel) => {\n    expected.push(this.qualityLevels.addQualityLevel(qualityLevel));\n  });\n\n  assert.strictEqual(\n    this.qualityLevels.getQualityLevelById('0'),\n    expected[0],\n    'found quality level with id \"0\"'\n  );\n  assert.strictEqual(\n    this.qualityLevels.getQualityLevelById('1'),\n    expected[1],\n    'found quality level with id \"1\"'\n  );\n  assert.strictEqual(\n    this.qualityLevels.getQualityLevelById('2'),\n    expected[2],\n    'found quality level with id \"2\"'\n  );\n  assert.strictEqual(\n    this.qualityLevels.getQualityLevelById('3'),\n    expected[3],\n    'found quality level with id \"3\"'\n  );\n  assert.strictEqual(\n    this.qualityLevels.getQualityLevelById('4'),\n    null,\n    'no quality level with id \"4\" found'\n  );\n});\n"
  },
  {
    "path": "test/test-helpers.js",
    "content": "export const representations = [\n  {\n    id: '0',\n    width: 100,\n    height: 100,\n    bandwidth: 100,\n    frameRate: 29.956,\n    enabled() {\n      return true;\n    }\n  },\n  {\n    id: '1',\n    width: 200,\n    height: 200,\n    bandwidth: 200,\n    frameRate: 29.956,\n    enabled() {\n      return true;\n    }\n  },\n  {\n    id: '2',\n    width: 300,\n    height: 300,\n    bandwidth: 300,\n    frameRate: 30,\n    enabled() {\n      return true;\n    }\n  },\n  {\n    id: '3',\n    width: 400,\n    height: 400,\n    bandwidth: 400,\n    frameRate: 60,\n    enabled() {\n      return true;\n    }\n  }\n];\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"include\": [\"src/**/*\"],\n  \"compilerOptions\": {\n    \"allowJs\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"declaration\": true,\n    \"emitDeclarationOnly\": true,\n    \"outDir\": \"dist/types\",\n    \"declarationMap\": true,\n    \"skipLibCheck\": true,\n    \"checkJs\": false,\n    \"preserveWatchOutput\": true\n  }\n}\n"
  }
]