aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/app.js')
-rw-r--r--src/js/app.js32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/js/app.js b/src/js/app.js
index 773e5b0..3b8ae97 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -1,5 +1,6 @@
import Mustache from 'mustache';
-import { init as init_sliders } from './sliders';
+import { audiomixer } from 'agl-js-api';
+import { setValue } from './sliders';
var template;
@@ -15,15 +16,24 @@ export function init() {
template = document.getElementById('slider-template').innerHTML;
Mustache.parse(template);
- var sliders = [];
- for( var i=0; i<10; i++) {
- sliders.push({
- id: i,
- name: 'Volume '+i,
- value: Math.floor(Math.random()*100)
- });
- }
+ audiomixer.list_controls().then(function(result) {
+ var sliders = [];
+ for( var i=0; i<result.length; i++) {
+ sliders.push({
+ id: result[i].control,
+ name: result[i].control,
+ value: Math.floor(result[i].volume*100)
+ });
+ }
+
+ render_sliders(sliders);
+ }).catch(function(error) {
+ console.error('ERROR loading sliders', error);
+ });
- init_sliders(sliders);
- render_sliders(sliders);
+ audiomixer.on_volume_changed(function(data){
+ setValue(document.getElementById("slider-"+data.control), Math.ceil(data.value*100), true);
+ }).then(function(result) {
+ console.log("SUBSCRIBED TO VOLUME CHANGED");
+ });
} \ No newline at end of file