ember-cli-ambienx v1.0.5
ember-cli-ambienx
This README outlines the details of collaborating on this Ember addon.
Installation
git clonethis repositorynpm installbower install
Running
ember server- Visit your app at http://localhost:4200.
Running Tests
npm test(Runsember try:testallto test your addon against multiple Ember versions)ember testember test --server
Building
ember build
For more information on using ember-cli, visit http://ember-cli.com/.
This is Ember addon provides a wrapper for Ambienx.js. Use some background music to give your website or webapp some ambience.
Installation
ember install ember-cli-ambienx
// or
npm install ember-cli-bg-music --save
// or
yarn add ember-cli-bg-musicAfter installing the Ember-Cli-Ambienx npm package, the addon will automatically install the bower package for Ambienx.js. Before the addon can work, in your ember-cli-build.js file you will have to import Ambienx.js like this:
app.import('bower_components/ambienx/ambienx.js');Setup
In your Ember app's config/environment.js file, define a property called ambienx. It accepts an object with key/values that correspond to all the options available in Ambienx.js.
For example:
// config/environment.js
ambienx: {
audioSrc: 'music.mp3',
audioLoop: true,
autoplay: false,
enabledLoseFocus: true
}Likewise, all Ambienx.js methods are provided via a service called serviceAmbienx. This service by default is injected into all your components. If you want to use the playAudio() method, you can do so like this:
this.get('serviceAmbienx').playAudio();Alternative Setup
But you also have an option to initialize Ambienx.js outside the environment.js file. All you need to do is access the Ember-Cli-Ambienx service and store the Ambienx.js initialization in the newAmbienx property.
For example you can initialize Ambienx.js in an instance initializer called audio.js:
let serviceAmbienx = appInstance.lookup('service:service-ambienx');
let newAmbienx = new Ambienx({
audioSrc: 'music.mp3',
audioLoop: true,
autoplay: false,
enabledLoseFocus: true
});
serviceAmbienx.newAmbienx = newAmbienx;