How to use the ember-hifi/utils/mime-types.getMimeType function in ember-hifi

To help you get started, we’ve selected a few ember-hifi 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 nypublicradio / ember-hifi / tests / dummy / app / components / connection-display / component.js View on Github external
if (options.useConnections) {
        // If the consumer has specified a connection to prefer, use it
        let connectionNames  = options.useConnections;
        strategies = this.hifi._prepareStrategies(urlsToTry, connectionNames);
      }
      else if (this.hifi.get('isMobileDevice')) {
        // If we're on a mobile device, we want to try NativeAudio first
        strategies  = this.hifi._prepareMobileStrategies(urlsToTry);
      }
      else {
        strategies  = this.hifi._prepareStandardStrategies(urlsToTry);
      }

      let url = urlsToTry[0];

      let mimeType = typeof(url) === 'string' ?  getMimeType(url) : url.mimeType;

      let result = {
        url,
        title: get(options, 'metadata.title'),
        canPlay: this.connection.canPlay(url),
        mimeType: mimeType,
        canPlayMimeType: this.connection.canPlayMimeType(mimeType),
        canUseConnection: this.connection.canUseConnection(url),
        connectionName: this.connection.toString(),
      }

      loadPromise.then(({sound}) => {
        let results = getWithDefault(sound, 'metadata.debug.results', [])

        set(result, 'thisConnection',  this.connection.toString())
        set(result, 'connectionResult',  sound.connectionName)
github nypublicradio / ember-hifi / addon / hifi-connections / base.js View on Github external
canPlay(url) {
    let usablePlatform = this.canUseConnection(url);
    if (!usablePlatform) {
      return false;
    }
    if (typeof url === 'string') {
      let mimeType = getMimeType(url);
      if (!mimeType) {
        /* eslint-disable no-console */
        console.warn(`Could not determine mime type for ${url}`);
        console.warn('Attempting to play urls with an unknown mime type can be bad for performance. See documentation for more info.');
        /* eslint-enable no-console */
        return true;
      }
      else {
        return this.canPlayMimeType(mimeType);
      }
    }
    else if (url.mimeType) {
      return this.canPlayMimeType(url.mimeType);
    }
    else {
      throw new Error('URL must be a string or object with a mimeType property');