improve iPad detection;

recent iPads do not indicate being an iPad in the user-agent,
so the audio-player would fall back on transcoding to mp3,
assuming the device cannot play opus-caf

improve this with pessimistic feature-detection for caf
hopefully still avoiding false-positives
This commit is contained in:
ed 2025-01-27 21:06:47 +00:00
parent b3b39bd8f1
commit 12dcea4f70
2 changed files with 8 additions and 5 deletions

View file

@ -2579,16 +2579,17 @@ var mpl = (function () {
var za, var za,
can_ogg = true, can_ogg = true,
can_owa = false, can_owa = false,
can_caf = IPHONE && !/ OS ([1-9]|1[01])_/.test(UA); can_caf = APPLE && !/ OS ([1-9]|1[01])_/.test(UA);
try { try {
za = new Audio(); za = new Audio();
can_ogg = za.canPlayType('audio/ogg; codecs=opus') === 'probably'; can_ogg = za.canPlayType('audio/ogg; codecs=opus') === 'probably';
can_owa = za.canPlayType('audio/webm; codecs=opus') === 'probably'; can_owa = za.canPlayType('audio/webm; codecs=opus') === 'probably';
can_caf = za.canPlayType('audio/x-caf') && can_caf; //'maybe'
} }
catch (ex) { } catch (ex) { }
za = null; za = null;
if (can_owa && IPHONE && / OS ([1-9]|1[0-7])_/.test(UA)) if (can_owa && APPLE && / OS ([1-9]|1[0-7])_/.test(UA))
can_owa = false; can_owa = false;
mpl.init_ac2(); mpl.init_ac2();

View file

@ -37,7 +37,9 @@ var wah = '',
IPHONE = TOUCH && /iPhone|iPad|iPod/i.test(UA), IPHONE = TOUCH && /iPhone|iPad|iPod/i.test(UA),
LINUX = /Linux/.test(UA), LINUX = /Linux/.test(UA),
MACOS = /Macintosh/.test(UA), MACOS = /Macintosh/.test(UA),
WINDOWS = /Windows/.test(UA); WINDOWS = /Windows/.test(UA),
APPLE = IPHONE || MACOS,
APPLEM = TOUCH && APPLE;
if (!window.WebAssembly || !WebAssembly.Memory) if (!window.WebAssembly || !WebAssembly.Memory)
window.WebAssembly = false; window.WebAssembly = false;
@ -432,7 +434,7 @@ function import_js(url, cb, ecb) {
function unsmart(txt) { function unsmart(txt) {
return !IPHONE ? txt : (txt. return !APPLEM ? txt : (txt.
replace(/[\u2014]/g, "--"). replace(/[\u2014]/g, "--").
replace(/[\u2022]/g, "*"). replace(/[\u2022]/g, "*").
replace(/[\u2018\u2019]/g, "'"). replace(/[\u2018\u2019]/g, "'").
@ -1357,7 +1359,7 @@ var tt = (function () {
}; };
r.getmsg = function (el) { r.getmsg = function (el) {
if (IPHONE && QS('body.bbox-open')) if (APPLEM && QS('body.bbox-open'))
return; return;
var cfg = sread('tooltips'); var cfg = sread('tooltips');