From 12dcea4f709b522fe17f1c1cdf709070e67cf86f Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 27 Jan 2025 21:06:47 +0000 Subject: [PATCH] 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 --- copyparty/web/browser.js | 5 +++-- copyparty/web/util.js | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index a6529f2e..613a1c60 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -2579,16 +2579,17 @@ var mpl = (function () { var za, can_ogg = true, can_owa = false, - can_caf = IPHONE && !/ OS ([1-9]|1[01])_/.test(UA); + can_caf = APPLE && !/ OS ([1-9]|1[01])_/.test(UA); try { za = new Audio(); can_ogg = za.canPlayType('audio/ogg; codecs=opus') === 'probably'; can_owa = za.canPlayType('audio/webm; codecs=opus') === 'probably'; + can_caf = za.canPlayType('audio/x-caf') && can_caf; //'maybe' } catch (ex) { } 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; mpl.init_ac2(); diff --git a/copyparty/web/util.js b/copyparty/web/util.js index a267f0eb..81f972c3 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -37,7 +37,9 @@ var wah = '', IPHONE = TOUCH && /iPhone|iPad|iPod/i.test(UA), LINUX = /Linux/.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) window.WebAssembly = false; @@ -432,7 +434,7 @@ function import_js(url, cb, ecb) { function unsmart(txt) { - return !IPHONE ? txt : (txt. + return !APPLEM ? txt : (txt. replace(/[\u2014]/g, "--"). replace(/[\u2022]/g, "*"). replace(/[\u2018\u2019]/g, "'"). @@ -1357,7 +1359,7 @@ var tt = (function () { }; r.getmsg = function (el) { - if (IPHONE && QS('body.bbox-open')) + if (APPLEM && QS('body.bbox-open')) return; var cfg = sread('tooltips');