How to use the howler.Howler._codecs function in howler

To help you get started, we’ve selected a few howler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bluedaniel / Kakapo-app / app / scripts / utils / validHowl.js View on Github external
import { Howler } from 'howler';
import path from 'path';

const codecs = Howler._codecs;
const testCodecs = [ 'mp3', 'opus', 'ogg', 'wav', 'aac', 'm4a', 'mp4', 'weba' ];

const supported = codecs.length ? Object.keys(codecs) : testCodecs;

export default function validHowl(url, msg) {
  const ext = path.extname(url).substring(1);
  const valid = supported.indexOf(ext) !== -1;

  return msg && !valid ? `File is ${ext}, but must be one of ${supported.join(', ')}` : valid;
}