How to use ember-hifi - 7 common examples

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');
github nypublicradio / ember-hifi / tests / helpers / ember-hifi-test-helpers.js View on Github external
let connectionSpy = test.stub(Connection, 'create').callsFake(function(options) {
    let sound = BaseSound.create(Object.assign({}, dummyOps, options));
    next(() => sound.trigger('audio-load-error'));
    return sound;
  });
github nypublicradio / ember-hifi / tests / helpers / ember-hifi-test-helpers.js View on Github external
let connectionSpy = test.stub(Connection, 'create').callsFake(function(options) {
    let sound = BaseSound.create(Object.assign({}, dummyOps, options));
    test.stub(sound, 'play').callsFake(() => sound.trigger('audio-played'));
    test.stub(sound, 'pause').callsFake(() => sound.trigger('audio-paused'));
    
    next(() => sound.trigger('audio-ready'));
    return sound;
  });
github nypublicradio / ember-hifi / tests / dummy / app / hifi-connections / local-dummy-connection.js View on Github external
import BaseSound from 'ember-hifi/hifi-connections/base';

export default BaseSound.extend({
  toString() {
    return 'Local Dummy Connection';
  },

  init           : function() {},
  willDestroy    : function() {},
  currentPosition: function() {},
  play           : function() {},
  pause          : function() {},
  _setVolume     : function() {}
});
github nypublicradio / ember-hifi / tests / dummy / app / components / event-display / component.js View on Github external
removeEvents: function(item) {
    EVENT_MAP.forEach(e => {
      item.off(e.event);
    });

    SERVICE_EVENT_MAP.forEach(e => {
      item.off(e.event);
    });
  },
github nypublicradio / ember-hifi / tests / dummy / app / components / event-display / component.js View on Github external
addServiceEvents: function(item) {
    this.addSoundEvents(item);

    SERVICE_EVENT_MAP.forEach(e => {
      item.on(e.event, (data) => {
        this.eventsList.pushObject({name: e.event, data: data, type: 'service'})
      });
    });
  },