fix: restore iOS background play by detecting iOS before UA spoof
This commit is contained in:
parent
152beda73b
commit
0d1910285c
3 changed files with 9 additions and 4 deletions
|
|
@ -2,6 +2,10 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<script>
|
||||
// Capture real iOS state before spoofing (needed for background audio)
|
||||
var _ua = navigator.userAgent.toLowerCase();
|
||||
window.__IS_IOS__ = /iphone|ipad|ipod/.test(_ua) || (_ua.includes('mac') && navigator.maxTouchPoints > 1);
|
||||
|
||||
// Spoof User-Agent to bypass Google's embedded browser check
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
get: function () {
|
||||
|
|
|
|||
|
|
@ -234,8 +234,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
const audioPlayer = document.getElementById('audio-player');
|
||||
|
||||
// i love ios and macos!!!! webkit fucking SUCKS BULLSHIT sorry ios/macos heads yall getting lossless only
|
||||
// Use window.__IS_IOS__ (set before UA spoof in index.html) so detection works on real iOS.
|
||||
const isIOS = typeof window !== 'undefined' && window.__IS_IOS__ === true;
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
const isIOS = /iphone|ipad|ipod/.test(ua) || (ua.includes('mac') && navigator.maxTouchPoints > 1);
|
||||
const isSafari =
|
||||
ua.includes('safari') && !ua.includes('chrome') && !ua.includes('crios') && !ua.includes('android');
|
||||
|
||||
|
|
|
|||
|
|
@ -137,9 +137,9 @@ class AudioContextManager {
|
|||
|
||||
// Detect iOS - skip Web Audio initialization on iOS to avoid lock screen audio issues
|
||||
// iOS suspends AudioContext when screen locks, and MediaSession controls don't count
|
||||
// as user gestures to resume it, causing audio to play silently
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
const isIOS = /iphone|ipad|ipod/.test(ua) || (ua.includes('mac') && navigator.maxTouchPoints > 1);
|
||||
// as user gestures to resume it, causing audio to play silently.
|
||||
// Use window.__IS_IOS__ (set before UA spoof in index.html) so detection works on real iOS.
|
||||
const isIOS = typeof window !== 'undefined' && window.__IS_IOS__ === true;
|
||||
if (isIOS) {
|
||||
console.log('[AudioContext] Skipping Web Audio initialization on iOS for lock screen compatibility');
|
||||
// Don't set isInitialized - let it remain false so isReady() returns false
|
||||
|
|
|
|||
Loading…
Reference in a new issue