Comments (5)
Some initial findings:
- You can start chrome with a flag to enable the new autoplay policy like this:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-features=AutoplayIgnoreWebAudio
- Scratch's ability to play sound is almost completely unaffected as far as I can tell, because you almost always have clicked on something (such as the green flag or a sprite) before sound needs to play, and at that point it is allowed to play.
- A keypress by itself (i.e. without any mouse clicks having occurred) seems to be sufficient to allow the sound to play.
- Mac Safari, as far as I can tell, already implements exactly this same policy (but we didn't notice).
- There is, unfortunately, one problem: there is a way to play a sound without any user interaction (i.e. not even a green flag click), using the "when timer > 10" hat block. As far as I know this is the only way. In this case, on Chrome with the new autoplay policy (and on Safari currently), if you do not click on anything or press any keys, when you load the project, the sound will not start after the timer crosses 10s. As soon as you click or press a key, the sound will start.
I can think of two ways to proceed:
- No fix. Sounds started by the when timer block will not play until there has been a user interaction. This matches the intent of the autoplay policy.
- We have a bug where sounds are not allowed to start if triggered by the when timer block without any user interaction, and we need to handle it somehow. This could be:
- Detecting this (rare) situation, and showing some kind of notification ("click to enable Scratch to play sound")
- Some other strategy??
from scratch-audio.
Curious about your thoughts on this @paulkaplan
from scratch-audio.
Thanks for the thorough investigation! It is kind of funny because using the when "timer > 0 => play sound" construction is totally the scratch equivalent of autoplaying videos, so it makes sense that it would get blocked.
I'm curious about which scratch2 views actually play audio with no user interaction. The project page has the green flag overlay that starts the VM, so it wouldn't effect the project there, which is probably our main concern. The places that do rely on autoplay right now are:
- Going directly to /#editor (will be /editor in 3.0)
- Embed with autoplay=true does autoplay right now (not clear if that will exist in 3.0?)
from scratch-audio.
We are going with the "no fix" option for now, but leaving this in the backlog.
We are considering removing the autoplay option from embed mode.
from scratch-audio.
We are considering removing the autoplay option from embed mode.
For later discussion, I think it would be better to stay away from removing autoplay. It could still be a useful option on sites that, for example, specifically embed the player so that it's "flush" with the rest of the site's design; having to click the no-autoplay overlay green flag could clash with that.
from scratch-audio.
Related Issues (20)
- Notes initially ignore volume HOT 2
- The ADPCM decoder uses too much memory HOT 1
- RIFFVtWAVEfmt Wave Files don't load in 3.0
- The instruments could use some tweaks HOT 1
- Invalid content error in Firefox on one project
- Repeatedly changing the volume (e.g. fade-out) causes bitsy effect HOT 1
- Audio on a particular project can't be decoded successfully HOT 1
- Set volume to in a forever loop causes audio to stutter on Firefox HOT 2
- First time a sound plays it starts at full volume even if volume is set lower
- Pan left/right doesn't effect extension blocks HOT 1
- Extend the pitch effects limit HOT 3
- After numerous changes of volume/pitch, they became less responsive HOT 8
- "The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page." are displayed in chrome console when scratch is started. HOT 1
- npm-published packages should follow semver
- To remove the sound pitch limit completely HOT 1
- Dependency Dashboard
- module is not defined HOT 1
- Migrate from travis-after-all to Travis Stages
- Audio still clicks when restarting after a rest block HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scratch-audio.