summaryrefslogtreecommitdiffstats
path: root/src/js/app.js
diff options
context:
space:
mode:
authorHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-10-07 13:18:06 +0200
committerLorenzo Tilve <ltilve@igalia.com>2020-02-04 09:42:15 +0100
commita16d4d0c1402472265a3a104fcafdf343177ea67 (patch)
tree78b3eb7658930b2366ca44cf72abe1c6c0f2a9d3 /src/js/app.js
parent9dfbec37d2c28f5850a0707c9a2717f4bcb5b6ce (diff)
FUNCT Integrate AGLJS library
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