Package Exports
- audio-support-level
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (audio-support-level) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
audio-support-level.js
A client-side library to check if the given audio format is supported on the browser. It returns the compatibility level as a number (0 - 2).
// On Google Chrome
audioSupportLevel('aiff'); //=> 0
audioSupportLevel('mp4'); //=> 1
audioSupportLevel('mp4', 'mp4a.40.5'); //=> 2
audioSupportLevel({subtype: 'mp4', codecs: 'mp4a.40.5'}); //=> 2Installation
Install with package manager
npm
npm i --save audio-support-levelBower
bower i --save audio-support-levelComponent
component install shinnn/audio-support-level.jsInstall manually
Download the script file directly and install the dependency.
Dependency
AMD support
This repository includes the AMD-friendly build but the package managers doesn't include it. If you want to use it, download it and its dependency directly.
API
audioSupportLevel(subtype [, codecs])
subtype: String (e.g. 'ogg', 'mp3')
codecs: String (e.g. 'vorbis', 'mp4a.40.5')
Return: Number (0 - 2)
It evaluates .canPlayType() of an audio element, passing a MIME Type with the given subtype and codecs. Then it returns a number (0 - 2) according to the API of can-play-type-to-number.
// On Google Chrome
audioSupportLevel('ogg'); //=> 1
audioSupportLevel('ogg', 'vorbis'); //=> 2audioSupportLevel(options)
options: Object
Return: Number (0 - 2)
Instead of String, it can take an Object with subtype property (required) and codecs property (optional).
// On Google Chrome
audioSupportLevel({subtype: 'ogg'}); //=> 1
audioSupportLevel({subtype: 'ogg', codecs: 'vorbis'}); //=> 2License
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT LIcense.