JSPM

audio-support-level

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q28720F

Check if the given audio format is supported on the browser, and return the compatibility level as a number

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

Bower version NPM version Build Status Dependency Status devDependency Status

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'}); //=> 2

Installation

Install with package manager

npm

npm i --save audio-support-level

Bower

bower i --save audio-support-level

Component

component install shinnn/audio-support-level.js

Install 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'); //=> 2

audioSupportLevel(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'}); //=> 2

License

Copyright (c) 2014 Shinnosuke Watanabe

Licensed under the MIT LIcense.