swevans / unmute Goto Github PK
View Code? Open in Web Editor NEWEnables web audio playback with the ios mute switch on
License: MIT License
Enables web audio playback with the ios mute switch on
License: MIT License
Hi,
Thanks again for the great script, works great!
In the console I get TypeError: context.resume is not a function
on unmute.js:62:29
on every click / mousedown / touch. On the minified version as TypeError: i.resume is not a function
.
First off, thank you @swevans for this script. It's been super helpful for us. I'm running into a unique situation that I was hoping you might have some input on:
We have a native app that uses a wkwebview for an audio player that's driven by Web Audio. Unmute has enabled our users to hear the audio if their ringer is set to silent (again, thanks for that!). The interesting thing that's happening is when the app is put in the background -- We've set it to "allow" airplay and background playing (via tag.disableRemotePlayback
), but the result is a broken sounding audio file (check out the video below). It's such a unique combination of tech that I haven't been able to find anything on SO and since without Unmute the background audio doesn't work at all, I figured I'd see if you had any insight to offer.
Thanks!
Hello @swevans, and thank you for this script (and for your SO answers) which eventually got me unstuck on my project!
However, I'm finding that occasionally the audio is not resumed correctly when working on Chrome on my laptop. After some investigation I think the problem is here:
function pageStateCheck() {
if (isPageVisible && iosIsPageFocused) {
if (!isPageActive) {
isPageActive = true;
pageActivated();
}
}
else {
if (isPageActive) {
isPageActive = false;
pageDeactivated();
}
}
}
i.e. the first if condition will only be true if iosIsPageFocused is true - which looks questionable to me as that variable is clearly only relevant for ios. Of course it would be ok if that var just stayed true if we're not ios, but after much logging I find that it can become false (e.g. if the page is refreshed though its tab is not in the foreground).
So I think the fix would be something like the following:
function pageStateCheck() {
if (isPageVisible && (iosIsPageFocused || !isIOS)) {
if (!isPageActive) {
...
I'd really appreciate it if you were able to confirm this, or otherwise point me in the right direction.
Many thanks!
EDITED:
I was using the older script that doesn't mute on tab change...
maybe you should include this as an option I want my sound to never be muted at all.
OLD COMMENT:
Hi there, I was successfully using your unmute script it's really awesome, tough, it is not working on newest iPad 5th Gen with 15.2 Beta.
So what I did is I removed the condition to detect if it's iOS and it works like a charm. You might consider improving the iPad iOS detection here to make the script more compatible.
BIG THANKS (you can keep the pizza donation ... only if you buy a veg pizza!)
if (isIOS) { }
Man, you made my capacitor v3 / stenciljs music generation app able to work in silent mode.
On top of that when I use your other unmute-no-pause version I can add background mode.
I'll work on making WebAudio interact with native audio iOS control center and report here.
You saved many headaches and hours of useless work.
I'll buy you a pizza.
Just flagging this in case it's a regression. When I switch tabs the audio stops as expected. When I switch back, the audio does not automatically unmute, but it does resume when I tap the screen.
iOS Version 16.0.2
Hi again. I've been using this recently on a project, and noticed that there was uptick in requests to /null
on my server. From digging in the code, it looks like this is caused by destroyChannelTag()
. I can repro by creating an audio tag and setting it's src
to null
like in the code.
Lines 240 to 249 in 3c6b03e
It seems mostly harmless, but wanted to check if you've seen this, and if you had other ideas on workarounds to hide the playback controls.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.