Skip to content

Instantly share code, notes, and snippets.

@paulgoetze
Forked from matthias-k/controllers.application.js
Last active October 29, 2019 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paulgoetze/643ece6b7ae03968ee8732522f21a87c to your computer and use it in GitHub Desktop.
Save paulgoetze/643ece6b7ae03968ee8732522f21a87c to your computer and use it in GitHub Desktop.
Ember with WQXR
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
hifi: Ember.inject.service(),
actions: {
play() {
const url = "https://stream.wqxr.org/wqxr";
const mimeType = 'audio/mpeg';
this.get('hifi').play([{url, mimeType}]).then(({sound}) => {
console.log("sound", sound);
}).catch(error => {
console.log("error", error);
})
},
},
});
<h1>Welcome to {{appName}} year!</h1>
<audio id="single-song" preload="none" controls="controls">
<source src="https://stream.wqxr.org/wqxr" type="audio/mpeg" id="single-song"/>
Your browser does not support the audio tag.
</audio>
<br>
{{hifi}}
<br>
<button {{action "play"}}>Play</button>
foo
{{outlet}}
<br>
<br>
{
"version": "0.15.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.4.3",
"ember-template-compiler": "3.4.3",
"ember-testing": "3.4.3"
},
"addons": {
"ember-data": "3.4.2",
"ember-hifi": "1.16.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment