mirror of
https://github.com/kmoskwiak/videojs-resolution-switcher.git
synced 2025-10-03 09:49:21 +02:00
Only add sources if the type is supported by a Tech
There is not much use in adding sources that we cannot play, so filter them out. Backwards compatible with Tech's that do not yet support canPlayType(). Fixes #15
This commit is contained in:
parent
56760f6314
commit
d5aec7c6c6
1 changed files with 9 additions and 0 deletions
|
@ -178,6 +178,15 @@
|
||||||
player.controlBar.resolutionSwitcher.dispose();
|
player.controlBar.resolutionSwitcher.dispose();
|
||||||
delete player.controlBar.resolutionSwitcher;
|
delete player.controlBar.resolutionSwitcher;
|
||||||
}
|
}
|
||||||
|
// Only add those sources which we can (maybe) play
|
||||||
|
src = src.filter( function(source) {
|
||||||
|
try {
|
||||||
|
return ( player.canPlayType( source.type ) !== '' );
|
||||||
|
} catch (e) {
|
||||||
|
// If a Tech doesn't yet have canPlayType just add it
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
//Sort sources
|
//Sort sources
|
||||||
src = src.sort(compareResolutions);
|
src = src.sort(compareResolutions);
|
||||||
groupedSrc = bucketSources(src);
|
groupedSrc = bucketSources(src);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue