{"_id":"videojs-resolution-switcher-vjs7","_rev":"1-fabead6b4488af75377f0d204b9b1fc7","name":"videojs-resolution-switcher-vjs7","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"videojs-resolution-switcher-vjs7","version":"1.0.0","description":"VideoJS Resolution Switcher for VideoJS Version 7+ Modified by Bari Artz from Poko for you using VideoJS Version 7+. For you using videojs resolution switcher from original script by kmoskwiak on Github but do not appear in VideoJS version 7+, you can usi","main":"index.js","keywords":["npm","npm-videojs-resolution-switcher"],"author":{"name":"Bari Artz from Poko"},"license":"ISC","_id":"videojs-resolution-switcher-vjs7@1.0.0","_nodeVersion":"12.16.3","_npmVersion":"6.14.4","dist":{"integrity":"sha512-BowDOEJ63lJKThw9WlxAP86vNwjRWsLjYkelJ01wIuFHNLlyJghstfs8U9QZwT5b3Fevbg+cHUVxtvlB9J4s4w==","shasum":"9a3d00f26ba3a9fded00a526d8be16835085f301","tarball":"https://registry.npmjs.org/videojs-resolution-switcher-vjs7/-/videojs-resolution-switcher-vjs7-1.0.0.tgz","fileCount":5,"unpackedSize":21545,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfEzU4CRA9TVsSAnZWagAAoWcP/2nJDZRG3gOo6mSF8zK6\nxeUZch2M3qAJH5h+6em+2Pyw3WC/RozsduX3eyTTwLlrBfQz4wi6sdQ0uFhh\n7guEbiU4xqLE+TTjE2QQ+vG9TsTUJpPG7Qp+QPx5QYwCW1FZrRNTeJ5i/apf\nkpHaqEfwy/3bGWZmV8MEAxSmf0Q0x+yKMZmtXzs9SgiFz+XqFFPxA5VUnJCx\nR+m8UxhZFFIXv71ZLiT7BRYzh4ganXliYLuetEJEsSYmLeo+VGNBYT+swjwc\nLGjJtdKtxsWCRkiChSaSMmWtPQlRAXGHY7iASPTmgbYgPBcy7lDDI0J0SJhG\ndkwgXNTDiqhIeupjvSGPQdth5PTa+FHxnW0yZ/bVxsk6mEGQJafGp/Q9Cmvi\nkKvHw03LcL/2D/A41B9CSY8l8ymIeL5wa+za5OcnYX9F5/oKVmP92hM80u0b\njZfiP7GkJxEMt+wnQGGtzGNxGgwNKuBlmkjXKbdMf/7wNC75CHXxE+Sid6bk\nevEW5H03kOucNQLxBiplyc6GDDjlAD6pB3jJPP4HKn6+W+/YGqCyTefPUx1u\nQLJ3R8ex+rJ1obitRo6VaoX5BLnz1SlSrbo565S+YADnTcsQU3Jkwbd1tZsB\n1mqaodnfjDtpWg2U1/pkXBsIK3UlBvAqTYqPrYVxuUcSRmSyhIs5bJ0zu1rX\nSdfh\r\n=QRd+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDWSecyUe9BJIrBMaD6MKTbax+Jit+i0u1oHnHwxh4t6wIhAKTfqWmuwkctcXrZdTezkkG/AbmTQGCL2ACRTzMAuTls"}]},"maintainers":[{"name":"bariarts","email":"blomenid@gmail.com"}],"_npmUser":{"name":"bariarts","email":"blomenid@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/videojs-resolution-switcher-vjs7_1.0.0_1595094327783_0.3964238251615848"},"_hasShrinkwrap":false}},"time":{"created":"2020-07-18T17:45:27.783Z","1.0.0":"2020-07-18T17:45:27.928Z","modified":"2022-05-23T06:37:51.932Z"},"maintainers":[{"name":"bariarts","email":"blomenid@gmail.com"}],"description":"VideoJS Resolution Switcher for VideoJS Version 7+ Modified by Bari Artz from Poko for you using VideoJS Version 7+. For you using videojs resolution switcher from original script by kmoskwiak on Github but do not appear in VideoJS version 7+, you can usi","keywords":["npm","npm-videojs-resolution-switcher"],"author":{"name":"Bari Artz from Poko"},"license":"ISC","readme":"# Video.js Resolution Switcher for VideoJS Version 7+\n[Original script](https://travis-ci.org/kmoskwiak/videojs-resolution-switcher)\n\nModified by Bari Artz from [Poko](https://facebook.com/pokonimeii) \n\nResolution switcher for [video.js v7+](https://github.com/videojs/video.js)\n\n## Example\n\nCheck out this [demo](http://bariartz.github.io/videojs-by-pp).\n\n## Getting Started\n\nGet plugin from this Github.\n\n\n### Setup sources dynamically:\n\n```html\n<video id='video' class=\"video-js vjs-default-skin\"></video>\n<script src=\"video.js\"></script>\n<script src=\"videojs-resolution-switcher.js\"></script>\n<script>\n  videojs('video', {\n    controls: true,\n    plugins: {\n        videoJsResolutionSwitcher: {\n          default: 'high',\n          dynamicLabel: true\n        }\n      }\n  }, function(){\n  \n    // Add dynamically sources via updateSrc method\n    player.updateSrc([\n        {\n          src: 'http://media.xiph.org/mango/tears_of_steel_1080p.webm',\n          type: 'video/webm',\n          label: '360'\n        },\n        {\n          src: 'http://mirrorblender.top-ix.org/movies/sintel-1024-surround.mp4',\n          type: 'video/mp4',\n          label: '720'\n        }\n      ])\n\n      player.on('resolutionchange', function(){\n        console.info('Source changed to %s', player.src())\n      })\n      \n  })\n</script>\n```\n\n### Or use `<source>` tags:\n\n```html\n\n<video id=\"video\" class=\"video-js vjs-default-skin\" width=\"1000\" controls data-setup='{}'>\n   <source src=\"http://mirrorblender.top-ix.org/movies/sintel-1024-surround.mp4\" type='video/mp4' label='SD' />\n   <source src=\"http://media.xiph.org/mango/tears_of_steel_1080p.webm\" type='video/webm' label='HD'/>\n</video>\n<script>\n  videojs('video').videoJsResolutionSwitcher()\n</script>\n\n```\n\n\n### YouTube tech\n\nYouTube tech form https://github.com/eXon/videojs-youtube\n\n```html\n<video id='video' class=\"video-js vjs-default-skin\"></video>\n<script src=\"../lib/videojs-resolution-switcher.js\"></script>\n<script>\n\tvideojs('video', {\n\t\tcontrols: true,\n\t\ttechOrder:  [\"youtube\"],\n\t\tsources: [{ \"type\": \"video/youtube\", \"src\": \"https://www.youtube.com/watch?v=iD_MyDbP_ZE\"}],\n\t\tplugins: {\n\t\t\tvideoJsResolutionSwitcher: {\n\t\t\t\tdefault: 'low',\n\t\t\t\tdynamicLabel: true\n\t\t\t}\n\t\t}\n\t}, function(){\n\t\tvar player = this;\n\t\tplayer.on('resolutionchange', function(){\n\t\t\tconsole.info('Source changed')\n\t\t})\n\t});\n\n</script>\n\n```\n\n### Flash tech\n\nWhen using flash tech `preload=\"auto\"` is required.\n\n## Source options\n\nSources can passed to player using `updateSrc` method or `<source>` tag as shown above. Avalible options for each source are:\n* label - `String` (required) is shown in menu (ex. 'SD' or '360p')\n* res - `Number` is resolution of video used for sorting (ex. 360 or 1080)\n\n## Plugin options\n\nYou can pass options to plugin like this:\n\n```javascript\n\nvideojs('video', {\n      controls: true,\n      muted: true,\n      width: 1000,\n      plugins: {\n        videoJsResolutionSwitcher: {\n          default: 'low'\n        }\n      }\n    }, function(){\n      // this is player\n    })\n```\n### Avalible options:\n* default - `{Number}|'low'|'high'` - default resolution. If any `Number` is passed plugin will try to choose source based on `res` parameter. If `low` or `high` is passed, plugin will choose respectively worse or best resolution (if `res` parameter is specified). If `res` parameter is not specified plugin assumes that sources array is sorted from best to worse.\n* dynamicLabel - `{Boolean}` - if `true` current label will be displayed in control bar. By default gear icon is displayed.\n* customSourcePicker - `{Function}` - custom function for selecting source.\n* ui - `{Boolean}` - If set to `false` button will not be displayed in control bar. Default is `true`.\n\n\n## Methods\n\n\n### updateSrc([source])\nReturns video.js player object if used as setter. If `source` is not passed it acts like [player.src()](http://docs.videojs.com/docs/api/player.html#Methodssrc)\n```javascript\n\n// Update video sources\nplayer.updateSrc([\n  { type: \"video/mp4\", src: \"http://www.example.com/path/to/video.mp4\", label: 'SD' },\n  { type: \"video/mp4\", src: \"http://www.example.com/path/to/video.mp4\", label: 'HD' },\n  { type: \"video/mp4\", src: \"http://www.example.com/path/to/video.mp4\", label: '4k' }\n])\n\n```\n#### PARAMETERS:\n| name | type | required | description |\n|:----:|:----:|:--------:|:-----------:|\n| source| array| no | array of sources |\n\n### currentResolution([label], [customSourcePicker])\nIf used as getter returns current resolution object:\n```javascript\n  {\n    label: 'SD', // current label\n    sources: [\n      { type: \"video/webm\", src: \"http://www.example.com/path/to/video.webm\", label: 'SD' },\n      { type: \"video/mp4\", src: \"http://www.example.com/path/to/video.mp4\", label: 'SD' }\n    ] // array of sources with current label\n  }\n```\n\nIf used as setter returns video.js player object.\n\n\n```javascript\n\n// Get current resolution\nplayer.currentResolution(); // returns object {label '', sources: []}\n\n// Set resolution\nplayer.currentResolution('SD'); // returns videojs player object\n```\n#### PARAMETERS:\n| name | type | required | description |\n|:----:|:----:|:--------:|:-----------:|\n| label| string| no | label name |\n| customSourcePicker | function | no | cutom function to choose source |\n\n#### customSourcePicker\nIf there is more than one source with the same label, player will choose source automatically. This behavior can be changed if `customSourcePicker` is passed.\n\n`customSourcePicker` must return `player` object.\n```javascript\nplayer.currentResolution('SD', function(_player, _sources, _label){\n  return _player.src(_sources[0]); \\\\ Always select first source in array\n});\n```\n`customSourcePicker` accepst 3 arguments.\n\n| name | type | required | description |\n|:----:|:----:|:--------:|:-----------:|\n| player| Object | yes | videojs player object |\n| sources | Array | no | array of sources |\n| label | String | no | name of label |\n\n`customSourcePicker` may be passed in options when player is initialized:\n```javascript\n\nvar myCustomSrcPicker = function(_p, _s, _l){\n  // select any source you want\n  return _p.src(selectedSource);\n}\n\nvideojs('video', {\n      controls: true,\n      muted: true,\n      width: 1000,\n      plugins: {\n        videoJsResolutionSwitcher: {\n          default: 'low',\n          customSourcePicker: myCustomSrcPicker\n        }\n      }\n    }, function(){\n      // this is player\n    })\n```\n\n\n### getGroupedSrc()\nReturns sources grouped by label, resolution and type.\n\n\n## Events\n\n### resolutionchange `EVENT`\n\n> Fired when resolution is changed\n","readmeFilename":"README.md"}