X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;ds=sidebyside;f=main.js;h=fefb964e54b8974fe12f5949f18d0ed65f527881;hb=92ef863031eb48baaee057efda818d874ce31451;hp=c0436df50ddc4ad0faf2f6eb8a19d469e211ca8b;hpb=2ff2c6c19a379a1ea3ab25038fadb17cc9a104c4;p=chrome-ext%2Fmusic-player-client.git diff --git a/main.js b/main.js index c0436df..fefb964 100644 --- a/main.js +++ b/main.js @@ -79,6 +79,8 @@ function mpc_connect(host, port) { tcpclient.addResponseListener(tramp_mpc_recv); mpc = new Mpc(mpc_sender, update_ui); console.log('connected to ' + host + ':' + port); + console.log('protip: use the "mpc" object to poke mpd directly.\n' + + 'you can also do mpc.set_debug(3) to see traffic'); mpc_refresh(); update_refresh_timer(); }); @@ -193,7 +195,7 @@ function init_ui(local_keys, sync_keys, options) { 'seekcur', 'setvol', 'single', 'stop', ].forEach(function(id) { var ele = window['ui_mpc_' + id] = document.getElementById(id); - ele.onclick = window['tramp_mpc_' + id]; + ele.onchange = ele.onclick = window['tramp_mpc_' + id]; ele.title = id; }); @@ -235,8 +237,7 @@ function update_ui(state, cmd) { if ('file' in state) { // Hack: should be a real object. - ui_mpc_metadata.innerText = state['file']; - return; + ui_mpc_metadata.innerText = state.file; } var time; @@ -245,10 +246,14 @@ function update_ui(state, cmd) { time = state.time.split(':'); else time = [0, 0]; - window['ui_mpc_seekcur'].max = time[1]; - window['ui_mpc_seekcur'].value = time[0]; + window.ui_mpc_seekcur.max = time[1]; + window.ui_mpc_seekcur.value = time[0]; + percent = Math.floor((0.0 + time[0]) * 100 / (0.0 + time[1])); + window.ui_mpc_seekcur.title = 'seekcur (' + percent + '%)'; + + window.ui_mpc_setvol.value = state.volume; + window.ui_mpc_setvol.title = 'setvol (' + state.volume + '%)'; - window['ui_mpc_setvol'].value = state.volume; [ 'consume', 'random', 'repeat', 'single', ].forEach(function(id) {