summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-04 22:19:28 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-04 22:19:28 +0200
commit983d576e1cc2359505fa4fc0c0c689ec65c99e86 (patch)
treef714294cf35f1169825a62c53d44327341bbf10c /packages
parent01c4db74f3f234373a3e97da9cdc1bd8458a9f8b (diff)
downloadmeshbay-983d576e1cc2359505fa4fc0c0c689ec65c99e86.tar.gz
fix(android): music player starts on its own and no longer shows autoplay refusals
WebView now allows play() after the track fetch; a NotAllowedError leaves the track waiting for the play button instead of raising an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages')
-rw-r--r--packages/meshbay-android/app/src/main/kotlin/org/meshbay/client/MainActivity.kt4
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/music-player.js5
2 files changed, 7 insertions, 2 deletions
diff --git a/packages/meshbay-android/app/src/main/kotlin/org/meshbay/client/MainActivity.kt b/packages/meshbay-android/app/src/main/kotlin/org/meshbay/client/MainActivity.kt
index a781350..ea31bca 100644
--- a/packages/meshbay-android/app/src/main/kotlin/org/meshbay/client/MainActivity.kt
+++ b/packages/meshbay-android/app/src/main/kotlin/org/meshbay/client/MainActivity.kt
@@ -98,7 +98,9 @@ class MainActivity : Activity() {
domStorageEnabled = true // IndexedDB and localStorage: session, resume positions
allowFileAccess = false
allowContentAccess = false
- mediaPlaybackRequiresUserGesture = true
+ // The page is our own bundled UI. With `true`, WebView wants play() inside the tap
+ // handler itself, and the music player only calls it after fetching the track.
+ mediaPlaybackRequiresUserGesture = false
setSupportMultipleWindows(false)
mixedContentMode = android.webkit.WebSettings.MIXED_CONTENT_NEVER_ALLOW
}
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/music-player.js b/packages/meshbay-hub/src/meshbay_hub/static/music-player.js
index e8124fa..154d761 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/music-player.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/music-player.js
@@ -459,6 +459,9 @@ function MusicPlayerBar({ getConnection, queue, onClose, userPrefs, onSaveQueue
prefetchNext(pos);
} catch (err) {
if (loadTokenRef.current !== myToken) return;
+ // Autoplay refused (no recent tap): the track is loaded and fine, it
+ // waits for the play button. Not an error, and no reason to skip it.
+ if (err && err.name === 'NotAllowedError') { setPlaying(false); prefetchNext(pos); return; }
setError(err.message || String(err));
setPlaying(false);
// `fetchTrackBlob` throws `err_transport` when no node answered for
@@ -524,7 +527,7 @@ function MusicPlayerBar({ getConnection, queue, onClose, userPrefs, onSaveQueue
const audio = audioRef.current;
if (!audio) return;
if (playing) { audio.pause(); setPlaying(false); }
- else { audio.play().then(() => setPlaying(true)).catch(() => {}); }
+ else { audio.play().then(() => { setError(''); setPlaying(true); }).catch(() => {}); }
}, [playing]);
// Reshuffling keeps the currently playing track in place — turning shuffle