X-Git-Url: https://git.wh0rd.org/?p=chrome-ext%2Fmusic-player-client.git;a=blobdiff_plain;f=main.js;h=fefb964e54b8974fe12f5949f18d0ed65f527881;hp=b9d188deced4318cfd565942404e11cadabc3b32;hb=d4a26e736741a0a75acc6742d075d1cf7a11a44c;hpb=ea13f13a1c11e84f8de064bba91b6aa331a18007 diff --git a/main.js b/main.js index b9d188d..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(); }); @@ -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) {