Play() javascript function won't work
Reported by
ngmariol...@gmail.com,
Dec 10 2017
|
|||
Issue description
Steps to reproduce the problem:
1. Make a <audio> with autoplay and a src
2. Use a javascript code with envents "oncanplay" or "oncanplaythrough"
3. The paused state will be true (anormal), make a while(audio.paused) {audio.play();) and chrome will freeze all your android system and won't play the music
What is the expected behavior?
Normaly the music should play when she is loaded, and play() fonction should set *.paused as false
What went wrong?
The music has corretly loaded, but won't start because the autoplay is wrong
Did this work before? N/A
Chrome version: 62.0.3202.84 Channel: stable
OS Version: Android 7.0
Flash Version: Shockwave Flash 27.0 r0
,
Dec 11 2017
"freeze all your android system" looks severe. Can anyone take a look sooner? Routing to Blink>Media>Audio.
,
Dec 11 2017
Autoplay on Chrome Android requires a user gesture, like Safari iOS. You should call play() in the event handler of an event such as `click`. FWIW, you can check the result of the returned promise from `play()` to know if it succeeded. You can read more about this here: https://developers.google.com/web/updates/2017/06/play-request-was-interrupted
,
Dec 11 2017
,
Dec 11 2017
@Comment 2
yeah, Chrome set the CPU at 100% working, so it "freeze" Android (system answer slowly up to you stop Chrome)
@Comment 3
Why it require a user action ? 'Autoplay' should autoplay (like the name) the audio/video data when it ready (like firefox). Also, the autoplay work fine without user action on Chrome PC
I have tried a code like this (this freeze Chrome on Android):
<audio id="audioplayer" autoplay></audio>
var audiplayer = document.getElementById('audiplayer');
audioplayer.src = *source of audio data*;
audioplayer.load();
audioplayer.oncanplay = function() {
var TMP_AUDIO = document.getElementById('audiplayer');
while (TMP_AUDIO.paused) {TMP_AUDIO.play();}
};
,
Dec 11 2017
I have forget the <script> </script> balise on @Comment 5 |
|||
►
Sign in to add a comment |
|||
Comment 1 by pnangunoori@chromium.org
, Dec 11 2017