clappr / clappr-level-selector-plugin

Clappr Level Selector Plugin
MIT License
76 stars 56 forks source link

FR: add possibility to invert resolutions #84

Closed Niko78 closed 4 years ago

Niko78 commented 4 years ago

hi, Right now the plugin displays values from bottom to top That would be interesting to get values inverted : Quality AUTO 1080p 720p 360p

instead of Quality AUTO 360p 720p 1080p

thanks

Nico

kslimani commented 4 years ago

I think it is easy to solve, for example adding a new onLevelsAvailable configuration option which accept a "transform" function as value.

Usage example :

var player = new Clappr.Player({
  // [...]
  levelSelectorConfig: {
    onLevelsAvailable: function(levels) {
      // here do whatever you want (filter, sort, etc...)
      return levels
    },
  },
});

@Niko78 : using the previous example, to solve your issue, simply return return levels.reverse()

@leandromoreira want me to add this feature to #83 or do you prefer i open another pr ?

leandromoreira commented 4 years ago

i think you can mix them togheter