dodge android-chrome bug: canvas aspect ratio

This commit is contained in:
ed 2021-06-18 21:46:15 +02:00
parent 98aaab02c5
commit c50f1b64e5
3 changed files with 27 additions and 16 deletions

View file

@ -172,7 +172,7 @@ class HttpConn(object):
self.log("client rejected our certificate (nice)") self.log("client rejected our certificate (nice)")
elif "ALERT_CERTIFICATE_UNKNOWN" in em: elif "ALERT_CERTIFICATE_UNKNOWN" in em:
# chrome-android keeps doing this # android-chrome keeps doing this
pass pass
else: else:

View file

@ -298,7 +298,7 @@ var pbar = (function () {
gradh = -1, gradh = -1,
grad; grad;
function onresize() { r.onresize = function () {
r.buf = canvas_cfg(ebi('barbuf')); r.buf = canvas_cfg(ebi('barbuf'));
r.pos = canvas_cfg(ebi('barpos')); r.pos = canvas_cfg(ebi('barpos'));
r.drawbuf(); r.drawbuf();
@ -372,8 +372,8 @@ var pbar = (function () {
pctx.fillText(t2, xt2, yt); pctx.fillText(t2, xt2, yt);
}; };
window.addEventListener('resize', onresize); window.addEventListener('resize', r.onresize);
onresize(); r.onresize();
return r; return r;
})(); })();
@ -384,7 +384,7 @@ var vbar = (function () {
gradh = -1, gradh = -1,
can, ctx, w, h, grad1, grad2; can, ctx, w, h, grad1, grad2;
function onresize() { r.onresize = function () {
r.can = canvas_cfg(ebi('pvol')); r.can = canvas_cfg(ebi('pvol'));
can = r.can.can; can = r.can.can;
ctx = r.can.ctx; ctx = r.can.ctx;
@ -403,8 +403,8 @@ var vbar = (function () {
ctx.fillStyle = grad2; ctx.fillRect(0, 0, w, h); ctx.fillStyle = grad2; ctx.fillRect(0, 0, w, h);
ctx.fillStyle = grad1; ctx.fillRect(0, 0, w * mp.vol, h); ctx.fillStyle = grad1; ctx.fillRect(0, 0, w * mp.vol, h);
}; };
window.addEventListener('resize', onresize); window.addEventListener('resize', r.onresize);
onresize(); r.onresize();
var rect; var rect;
function mousedown(e) { function mousedown(e) {
@ -542,14 +542,23 @@ var mpui = (function () {
// indicate playback state in ui // indicate playback state in ui
widget.paused(mp.au.paused); widget.paused(mp.au.paused);
if (++nth > 69) {
// android-chrome breaks aspect ratio with unannounced viewport changes
nth = 0;
if (is_touch) {
nth = 1;
pbar.onresize();
vbar.onresize();
}
}
else {
// draw current position in song // draw current position in song
if (!mp.au.paused) if (!mp.au.paused)
pbar.drawpos(); pbar.drawpos();
// occasionally draw buffered regions // occasionally draw buffered regions
if (++nth == 5) { if (++nth % 5 == 0)
pbar.drawbuf(); pbar.drawbuf();
nth = 0;
} }
// preload next song // preload next song
@ -820,7 +829,7 @@ var audio_eq = (function () {
// plays the tid'th audio file on the page // plays the tid'th audio file on the page
function play(tid, seek, call_depth) { function play(tid, seek, call_depth) {
if (mp.order.length == 0) if (mp.order.length == 0)
return alert('no audio found wait what'); return console.log('no audio found wait what');
var tn = tid; var tn = tid;
if ((tn + '').indexOf('f-') === 0) if ((tn + '').indexOf('f-') === 0)
@ -1087,6 +1096,8 @@ var thegrid = (function () {
lfiles.style.display = ''; lfiles.style.display = '';
gfiles.style.display = 'none'; gfiles.style.display = 'none';
} }
pbar.onresize();
vbar.onresize();
}; };
var btnclick = function (e) { var btnclick = function (e) {

View file

@ -6,7 +6,7 @@ if (!window['console'])
}; };
var clickev = window.Touch ? 'touchstart' : 'click', var is_touch = 'ontouchstart' in window,
ANDROID = /(android)/i.test(navigator.userAgent); ANDROID = /(android)/i.test(navigator.userAgent);