mirror of
https://github.com/kmoskwiak/videojs-resolution-switcher.git
synced 2025-10-03 09:49:21 +02:00
groupedSrc method, Readme
This commit is contained in:
parent
7250a1dcee
commit
0c390b3f2e
2 changed files with 50 additions and 1 deletions
47
README.md
47
README.md
|
@ -127,7 +127,7 @@ player.updateSrc([
|
||||||
|:----:|:----:|:--------:|:-----------:|
|
|:----:|:----:|:--------:|:-----------:|
|
||||||
| source| array| no | array of sources |
|
| source| array| no | array of sources |
|
||||||
|
|
||||||
### currentResolution([label])
|
### currentResolution([label], [customSourcePicker])
|
||||||
If used as getter returns current resolution object:
|
If used as getter returns current resolution object:
|
||||||
```javascript
|
```javascript
|
||||||
{
|
{
|
||||||
|
@ -154,6 +154,51 @@ player.currentResolution('SD'); // returns videojs player object
|
||||||
| name | type | required | description |
|
| name | type | required | description |
|
||||||
|:----:|:----:|:--------:|:-----------:|
|
|:----:|:----:|:--------:|:-----------:|
|
||||||
| label| string| no | label name |
|
| label| string| no | label name |
|
||||||
|
| customSourcePicker | function | no | cutom function to choose source |
|
||||||
|
|
||||||
|
#### customSourcePicker
|
||||||
|
If there is more than one source with the same label, player will choose source automatically. This behavior can be changed if `customSourcePicker` is passed.
|
||||||
|
|
||||||
|
`customSourcePicker` must return `player` object.
|
||||||
|
```javascript
|
||||||
|
player.currentResolution('SD', function(_player, _sources, _label){
|
||||||
|
return _player.src(_sources[0]); \\ Always select first source in array
|
||||||
|
});
|
||||||
|
```
|
||||||
|
`customSourcePicker` accepst 3 arguments.
|
||||||
|
|
||||||
|
| name | type | required | description |
|
||||||
|
|:----:|:----:|:--------:|:-----------:|
|
||||||
|
| palyer| Object | yes | videojs player object |
|
||||||
|
| sources | Array | no | array of sources |
|
||||||
|
| label | String | no | name of label |
|
||||||
|
|
||||||
|
`customSourcePicker` may be passed in options when player is initialized:
|
||||||
|
```javascript
|
||||||
|
|
||||||
|
var myCustomSrcPicker = function(_p, _s, _l){
|
||||||
|
// select any source you want
|
||||||
|
return _p.src(selectedSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
videojs('video', {
|
||||||
|
controls: true,
|
||||||
|
muted: true,
|
||||||
|
width: 1000,
|
||||||
|
plugins: {
|
||||||
|
videoJsResolutionSwitcher: {
|
||||||
|
default: 'low',
|
||||||
|
customSourcePicker: myCustomSrcPicker
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function(){
|
||||||
|
// this is player
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### getGroupedSrc()
|
||||||
|
Returns sources grouped by label, resolution and type.
|
||||||
|
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
|
@ -195,6 +195,10 @@
|
||||||
return player;
|
return player;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns grouped sources by label, resolution and type
|
||||||
|
* @returns {Object} grouped sources: { label: { key: [] }, res: { key: [] }, type: { key: [] } }
|
||||||
|
*/
|
||||||
player.getGroupedSrc = function(){
|
player.getGroupedSrc = function(){
|
||||||
return groupedSrc;
|
return groupedSrc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue