From 9986136dfb2364edb35aa9fbb87410641c6d6af3 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 31 Aug 2023 19:57:05 +0000 Subject: [PATCH] apple/ios/iphone: maybe fix background album playback good news: apple finally added support for samplerates other than 44100 for AudioContext, meaning it would now have been possible to set non-100% volume for audio files including opus files bad news: apple broke AudioContext in a way that makes it bug out mediaSessions, causing lockscreen controls to become mostly useless bad news: apple broke AudioContext additionally where it randomly causes playback issues, blocking playback of audio files, even if the AudioContext is sitting idle doing nothing (which is a requirement for reliable upload speeds on other platforms) disable AudioContext on iOS --- README.md | 5 +++-- copyparty/web/browser.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6522d8d0..fd1cea72 100644 --- a/README.md +++ b/README.md @@ -285,8 +285,7 @@ server notes: * Android: music playback randomly stops due to [battery usage settings](#fix-unreliable-playback-on-android) * iPhones: the volume control doesn't work because [apple doesn't want it to](https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW11) - * *future workaround:* enable the equalizer, make it all-zero, and set a negative boost to reduce the volume - * "future" because `AudioContext` can't maintain a stable playback speed in the current iOS version (15.7), maybe one day... + * `AudioContext` will probably never be a viable workaround as apple introduces new issues faster than they fix current ones * Windows: folders cannot be accessed if the name ends with `.` * python or windows bug @@ -721,6 +720,8 @@ can also boost the volume in general, or increase/decrease stereo width (like [c has the convenient side-effect of reducing the pause between songs, so gapless albums play better with the eq enabled (just make it flat) +not available on iPhones / iPads because AudioContext currently breaks background audio playback on iOS (15.7.8) + ### fix unreliable playback on android diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index c4080027..29cf1a22 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1299,7 +1299,8 @@ function set_files_html(html) { } -var ACtx = window.AudioContext || window.webkitAudioContext, +// actx breaks background album playback on ios +var ACtx = !IPHONE && (window.AudioContext || window.webkitAudioContext), noih = /[?&]v\b/.exec('' + location), hash0 = location.hash, mp;