Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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');
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;
});
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;
});
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() {}
});
removeEvents: function(item) {
EVENT_MAP.forEach(e => {
item.off(e.event);
});
SERVICE_EVENT_MAP.forEach(e => {
item.off(e.event);
});
},
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'})
});
});
},