clappr / clappr-level-selector-plugin

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

bitrate -> label? #61

Open joshmn opened 6 years ago

joshmn commented 6 years ago

I see that there's only a way to go ID to label. Is there any chance for bitrate to label?

I may just end up adding this myself with a PR :)

leandromoreira commented 6 years ago

I think this would be an amazing contribution, although I think in most cases people really want a bitrate range to label but then we'd need to change the id/bitrate number to a function or something dynamic. I'd like to see @clappr/core ideas cc @vagnervjs

    labelsByRange: [
       {belongs: between(0, 120000): label: 'Low'},
       {belongs: between(120000, 240000): label: 'Mid'},
       {belongs: between(240000, 500000): label: 'High'},
    ],

Maybe I'm wrong about the most useful case. We also need to ensure that we're not doubling features (or at lease reuse or rethink the labelCallback)

joshmn commented 6 years ago

Most things with javascript are completely above my paygrade, so I ended up being a lazy bloke :)

levelSelectorConfig: {
    labelCallback: function(level, label) {
        return BITRATE_LABELS[level.level.bitrate / 1000]
    },
},